2012-10-30 10:43:01 +00:00
import sys
import urllib
import os . path
import ConfigParser
IMP: (#844)Annuals now deleted from table on a Delete Series command, IMP: (#837)Better volume detection when searching for issues, IMP: (#842)(#808) Added some handling for issue titles when searching (it's not perfect, but it works for most), IMP: (#836)Added .cb7 for filechecking purposes only, IMP: (#830)issue numbers that are -1 can now be renamed, FIX: 'bi-annual' now fixed along with some other improvements for annual handling, IMP: Added version check for autoProcessComics and ComicRN - in order to help warn users of changes and the need to update these files since they are usually outside of the mylar git directory when being used, FIX:(#840) Boxcar2 should be working again, FIX: (#845) If search returned a filename that had no distinction between issue number and issue title and/or extra information, would error out if any of the words contained NOW, IMP: (#823) Added some better detection for NZBGet parameters when using ComicRN.py
2014-10-06 18:10:36 +00:00
apc_version = " 1.0 "
2012-10-30 10:43:01 +00:00
class AuthURLOpener ( urllib . FancyURLopener ) :
def __init__ ( self , user , pw ) :
self . username = user
self . password = pw
self . numTries = 0
urllib . FancyURLopener . __init__ ( self )
def prompt_user_passwd ( self , host , realm ) :
if self . numTries == 0 :
self . numTries = 1
return ( self . username , self . password )
else :
return ( ' ' , ' ' )
def openit ( self , url ) :
self . numTries = 0
return urllib . FancyURLopener . open ( self , url )
IMP: (#844)Annuals now deleted from table on a Delete Series command, IMP: (#837)Better volume detection when searching for issues, IMP: (#842)(#808) Added some handling for issue titles when searching (it's not perfect, but it works for most), IMP: (#836)Added .cb7 for filechecking purposes only, IMP: (#830)issue numbers that are -1 can now be renamed, FIX: 'bi-annual' now fixed along with some other improvements for annual handling, IMP: Added version check for autoProcessComics and ComicRN - in order to help warn users of changes and the need to update these files since they are usually outside of the mylar git directory when being used, FIX:(#840) Boxcar2 should be working again, FIX: (#845) If search returned a filename that had no distinction between issue number and issue title and/or extra information, would error out if any of the words contained NOW, IMP: (#823) Added some better detection for NZBGet parameters when using ComicRN.py
2014-10-06 18:10:36 +00:00
def processEpisode ( dirName , nzbName = None ) :
print " Your ComicRN.py script is outdated. I ' ll force this through, but Failed Download Handling and possible enhancements/fixes will not work and could cause errors. "
return processIssue ( dirName , nzbName )
2012-10-30 10:43:01 +00:00
IMP: (#844)Annuals now deleted from table on a Delete Series command, IMP: (#837)Better volume detection when searching for issues, IMP: (#842)(#808) Added some handling for issue titles when searching (it's not perfect, but it works for most), IMP: (#836)Added .cb7 for filechecking purposes only, IMP: (#830)issue numbers that are -1 can now be renamed, FIX: 'bi-annual' now fixed along with some other improvements for annual handling, IMP: Added version check for autoProcessComics and ComicRN - in order to help warn users of changes and the need to update these files since they are usually outside of the mylar git directory when being used, FIX:(#840) Boxcar2 should be working again, FIX: (#845) If search returned a filename that had no distinction between issue number and issue title and/or extra information, would error out if any of the words contained NOW, IMP: (#823) Added some better detection for NZBGet parameters when using ComicRN.py
2014-10-06 18:10:36 +00:00
def processIssue ( dirName , nzbName = None , failed = False , comicrn_version = None ) :
2012-10-30 10:43:01 +00:00
config = ConfigParser . ConfigParser ( )
configFilename = os . path . join ( os . path . dirname ( sys . argv [ 0 ] ) , " autoProcessComics.cfg " )
print " Loading config from " , configFilename
if not os . path . isfile ( configFilename ) :
print " ERROR: You need an autoProcessComics.cfg file - did you rename and edit the .sample? "
sys . exit ( - 1 )
try :
fp = open ( configFilename , " r " )
config . readfp ( fp )
fp . close ( )
except IOError , e :
print " Could not read configuration file: " , str ( e )
sys . exit ( 1 )
host = config . get ( " Mylar " , " host " )
port = config . get ( " Mylar " , " port " )
username = config . get ( " Mylar " , " username " )
password = config . get ( " Mylar " , " password " )
try :
ssl = int ( config . get ( " Mylar " , " ssl " ) )
except ( ConfigParser . NoOptionError , ValueError ) :
ssl = 0
try :
web_root = config . get ( " Mylar " , " web_root " )
except ConfigParser . NoOptionError :
web_root = " "
params = { }
params [ ' nzb_folder ' ] = dirName
if nzbName != None :
params [ ' nzb_name ' ] = nzbName
FIX: undefined on filter box on startup, IMP: Added Meta-Tagging options on a series / issue basis on comic details screen, IMP: Issue Information is now available per issue and is extracted currently from the cbz file to display (if no cbz is present, the option isn't available), IMP: Failed Download handling is implemented and available in GUI - required to replace existing autoProcessComics.py and ComicRN.py scripts, IMP: Added ability to specify post-processing script instead of ComicRN.py, IMP: Added abilty to edit the issue date for a given issue by simply clicking on it - this will help to avoid dates that have incorrect or 0000-00-00, IMP: Story Arc searching is working (not adding yet), IMP: Added Archived/Ignored options to Upcoming/Wanted tab, IMP: Fixed some alignment and display issues on the Upcoming section, IMP: Added better directory handling for Updating Comic Location when it needs to get changed for all existing series (locmove in config.ini), IMP: Added better handling for unicode characters in series titles when searching / filechecking, IMP: When adding a new series with no data, Mylar would error out (now will add and just retain 0 issues), FIX: When year was fuzzied, search would still attempt to do a date-check comparison and say everything failed, IMP: Better handling of nzb names when retaining for post-processing comparisons, IMP: Future Upcoming now will use actual shipping date of issue if available in order to see if issue is available, FIX: If annuals were enabled, refreshing a series would put some issues into an Archived status because the actual counts would be off, IMP: When file checking, Alternate Naming would be searched last which resulted in matching incorrectly to the series title or other alternate naming for the given series, now will check the Alternate Naming first for a match, then drop back down to the series name itself otherwise, IMP: Improved Annual detection when integrated with a given series, IMP: Improved the checking of the future Upcoming list for issues marked as Wanted but not available yet and then auto-adding, IMP: Improved upon story arc checking for missing issues / searching for wanted, IMP: Enabling Annuals support now within Configuration GUI, bunch of other things....
2014-07-28 19:28:09 +00:00
params [ ' failed ' ] = failed
IMP: (#844)Annuals now deleted from table on a Delete Series command, IMP: (#837)Better volume detection when searching for issues, IMP: (#842)(#808) Added some handling for issue titles when searching (it's not perfect, but it works for most), IMP: (#836)Added .cb7 for filechecking purposes only, IMP: (#830)issue numbers that are -1 can now be renamed, FIX: 'bi-annual' now fixed along with some other improvements for annual handling, IMP: Added version check for autoProcessComics and ComicRN - in order to help warn users of changes and the need to update these files since they are usually outside of the mylar git directory when being used, FIX:(#840) Boxcar2 should be working again, FIX: (#845) If search returned a filename that had no distinction between issue number and issue title and/or extra information, would error out if any of the words contained NOW, IMP: (#823) Added some better detection for NZBGet parameters when using ComicRN.py
2014-10-06 18:10:36 +00:00
params [ ' apc_version ' ] = apc_version
params [ ' comicrn_version ' ] = comicrn_version
2012-10-30 10:43:01 +00:00
myOpener = AuthURLOpener ( username , password )
if ssl :
protocol = " https:// "
else :
protocol = " http:// "
url = protocol + host + " : " + port + web_root + " /post_process? " + urllib . urlencode ( params )
print " Opening URL: " , url
try :
urlObj = myOpener . openit ( url )
except IOError , e :
print " Unable to open URL: " , str ( e )
sys . exit ( 1 )
result = urlObj . readlines ( )
for line in result :
print line
2013-05-16 17:46:34 +00:00
FIX: (#746) updated autoProcessComics.py / ComicRN.py's which will now send proper completion messeages to clients, FIX: (#752) refresh series will now test if a series is 'out of whack' with it's numerical issue count (ie. 5/4) or it has no issue data due to a bad refresh / api maxing out and will adjust it's processing to accomodate either, IMP: (#750) Added ComicVine API Checker which will check API counts at regular intervals to inform/warn users of usage, as well as adding a screen-time display of API hits / mins used at the bottom of every page (refreshing/reloading pages will update counts), FIX: (#747)EOL normalization (dos2unix) on search.py - removed classes & exceptions as not being used, IMP: (#747) Skip processing issues with an invalid store date & issue date (thnx rupaschomaker), FIX: Removed strings when searching/logging torrents as was causing ascii errors especially with KAT, IMP: Added [META-TAGGING] to logging for meta-tagging module, IMP: Added ability in GUI to select CR or Cbl tags (or both) when writing metadata to cbz files, IMP: Improved support/usage with ComicTagger v1.1.15 which allows for personal CV API Key usage - if supplied to Mylar, will use when tagging with ComicTagger, IMP: Added Manual Search option to allow for individual searches of issues without changing initial status.
2014-06-18 19:58:19 +00:00
if any ( " Post Processing SUCCESSFUL " in s for s in result ) :
2013-05-16 17:46:34 +00:00
return 0
2013-05-17 01:36:10 +00:00
else :
2013-05-16 17:46:34 +00:00
return 1