コード例 #1
0
	def fetchIssuesByVolume( self, series_id ):
		
		# before we search online, look in our cache, since we might already
		# have this info
		cvc = ComicVineCacher( )
		cached_volume_issues_result = cvc.get_volume_issues_info( series_id )

		if cached_volume_issues_result is not None:		
			return cached_volume_issues_result
		
		#---------------------------------	
		issues_url = self.api_base_url + "/issues/" + "?api_key=" + self.api_key + "&filter=volume:" + str(series_id) + "&field_list=id,volume,issue_number,name,image,cover_date,site_detail_url,description&format=json"
		content = self.getUrlContent(issues_url) 	
		cv_response = json.loads(content)
		
		if cv_response[ 'status_code' ] != 1:
			print >> sys.stderr, "Comic Vine query failed with error:  [{0}]. ".format( cv_response[ 'error' ] )
			return None
		#------------------------------------
		
		limit = cv_response['limit']
		current_result_count = cv_response['number_of_page_results']
		total_result_count = cv_response['number_of_total_results']
		#print "ATB total_result_count", total_result_count
		
		#print "ATB Found {0} of {1} results".format( cv_response['number_of_page_results'], cv_response['number_of_total_results'])
		volume_issues_result = cv_response['results']
		page = 1
		offset = 0
				
		# see if we need to keep asking for more pages...
		while ( current_result_count < total_result_count ):
			#print "ATB getting another page of issue results {0} of {1}...".format( current_result_count, total_result_count)
			page += 1
			offset += cv_response['number_of_page_results']

			#print issues_url+ "&offset="+str(offset)
			content = self.getUrlContent(issues_url + "&offset="+str(offset)) 
			cv_response = json.loads(content)
		
			if cv_response[ 'status_code' ] != 1:
				self.writeLog( "Comic Vine query failed with error:  [{0}]. \n".format( cv_response[ 'error' ] ))
				return None
			volume_issues_result.extend( cv_response['results'])
			current_result_count += cv_response['number_of_page_results']				
				
		self.repairUrls( volume_issues_result )

		cvc.add_volume_issues_info( series_id, volume_issues_result )

		return volume_issues_result
コード例 #2
0
ファイル: comicvinetalker.py プロジェクト: xeddmc/mylar
    def fetchIssuesByVolume(self, series_id):

        # before we search online, look in our cache, since we might already
        # have this info
        cvc = ComicVineCacher()
        cached_volume_issues_result = cvc.get_volume_issues_info(series_id)

        if cached_volume_issues_result is not None:
            return cached_volume_issues_result

        #---------------------------------
        issues_url = self.api_base_url + "/issues/" + "?api_key=" + self.api_key + "&filter=volume:" + \
            str(series_id) + \
            "&field_list=id,volume,issue_number,name,image,cover_date,site_detail_url,description&format=json"
        cv_response = self.getCVContent(issues_url)

        #------------------------------------

        limit = cv_response['limit']
        current_result_count = cv_response['number_of_page_results']
        total_result_count = cv_response['number_of_total_results']
        # print "ATB total_result_count", total_result_count

        #print("ATB Found {0} of {1} results".format(cv_response['number_of_page_results'], cv_response['number_of_total_results']))
        volume_issues_result = cv_response['results']
        page = 1
        offset = 0

        # see if we need to keep asking for more pages...
        while (current_result_count < total_result_count):
            #print("ATB getting another page of issue results {0} of {1}...".format(current_result_count, total_result_count))
            page += 1
            offset += cv_response['number_of_page_results']

            # print issues_url+ "&offset="+str(offset)
            cv_response = self.getCVContent(
                issues_url + "&offset=" + str(offset))

            volume_issues_result.extend(cv_response['results'])
            current_result_count += cv_response['number_of_page_results']

        self.repairUrls(volume_issues_result)

        cvc.add_volume_issues_info(series_id, volume_issues_result)

        return volume_issues_result