예제 #1
0
def _query_series_ids_dom(API_KEY, searchterm_s, page_n=1):
    ''' 
   Performs a query that will obtain a dom containing all the comic book series
   from ComicVine that match a given search string.  You can also provide a 
   second argument that specifies the page of the results (each page contains
   100 results) to display. This is useful, because this query will not 
   necessarily return all available results.
   
   This method doesn't return null, but it may throw Exceptions.
   '''

    # {0} is the search string, {1} is the page number of the results we want
    QUERY = 'http://comicvine.com/api/search/?api_key=' + API_KEY + \
       __CLIENTID + '&format=xml&limit=100&resources=volume' + \
       '&field_list=name,start_year,publisher,id,image,count_of_issues' + \
       '&query={0}'
    # leave "page=1" off of query to fix a bug, e.g. search for 'bprd vampire'
    PAGE = "" if page_n == 1 else "&page={0}".format(page_n)

    if searchterm_s is None or searchterm_s == '' or page_n < 0:
        raise ValueError('bad parameters')
    searchterm_s = " AND ".join(re.split(r'\s+', searchterm_s))
    # issue 349
    return __get_dom(
        QUERY.format(HttpUtility.UrlPathEncode(searchterm_s)) + PAGE)
예제 #2
0
def _query_issue_id_dom(API_KEY, seriesid_s, issue_num_s):
    '''
   Performs a query that will obtain a dom containing the issue ID for the 
   given issue number in the given series id.  
   
   This method doesn't return null, but it may throw Exceptions.
   '''

    # {0} is the series ID, an integer, and {1} is issue number, a string
    QUERY = 'http://comicvine.com/api/issues/?api_key=' + API_KEY + \
       __CLIENTID + '&format=xml&field_list=name,issue_number,id,image' + \
       '&filter=volume:{0},issue_number:{1}'

    if not seriesid_s or not issue_num_s:
        raise ValueError('bad parameters')
    return __get_dom(
        QUERY.format(sstr(seriesid_s),
                     HttpUtility.UrlPathEncode(sstr(issue_num_s))))
예제 #3
0
def _query_issue_id_dom(API_KEY, seriesid_s, issue_num_s):
    '''
   Performs a query that will obtain a dom containing the issue ID for the 
   given issue number in the given series id.  
   
   This method doesn't return null, but it may throw Exceptions.
   '''

    # {0} is the series ID, an integer, and {1} is issue number, a string
    QUERY = 'http://comicvine.gamespot.com/api/issues/?api_key=' + API_KEY + \
       __CLIENTID + '&format=xml&field_list=name,issue_number,id,image' + \
       '&filter=volume:{0},issue_number:{1}'

    # cv does not play well with leading zeros in issue nums. see issue #403.
    issue_num_s = sstr(issue_num_s).strip()
    if len(issue_num_s) > 0:  # fix issue 411
        issue_num_s = issue_num_s.lstrip('0').strip()
        issue_num_s = issue_num_s if len(issue_num_s) > 0 else '0'

    if not seriesid_s or not issue_num_s:
        raise ValueError('bad parameters')
    return __get_dom(
        QUERY.format(sstr(seriesid_s),
                     HttpUtility.UrlPathEncode(sstr(issue_num_s))))