Ejemplo n.º 1
0
    def __extract_issue_ref(self):
        '''
      This method attempts to rebuild the IssueRef that the user chose the 
      last time that they scraped this comic.  If it can do so, it will 
      return that IssueRef. If not, it will return None, or the 
      string "skip" (see below).   
      
      If the user has manually added the magic CVDBSKIP flag to the tags or 
      notes for this book, then this method will return the string "skip", 
      which should be interpreted as "never scrape this book".
      '''

        # in this method, its easier to work with tags as a single string
        bd = self.__bookdata
        tagstring = ', '.join(bd.tags_sl)

        # check for the magic CVDBSKIP skip flag
        skip_found = re.search(r'(?i)' + ComicBook.CVDBSKIP, tagstring)
        if not skip_found:
            skip_found = re.search(r'(?i)' + ComicBook.CVDBSKIP, bd.notes_s)
        retval = "skip" if skip_found else None

        if retval is None:
            # if no skip tag, see if there's a key tag in the tags or notes
            issue_key = db.parse_key_tag(tagstring)

            if issue_key == None:
                issue_key = db.parse_key_tag(bd.notes_s)

            if issue_key == None:
                issue_key = int(bd.issue_key_s) if \
                   utils.is_number(bd.issue_key_s) else None

            if issue_key != None:
                # found a key tag! convert to an IssueRef
                retval = IssueRef(self.issue_num_s, issue_key,
                                  self.__bookdata.title_s,
                                  self.__bookdata.cover_url_s)

        return retval
Ejemplo n.º 2
0
def __issue_to_issueref(issue):
   ''' Converts a cvdb "issue" dom element into an IssueRef. '''
   issue_num_s = issue.issue_number
   issue_num_s = issue_num_s.strip() if is_string(issue_num_s) else ''
   title_s = issue.name.strip() if is_string(issue.name) else ''
   return IssueRef(issue_num_s, issue.id, title_s, __parse_image_url(issue))