當前位置: 首頁>>代碼示例>>Python>>正文


Python comicvinecacher.ComicVineCacher類代碼示例

本文整理匯總了Python中comicvinecacher.ComicVineCacher的典型用法代碼示例。如果您正苦於以下問題:Python ComicVineCacher類的具體用法?Python ComicVineCacher怎麽用?Python ComicVineCacher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ComicVineCacher類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: fetchVolumeData

    def fetchVolumeData( self, series_id ):
        
        # before we search online, look in our cache, since we might already
        # have this info
        cvc = ComicVineCacher( )
        cached_volume_result = cvc.get_volume_info( series_id )
        
        if cached_volume_result is not None:
            return cached_volume_result

    
        volume_url = self.api_base_url + "/volume/" + CVTypeID.Volume + "-" + str(series_id) + "/?api_key=" + self.api_key + "&field_list=name,id,start_year,publisher,count_of_issues&format=json"

        content = self.getUrlContent(volume_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

        volume_results = cv_response['results']
    
        cvc.add_volume_info( volume_results )

        return volume_results
開發者ID:goldsoundz,項目名稱:comictagger,代碼行數:25,代碼來源:comicvinetalker.py

示例2: fetchCachedAlternateCoverURLs

    def fetchCachedAlternateCoverURLs(self, issue_id):

        # before we search online, look in our cache, since we might already
        # have this info
        cvc = ComicVineCacher()
        url_list = cvc.get_alt_covers(issue_id)
        if url_list is not None:
            return url_list
        else:
            return None
開發者ID:DarkSir23,項目名稱:mylar,代碼行數:10,代碼來源:comicvinetalker.py

示例3: fetchIssuesByVolume

    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
開發者ID:goldsoundz,項目名稱:comictagger,代碼行數:51,代碼來源:comicvinetalker.py

示例4: fetchVolumeData

    def fetchVolumeData( self, series_id ):
        
        # before we search online, look in our cache, since we might already
        # have this info
        cvc = ComicVineCacher( )
        cached_volume_result = cvc.get_volume_info( series_id )
        
        if cached_volume_result is not None:
            return cached_volume_result

    
        volume_url = self.api_base_url + "/volume/" + CVTypeID.Volume + "-" + str(series_id) + "/?api_key=" + self.api_key + "&field_list=name,id,start_year,publisher,count_of_issues&format=json"

        cv_response = self.getCVContent(volume_url)

        volume_results = cv_response['results']
    
        cvc.add_volume_info( volume_results )

        return volume_results
開發者ID:2mny,項目名稱:mylar,代碼行數:20,代碼來源:comicvinetalker.py

示例5: cacheAlternateCoverURLs

 def cacheAlternateCoverURLs(self, issue_id, url_list):
     cvc = ComicVineCacher()
     cvc.add_alt_covers(issue_id, url_list)
開發者ID:DarkSir23,項目名稱:mylar,代碼行數:3,代碼來源:comicvinetalker.py

示例6: cacheIssueSelectDetails

 def cacheIssueSelectDetails(
         self, issue_id, image_url, thumb_url, cover_date, page_url):
     cvc = ComicVineCacher()
     cvc.add_issue_select_details(
         issue_id, image_url, thumb_url, cover_date, page_url)
開發者ID:DarkSir23,項目名稱:mylar,代碼行數:5,代碼來源:comicvinetalker.py

示例7: fetchCachedIssueSelectDetails

    def fetchCachedIssueSelectDetails(self, issue_id):

        # before we search online, look in our cache, since we might already
        # have this info
        cvc = ComicVineCacher()
        return cvc.get_issue_select_details(issue_id)
開發者ID:DarkSir23,項目名稱:mylar,代碼行數:6,代碼來源:comicvinetalker.py

示例8: searchForSeries

    def searchForSeries(self, series_name, callback=None, refresh_cache=False):

        # remove cruft from the search string
        series_name = utils.removearticles(series_name).lower().strip()

        # before we search online, look in our cache, since we might have
        # done this same search recently
        cvc = ComicVineCacher()
        if not refresh_cache:
            cached_search_results = cvc.get_search_results(series_name)

            if len(cached_search_results) > 0:
                return cached_search_results

        original_series_name = series_name

        # We need to make the series name into an "AND"ed query list
        query_word_list = series_name.split()
        and_list = ['AND'] * (len(query_word_list) - 1)
        and_list.append('')
        # zipper up the two lists
        query_list = zip(query_word_list, and_list)
        # flatten the list
        query_list = [item for sublist in query_list for item in sublist]
        # convert back to a string
        query_string = " ".join(query_list).strip()
        # print "Query string = ", query_string

        query_string = urllib.quote_plus(query_string.encode("utf-8"))

        search_url = self.api_base_url + "/search/?api_key=" + self.api_key + "&format=json&resources=volume&query=" + \
            query_string + \
            "&field_list=name,id,start_year,publisher,image,description,count_of_issues"
        cv_response = self.getCVContent(search_url + "&page=1")

        search_results = list()

        # see http://api.comicvine.com/documentation/#handling_responses

        limit = cv_response['limit']
        current_result_count = cv_response['number_of_page_results']
        total_result_count = cv_response['number_of_total_results']

        if callback is None:
            self.writeLog(
                "Found {0} of {1} results\n".format(
                    cv_response['number_of_page_results'],
                    cv_response['number_of_total_results']))
        search_results.extend(cv_response['results'])
        page = 1

        if callback is not None:
            callback(current_result_count, total_result_count)

        # see if we need to keep asking for more pages...
        while (current_result_count < total_result_count):
            if callback is None:
                self.writeLog(
                    "getting another page of results {0} of {1}...\n".format(
                        current_result_count,
                        total_result_count))
            page += 1

            cv_response = self.getCVContent(search_url + "&page=" + str(page))

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

            if callback is not None:
                callback(current_result_count, total_result_count)

        # for record in search_results:
            #print(u"{0}: {1} ({2})".format(record['id'], record['name'] , record['start_year']))
            # print(record)
            #record['count_of_issues'] = record['count_of_isssues']
        #print(u"{0}: {1} ({2})".format(search_results['results'][0]['id'], search_results['results'][0]['name'] , search_results['results'][0]['start_year']))

        # cache these search results
        cvc.add_search_results(original_series_name, search_results)

        return search_results
開發者ID:DarkSir23,項目名稱:mylar,代碼行數:81,代碼來源:comicvinetalker.py

示例9: searchForSeries

    def searchForSeries( self, series_name , callback=None, refresh_cache=False ):
        
        # remove cruft from the search string
        series_name = utils.removearticles( series_name ).lower().strip()
        
        # before we search online, look in our cache, since we might have
        # done this same search recently
        cvc = ComicVineCacher( )
        if not refresh_cache:
            cached_search_results = cvc.get_search_results( series_name )
            
            if len (cached_search_results) > 0:
                return cached_search_results
        
        original_series_name = series_name
    
        series_name = urllib.quote_plus(series_name.encode("utf-8"))
        #series_name = urllib.quote_plus(unicode(series_name))
        search_url = self.api_base_url + "/search/?api_key=" + self.api_key + "&format=json&resources=volume&query=" + series_name + "&field_list=name,id,start_year,publisher,image,description,count_of_issues"
        content = self.getUrlContent(search_url + "&page=1") 
    
        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

        search_results = list()
            
        # see http://api.comicvine.com/documentation/#handling_responses		

        limit = cv_response['limit']
        current_result_count = cv_response['number_of_page_results']
        total_result_count = cv_response['number_of_total_results']
        
        if callback is None:
            self.writeLog( "Found {0} of {1} results\n".format( cv_response['number_of_page_results'], cv_response['number_of_total_results']))
        search_results.extend( cv_response['results'])
        page = 1
        
        if callback is not None:
            callback( current_result_count, total_result_count )
            
        # see if we need to keep asking for more pages...
        while ( current_result_count < total_result_count ):
            if callback is None:
                self.writeLog("getting another page of results {0} of {1}...\n".format( current_result_count, total_result_count))
            page += 1

            content = self.getUrlContent(search_url + "&page="+str(page)) 
        
            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
            search_results.extend( cv_response['results'])
            current_result_count += cv_response['number_of_page_results']
            
            if callback is not None:
                callback( current_result_count, total_result_count )

    
        #for record in search_results: 
        #	#print( u"{0}: {1} ({2})".format(record['id'], record['name'] , record['start_year'] ) )
        #	#print record
        #	#record['count_of_issues'] = record['count_of_isssues']
        #print u"{0}: {1} ({2})".format(search_results['results'][0]['id'], search_results['results'][0]['name'] , search_results['results'][0]['start_year'] ) 
    
        # cache these search results
        cvc.add_search_results( original_series_name, search_results )

        return search_results
開發者ID:goldsoundz,項目名稱:comictagger,代碼行數:73,代碼來源:comicvinetalker.py


注:本文中的comicvinecacher.ComicVineCacher類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。