Skip to content

comicbox.readinglists.formats.comicvine_api

Reading lists built from Comic Vine story arcs.

A builder from simyan objects, read by attribute, so this module imports no network library. Comic Vine is a source, not a format: nothing is written back.

reading_list_from_comicvine_arc(arc, issues=(), volumes=())

Build an unordered story list from a Comic Vine arc.

The arc names its issues by id alone. issues and volumes are the rows for those issues and their volumes, which give each entry its series, start year, number and dates. Every member of the arc gets an entry, in the arc’s order, whether a row came for it or not. Comic Vine states no reading order for an arc, so the list is unordered.

The revision is the arc’s date_last_updated as Comic Vine gives it, with no time zone: Comic Vine states none, and a revision is only ever compared with another from the same source.

Source code in comicbox/readinglists/formats/comicvine_api.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
def reading_list_from_comicvine_arc(
    arc: StoryArc,
    issues: Iterable[BasicIssue] = (),
    volumes: Iterable[BasicVolume] = (),
) -> ReadingListResult:
    """
    Build an unordered story list from a Comic Vine arc.

    The arc names its issues by id alone. ``issues`` and ``volumes`` are
    the rows for those issues and their volumes, which give each entry its
    series, start year, number and dates. Every member of the arc gets an
    entry, in the arc's order, whether a row came for it or not. Comic Vine
    states no reading order for an arc, so the list is unordered.

    The revision is the arc's ``date_last_updated`` as Comic Vine gives it,
    with no time zone: Comic Vine states none, and a revision is only ever
    compared with another from the same source.
    """
    rows = {issue.id: issue for issue in issues}
    volume_rows = {volume.id: volume for volume in volumes}
    source = {
        SOURCE_KIND_KEY: SourceKind.COMICVINE_ARC.value,
        SOURCE_KEY_KEY: str(arc.id),
        SOURCE_URL_KEY: str(arc.site_url),
        SOURCE_REVISION_KEY: arc.date_last_updated.isoformat(),
    }
    entries = [
        _entry(member.id, rows.get(member.id), volume_rows) for member in arc.issues
    ]
    raw = {
        NAME_KEY: arc.name,
        # The deck is Comic Vine's one-line summary, for an arc with no
        # long description.
        DESCRIPTION_KEY: strip_html(arc.description) or arc.summary,
        LIST_TYPE_KEY: STORY_LIST_TYPE,
        ORDERED_KEY: False,
        SOURCES_KEY: [source],
        ENTRIES_KEY: entries,
    }
    reading_list, warnings = load_model_with_warnings(_without_empty(raw))
    return ReadingListResult(reading_list, None, warnings)