Monday, July 23, 2018

ComicTagger Error StrpTime

Long time, no see/speak/etc.    You can thank an annoying, seemingly obscure technical problem I ran into for breaking my 42 months of blog silence.  These hiatuses (yatus #bigbrother) seem to be getting longer and longer over the years.

So anyways, I decided to try to organize my electronic comic book collection yesterday and installed a program called ComicTagger, which helps grab and write metadata for comic books.  

I get it installed and ran into my first problem right off the bat.  The application wants you to put in the path to WinRar (or any RAR/UnRAR program) but the little tool you use to navigate through your filesystem doesn't actually navigate anything.  It'll open the box and show you your root folder, but none of the contents.  The workaround for that was to just manually type in the path.  Since I'm running Linux, my path was "/usr/bin/rar" and "usr/bin/unrar"

Problem solved!  Let's get to tagging comics!  I drag and drop a file over to test and wait.  And wait.  And wait some more.  The dialog box that popped up is just sitting at 0% for a few minutes before I realize that there's an error in the terminal window and I'm stuck.  Here's what I see:

Traceback (most recent call last):  File "/usr/local/lib/python2.7/dist-packages/comictaggerlib/", line 540, in dropEvent    self.fileSelectionList.addPathList( self.droppedFiles )  File "/usr/local/lib/python2.7/dist-packages/comictaggerlib/", line 196, in addPathList    row = self.addPathItem( f )  File "/usr/local/lib/python2.7/dist-packages/comictaggerlib/", line 271, in addPathItem    if ca.seemsToBeAComicArchive() :  File "/usr/local/lib/python2.7/dist-packages/comictaggerlib/", line 618, in seemsToBeAComicArchive    ( self.getNumberOfPages() > 0)  File "/usr/local/lib/python2.7/dist-packages/comictaggerlib/", line 775, in getNumberOfPages    self.page_count = len( self.getPageNameList( ) )  File "/usr/local/lib/python2.7/dist-packages/comictaggerlib/", line 751, in getPageNameList    files = self.archiver.getArchiveFilenameList()  File "/usr/local/lib/python2.7/dist-packages/comictaggerlib/", line 395, in getArchiveFilenameList    for item in rarc.infolist():  File "/usr/local/lib/python2.7/dist-packages/comictaggerlib/UnRAR2/", line 127, in infolist    return list(self.infoiter())  File "/usr/local/lib/python2.7/dist-packages/comictaggerlib/UnRAR2/", line 122, in infoiter    for params in RarFileImplementation.infoiter(self):  File "/usr/local/lib/python2.7/dist-packages/comictaggerlib/UnRAR2/", line 171, in infoiter    data['datetime'] = time.strptime(fields[2]+" "+fields[3], '%d-%m-%y %H:%M')  File "/usr/lib/python2.7/", line 478, in _strptime_time    return _strptime(data_string, format)[0]  File "/usr/lib/python2.7/", line 332, in _strptime    (data_string, format))ValueError: time data '2006-03-29 18:32' does not match format '%d-%m-%y %H:%M'
The highlighted section is the actual error.  There's nothing about this on the project Github site, the Google site the code was originally housed on, or the application's web forum.  NOTHING.  There is literally one post on an Ubuntu forum where a dude asks about the issue in 2016, but no one ever responded!  And if he ever discovered the fix, he didn't post it in that thread.  DON'T EVER DO THAT.  If you fix your own problem, update the fucking thread!

Anyway, I DID figure out a fix and I decided to post it on my blog, so if anyone else runs into the problem, it's a 30 second fix and not hours of googling like a moron (me!)  I should've just sat down and worked through the problem like I finally did this morning. It took me about 45 minutes and 25ish minutes of that was trying to find and install a text editor that had line numbers on it, haha.  I tried Sublime and it wasn't.  Now I know why the editor war has been ongoing for over 30 years.

In this case, ComicTagger is choking while trying to strip out and reformat the date it finds in my CDisplay RAR Archived Comic Book (CBR) file.  It looks like the (or A) programmer hardcoded the date format as %d-%m-%y %H:%M, which is Day-Month-Year (two digit) Hour:Minute (Military format.)  However, it looks like the file date that was getting pulled from my CBR files were in YYYY-MM-DD HH:MM. The strptime Python module was throwing up an error because the date that was getting passed to it wasn't matching. 

Here's the fix:  I went into /usr/local/lib/python2.7/dist-packages/comictaggerlib/UnRAR2/ and edited line 171 to reflect the actual format that was needed:

data['datetime'] = time.strptime(fields[3]+" "+fields[4], '%Y-%m-%d %H:%M')
There you go.  Now I've wasted another 90 minutes writing this up. I hope you appreciate all that I do for you!

See you in 2022, bitches!

No comments: