Esempio n. 1
0
    def markissues(self, action=None, **args):
        myDB = db.DBConnection()
        if action == 'WantedNew':
            newaction = 'Wanted'
        else:
            newaction = action
        for IssueID in args:
            if IssueID is None: break
            print("IssueID:" + IssueID)
            mi = myDB.action("SELECT * FROM issues WHERE IssueID=?",[IssueID]).fetchone()
            miyr = myDB.action("SELECT ComicYear FROM comics WHERE ComicID=?", [mi['ComicID']]).fetchone()
            logger.info(u"Marking %s %s as %s" % (mi['ComicName'], mi['Issue_Number'], newaction))
            controlValueDict = {"IssueID": mbid}
            newValueDict = {"Status": newaction}
            myDB.upsert("issues", newValueDict, controlValueDict)
            if action == 'Skipped': pass
            elif action == 'Wanted':
                foundcoms = search.search_init(mi['ComicName'], mi['Issue_Number'], mi['IssueDate'][:4], miyr['ComicYear'])
                #searcher.searchforissue(mbid, new=False)
            elif action == 'WantedNew':
                foundcoms = search.search_init(mi['ComicName'], mi['Issue_Number'], mi['IssueDate'][:4], miyr['ComicYear'])
                #searcher.searchforissue(mbid, new=True)
            if foundcoms  == "yes":
                logger.info(u"Found " + mi['ComicName'] + " issue: " + mi['Issue_Number'] + " ! Marking as Snatched...")
                # file check to see if issue exists and update 'have' count
                if IssueID is not None:
                    ComicID = mi['ComicID']
                    print ("ComicID: " + str(ComicID))
                    comic =  myDB.action('SELECT * FROM comics WHERE ComicID=?', [ComicID]).fetchone()
                    print ("comic location: " + comic['ComicLocation'])
                    #fc = filechecker.listFiles(comic['ComicLocation'], mi['ComicName'])
                    #HaveDict = {'ComicID': ComicID}
                    #newHave = { 'Have':     fc['comiccount'] }
                    #myDB.upsert("comics", newHave, HaveDict)
                    controlValueDict = {'IssueID':  IssueID}
                    newValueDict = {'Status': 'Snatched'}
                    myDB.upsert("issues", newValueDict, controlValueDict)
                    snatchedupdate = {"IssueID":     IssueID}
                    newsnatchValues = {"ComicName":       mi['ComicName'],
                                       "ComicID":         ComicID,
                                       "Issue_Number":    mi['Issue_Number'],
                                       "DateAdded":       helpers.today(),
                                       "Status":          "Snatched"
                                       }
                    myDB.upsert("snatched", newsnatchValues, snatchedupdate)
            else:
                logger.info(u"Couldn't find " + mi['ComicName'] + " issue: " + mi['Issue_Number'] + " ! Status still wanted...")

        if ComicID:
            raise cherrypy.HTTPRedirect("artistPage?ComicID=%s" % ComicID)
        else:
            raise cherrypy.HTTPRedirect("upcoming")
Esempio n. 2
0
 def queueissue(self, mode, ComicName=None, ComicID=None, ComicYear=None, ComicIssue=None, IssueID=None, new=False, redirect=None):                   
     now = datetime.datetime.now()
     myDB = db.DBConnection()
     #mode dictates type of queue - either 'want' for individual comics, or 'series' for series watchlist.
     if ComicID is None and mode == 'series':
         issue = None
         raise cherrypy.HTTPRedirect("searchit?name=%s&issue=%s&mode=%s" % (ComicName, 'None', 'series'))
     elif ComicID is None and mode == 'pullseries':
         # we can limit the search by including the issue # and searching for
         # comics that have X many issues
         raise cherrypy.HTTPRedirect("searchit?name=%s&issue=%s&mode=%s" % (ComicName, 'None', 'pullseries'))
     elif ComicID is None and mode == 'pullwant':          
         #this is for marking individual comics from the pullist to be downloaded.
         #because ComicID and IssueID will both be None due to pullist, it's probably
         #better to set both to some generic #, and then filter out later...
         cyear = myDB.action("SELECT SHIPDATE FROM weekly").fetchone()
         ComicYear = str(cyear['SHIPDATE'])[:4]
         if ComicYear == '': ComicYear = now.year
         logger.info(u"Marking " + ComicName + " " + ComicIssue + " as wanted...")
         foundcom = search.search_init(ComicName=ComicName, IssueNumber=ComicIssue, ComicYear=ComicYear, SeriesYear=None, IssueDate=cyear['SHIPDATE'], IssueID=IssueID)
         if foundcom  == "yes":
             logger.info(u"Downloaded " + ComicName + " " + ComicIssue )  
         return
     elif mode == 'want':
         cdname = myDB.action("SELECT ComicName from comics where ComicID=?", [ComicID]).fetchone()
         ComicName = cdname['ComicName']
         logger.info(u"Marking " + ComicName + " issue: " + ComicIssue + " as wanted...")
     #---
     #this should be on it's own somewhere
     if IssueID is not None:
         controlValueDict = {"IssueID": IssueID}
         newStatus = {"Status": "Wanted"}
         myDB.upsert("issues", newStatus, controlValueDict)
     #for future reference, the year should default to current year (.datetime)
     issues = myDB.action("SELECT IssueDate FROM issues WHERE IssueID=?", [IssueID]).fetchone()
     if ComicYear == None:
         ComicYear = str(issues['IssueDate'])[:4]
     miy = myDB.action("SELECT * FROM comics WHERE ComicID=?", [ComicID]).fetchone()
     SeriesYear = miy['ComicYear']
     AlternateSearch = miy['AlternateSearch']
     foundcom = search.search_init(ComicName, ComicIssue, ComicYear, SeriesYear, issues['IssueDate'], IssueID, AlternateSearch)
     if foundcom  == "yes":
         # file check to see if issue exists and update 'have' count
         if IssueID is not None:
             return updater.foundsearch(ComicID, IssueID) 
     if ComicID:
         raise cherrypy.HTTPRedirect("artistPage?ComicID=%s" % ComicID)
     else:
         raise cherrypy.HTTPRedirect(redirect)