Exemple #1
0
def __issue_parse_series_details(issue, dom):
    ''' Parses the current comic's series details out of the DOM '''

    series_id = dom.results.volume.id

    # if the start year and publisher_s have been cached (because we already
    # accessed them once this session) use the cached values.  else
    # grab those values from comicvine, and cache em so we don't have to
    # hit comic vine for them again (at least not in this session)
    global __series_details_cache
    if __series_details_cache == None:
        raise Exception(__name__ + " module isn't initialized!")
    cache = __series_details_cache
    if series_id in cache:
        volume_year_n = cache[series_id][0]
        publisher_s = cache[series_id][1]
    else:
        # contact comicvine to extract details for this comic book
        series_dom = cvconnection._query_series_details_dom(
            __api_key, series_id)
        if series_dom is None:
            raise Exception("can't get details about series " + series_id)

        # start year
        volume_year_n = -1
        if "start_year" in series_dom.results.__dict__ and \
              is_string(series_dom.results.start_year):
            try:
                volume_year_n = int(series_dom.results.start_year)
            except:
                pass  # bad start year format...just keep going

        # publisher
        publisher_s = ''
        if "publisher" in series_dom.results.__dict__ and \
           "name" in series_dom.results.publisher.__dict__ and \
           is_string(series_dom.results.publisher.name):
            publisher_s = series_dom.results.publisher.name

        cache[series_id] = (volume_year_n, publisher_s)

    # check if there's the current publisher really is the true publisher, or
    # if it's really an imprint of another publisher.
    issue.publisher_s = cvimprints.find_parent_publisher(publisher_s)
    if issue.publisher_s != publisher_s:
        issue.imprint_s = publisher_s
    issue.volume_year_n = volume_year_n
def __issue_parse_series_details(issue, dom):
    """ Parses the current comic's series details out of the DOM """

    series_id = dom.results.volume.id

    # if the start year and publisher_s have been cached (because we already
    # accessed them once this session) use the cached values.  else
    # grab those values from comicvine, and cache em so we don't have to
    # hit comic vine for them again (at least not in this session)
    global __series_details_cache
    if __series_details_cache == None:
        raise Exception(__name__ + " module isn't initialized!")
    cache = __series_details_cache
    if series_id in cache:
        volume_year_n = cache[series_id][0]
        publisher_s = cache[series_id][1]
    else:
        # contact comicvine to extract details for this comic book
        series_dom = cvconnection._query_series_details_dom(__api_key, series_id)
        if series_dom is None:
            raise Exception("can't get details about series " + series_id)

        # start year
        volume_year_n = -1
        if "start_year" in series_dom.results.__dict__ and is_string(series_dom.results.start_year):
            try:
                volume_year_n = int(series_dom.results.start_year)
            except:
                pass  # bad start year format...just keep going

        # publisher
        publisher_s = ""
        if (
            "publisher" in series_dom.results.__dict__
            and "name" in series_dom.results.publisher.__dict__
            and is_string(series_dom.results.publisher.name)
        ):
            publisher_s = series_dom.results.publisher.name

        cache[series_id] = (volume_year_n, publisher_s)

    # check if there's the current publisher really is the true publisher, or
    # if it's really an imprint of another publisher.
    issue.publisher_s = cvimprints.find_parent_publisher(publisher_s)
    if issue.publisher_s != publisher_s:
        issue.imprint_s = publisher_s
    issue.volume_year_n = volume_year_n