예제 #1
0
	def metadataFromString( self, string ):
	
		cbi_container = json.loads( unicode(string, 'utf-8') )

		metadata = GenericMetadata()

		cbi = cbi_container[ 'ComicBookInfo/1.0' ]

		#helper func 
		# If item is not in CBI, return None
		def xlate( cbi_entry):
			if cbi_entry in cbi:
				return cbi[cbi_entry] 
			else:	
				return None 
		
		metadata.series =            xlate( 'series' )
		metadata.title =             xlate( 'title' )
		metadata.issue =             xlate( 'issue' )
		metadata.publisher =         xlate( 'publisher' )
		metadata.month =             xlate( 'publicationMonth' )
		metadata.year =              xlate( 'publicationYear' )
		metadata.issueCount =        xlate( 'numberOfIssues' )
		metadata.comments =          xlate( 'comments' )
		metadata.credits =           xlate( 'credits' )
		metadata.genre =             xlate( 'genre' )
		metadata.volume =            xlate( 'volume' )
		metadata.volumeCount =       xlate( 'numberOfVolumes' )
		metadata.language =          xlate( 'language' )
		metadata.country =           xlate( 'country' )
		metadata.criticalRating =    xlate( 'rating' )
		metadata.tags =              xlate( 'tags' )
		
		# make sure credits and tags are at least empty lists and not None
		if metadata.credits is None:
			metadata.credits = []
		if metadata.tags is None:
			metadata.tags = []
			
		#need to massage the language string to be ISO
		if metadata.language is not None:
			# reverse look-up
			pattern = metadata.language
			metadata.language = None
			for key in utils.getLanguageDict():
				if utils.getLanguageDict()[ key ] == pattern.encode('utf-8'):
					metadata.language = key
					break
		
		metadata.isEmpty = False
		
		return metadata
예제 #2
0
    def metadataFromString(self, string):

        cbi_container = json.loads(unicode(string, 'utf-8'))

        metadata = GenericMetadata()

        cbi = cbi_container['ComicBookInfo/1.0']

        #helper func
        # If item is not in CBI, return None
        def xlate(cbi_entry):
            if cbi_entry in cbi:
                return cbi[cbi_entry]
            else:
                return None

        metadata.series = xlate('series')
        metadata.title = xlate('title')
        metadata.issue = xlate('issue')
        metadata.publisher = xlate('publisher')
        metadata.month = xlate('publicationMonth')
        metadata.year = xlate('publicationYear')
        metadata.issueCount = xlate('numberOfIssues')
        metadata.comments = xlate('comments')
        metadata.credits = xlate('credits')
        metadata.genre = xlate('genre')
        metadata.volume = xlate('volume')
        metadata.volumeCount = xlate('numberOfVolumes')
        metadata.language = xlate('language')
        metadata.country = xlate('country')
        metadata.criticalRating = xlate('rating')
        metadata.tags = xlate('tags')

        # make sure credits and tags are at least empty lists and not None
        if metadata.credits is None:
            metadata.credits = []
        if metadata.tags is None:
            metadata.tags = []

        #need to massage the language string to be ISO
        if metadata.language is not None:
            # reverse look-up
            pattern = metadata.language
            metadata.language = None
            for key in utils.getLanguageDict():
                if utils.getLanguageDict()[key] == pattern.encode('utf-8'):
                    metadata.language = key
                    break

        metadata.isEmpty = False

        return metadata
예제 #3
0
    def mapCVDataToMetadata(self, volume_results, issue_results, settings):

        # Now, map the Comic Vine data to generic metadata
        metadata = GenericMetadata()

        metadata.series = issue_results['volume']['name']

        num_s = IssueString(issue_results['issue_number']).asString()
        metadata.issue = num_s
        metadata.title = issue_results['name']

        metadata.publisher = volume_results['publisher']['name']
        metadata.day, metadata.month, metadata.year = self.parseDateStr(
            issue_results['cover_date'])

        #metadata.issueCount = volume_results['count_of_issues']
        metadata.comments = self.cleanup_html(
            issue_results['description'], settings.remove_html_tables)
        if settings.use_series_start_as_volume:
            metadata.volume = volume_results['start_year']

        metadata.notes = "Tagged with the {0} fork of ComicTagger {1} using info from Comic Vine on {2}.  [Issue ID {3}]".format(
            ctversion.fork,
            ctversion.version,
            datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
            issue_results['id'])
        #metadata.notes  += issue_results['site_detail_url']

        metadata.webLink = issue_results['site_detail_url']

        person_credits = issue_results['person_credits']
        for person in person_credits:
            if 'role' in person:
                roles = person['role'].split(',')
                for role in roles:
                    # can we determine 'primary' from CV??
                    metadata.addCredit(
                        person['name'], role.title().strip(), False)

        character_credits = issue_results['character_credits']
        character_list = list()
        for character in character_credits:
            character_list.append(character['name'])
        metadata.characters = utils.listToString(character_list)

        team_credits = issue_results['team_credits']
        team_list = list()
        for team in team_credits:
            team_list.append(team['name'])
        metadata.teams = utils.listToString(team_list)

        location_credits = issue_results['location_credits']
        location_list = list()
        for location in location_credits:
            location_list.append(location['name'])
        metadata.locations = utils.listToString(location_list)

        story_arc_credits = issue_results['story_arc_credits']
        arc_list = []
        for arc in story_arc_credits:
            arc_list.append(arc['name'])
        if len(arc_list) > 0:
            metadata.storyArc = utils.listToString(arc_list)

        return metadata