Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

When importing cvinfo w/o full URL list index out of range causes exception #1923

Closed
boshuda opened this issue Apr 18, 2018 · 0 comments
Closed

Comments

@boshuda
Copy link
Contributor

boshuda commented Apr 18, 2018

When importing a folder containing a cvinfo file the following appeared in the log: ERROR :: mylar.scanLibrary.620 : LibraryScan : [IMPORT] Unable to complete the scan: list index out of range

I traced it through to libraryScan in librarysync.py, around line 254:

            try:
                with open(os.path.join(os.path.dirname(comlocation), 'cvinfo')) as f:
                    urllink = f.readline()

                if urllink:
                    cid = urllink.split('/')
                    if '4050-' in cid[-2]:
                        cvinfo_CID = re.sub('4050-', '', cid[-2]).strip()
                        logger.info('CVINFO file located within directory. Attaching everything in directory that is valid to ComicID: ' + str(cvinfo_CID))
                        #store the location of the cvinfo so it's applied to the correct directory (since we're scanning multile direcorties usually)
                        cvscanned_loc = os.path.dirname(comlocation)
                else:
                    logger.error("Could not read cvinfo file properly (or it does not contain any data)")
            except (OSError, IOError):
                logger.error("Could not read cvinfo file properly (or it does not contain any data)")

You can see it splits the urllink by the '/' character. However, a cvinfo file as described in Comicvine Scraper doesn't require the full url. Just the 4050-xxxxx part. So when it isn't able to create a list long enough to look for cid[-2], the index out of range error occurs. Seems like it would be reasonable to do a regex to look for the digits following the 4050- portion, and that would take care of any format a person might use.

While filing this, I did a fork and a fix. I'll commit the change and make a pull request.

boshuda added a commit to boshuda/mylar that referenced this issue Apr 18, 2018
If the cvinfo had information in an unsupported format, like just 4050-xxxxx then the regular expression sub would cause an end of index exception.

Now the regex just looks for 4050-xxxxx, and doesn't really care about the format.

evilhero#1923
evilhero pushed a commit that referenced this issue Apr 18, 2018
If the cvinfo had information in an unsupported format, like just 4050-xxxxx then the regular expression sub would cause an end of index exception.

Now the regex just looks for 4050-xxxxx, and doesn't really care about the format.

#1923
@evilhero evilhero closed this as completed Jan 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants