예제 #1
0
    def createComicFromMetadata(self, md):

        comic = Comic()
        # store full path, and filename and folder separately, for search efficiency,
        # at the cost of redundant storage
        comic.folder, comic.file = os.path.split(md.path)
        comic.path = md.path

        comic.page_count = md.page_count
        comic.mod_ts = md.mod_ts
        comic.hash = md.hash
        comic.filesize = md.filesize
        comic.thumbnail = md.thumbnail

        if not md.isEmpty:
            if md.series is not None:
                comic.series = str(md.series)
            if md.issue is not None:
                comic.issue = str(md.issue)
                comic.issue_num = IssueString(str(comic.issue)).asFloat()

            if md.year is not None:
                try:
                    day = 1
                    month = 1
                    if md.month is not None:
                        month = int(md.month)
                    if md.day is not None:
                        day = int(md.day)
                    year = int(md.year)
                    comic.date = datetime(year, month, day)
                except Exception as e:
                    logging.exception(e)
                    pass

            comic.year = md.year
            comic.month = md.month
            comic.day = md.day

            if md.volume is not None:
                comic.volume = int(md.volume)
            if md.publisher is not None:
                comic.publisher = str(md.publisher)
            if md.title is not None:
                comic.title = str(md.title)
            if md.comments is not None:
                comic.comments = str(md.comments)
            if md.imprint is not None:
                comic.imprint = str(md.imprint)
            if md.webLink is not None:
                comic.weblink = str(md.webLink)

        self.update_comic_meta(comic, md)

        return comic
예제 #2
0
    def createComicFromMetadata(self, md):
        """
        Translate the metadata to actual DB data!
        """

        comic = Comic()
        # store full path, and filename and folder separately, for search efficiency,
        # at the cost of redundant storage
        comic.folder, comic.file = os.path.split(md.path)
        comic.path = md.path

        comic.page_count = md.page_count
        comic.mod_ts = md.mod_ts
        comic.hash = md.hash
        comic.filesize = md.filesize
        comic.fingerprint = md.fingerprint
        comic.thumbnail = md.thumbnail

        if not md.isEmpty:
            if md.series is not None:
                comic.series = unicode(md.series)
            if md.issue is not None:
                comic.issue = unicode(md.issue)
                comic.issue_num = IssueString(unicode(comic.issue)).asFloat()

            if md.alternateNumber is not None:
                comic.alternateIssue = unicode(md.alternateNumber)
                comic.alternateNumber = IssueString(
                    unicode(comic.alternateIssue)).asFloat()
            if md.year is not None:
                try:
                    day = 1
                    month = 1
                    if md.month is not None:
                        month = int(md.month)
                    if md.day is not None:
                        day = int(md.day)
                    year = int(md.year)
                    comic.date = datetime(year, month, day)
                except:
                    pass

            comic.year = md.year
            comic.month = md.month
            comic.day = md.day

            if md.volume is not None:
                comic.volume = int(md.volume)
            if md.publisher is not None:
                comic.publisher = unicode(md.publisher)
            if md.language is not None:
                comic.language = unicode(md.language)
            if md.title is not None:
                comic.title = unicode(md.title)
            if md.comments is not None:
                comic.comments = unicode(md.comments)
            if md.imprint is not None:
                comic.imprint = unicode(md.imprint)
            if md.webLink is not None:
                comic.weblink = unicode(md.webLink)

        if md.characters is not None:
            for c in list(set(md.characters.split(","))):
                character = self.getNamedEntity(Character, c.strip())
                comic.characters_raw.append(character)

        if md.teams is not None:
            for t in list(set(md.teams.split(","))):
                team = self.getNamedEntity(Team, t.strip())
                comic.teams_raw.append(team)

        if md.locations is not None:
            for l in list(set(md.locations.split(","))):
                location = self.getNamedEntity(Location, l.strip())
                comic.locations_raw.append(location)

        if md.alternateSeries is not None:
            for alt in list(set(md.alternateSeries.split(","))):
                alternateseries = self.getNamedEntity(AlternateSeries,
                                                      alt.strip())
                comic.alternateseries_raw.append(alternateseries)

        if md.storyArc is not None:
            for sa in list(set(md.storyArc.split(","))):
                storyarc = self.getNamedEntity(StoryArc, sa.strip())
                comic.storyarcs_raw.append(storyarc)

        if md.genre is not None:
            for g in list(set(md.genre.split(","))):
                genre = self.getNamedEntity(Genre, g.strip())
                comic.genres_raw.append(genre)

        if md.tags is not None:
            for gt in list(set(md.tags)):
                generictag = self.getNamedEntity(GenericTag, gt.strip())
                comic.generictags_raw.append(generictag)

        if md.credits is not None:
            for credit in md.credits:
                role = self.getNamedEntity(Role,
                                           credit['role'].lower().strip())
                person = self.getNamedEntity(Person, credit['person'].strip())
                comic.credits_raw.append(Credit(person, role))

        return comic