Skip to main content

Marvel API python wrapper.

Project description

Marvel API python wrapper.

Examples

This is a script which can be run at the beginning on the week to generate a complete Marvel pull list, excluding any series the user doesn’t want.

import os
import marvelous

# Your own config file to keep your private key local and secret
from config import public_key, private_key

# All the series IDs of comics I'm not interested in reading
# I pull these out of the resulting pulls.txt file, then rerun this script
IGNORE = set([
    19709, 20256, 19379, 19062, 19486, 19242, 19371, 19210, 20930, 21328,
    20834, 18826, 20933, 20365, 20928, 21129, 20786, 21402, 21018
])

# Authenticate with Marvel, with keys I got from http://developer.marvel.com/
m = marvelous.api(public_key, private_key)

# Get all comics from this week, sorted alphabetically by title
# Uses the same API parameters as listed in the official API documentation
pulls = sorted(m.comics({
    'format': "comic",
    'formatType': "comic",
    'noVariants': True,
    'dateDescriptor': "thisWeek"}),
    key=lambda comic: comic.title)

# Grab the sale date of any of the comics for the folder name
directory = pulls[0].dates.on_sale.strftime('%m-%d')

# If there's no folder by that name, create one
if not os.path.exists(directory):
    os.makedirs(directory)

# Create a pulls.txt file in that folder
with open(directory + '/pulls.txt', 'w') as pull_checklist:
    # Check each comic that came out this week
    for comic in pulls:
        # If this series isn't in my ignore list
        if comic.series.id not in IGNORE:
            # Write a line to the file with the name of the issue, and the
            # id of the series incase I want to add it to my ignore list
            pull_checklist.write('{} (series #{})\n'.format(
                comic.title.encode('utf-8'), comic.series.id))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marvelous-0.0.2.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file marvelous-0.0.2.tar.gz.

File metadata

  • Download URL: marvelous-0.0.2.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for marvelous-0.0.2.tar.gz
Algorithm Hash digest
SHA256 289a49305879da5dd24ed86b3495357a21ab7e68f9142a40647dce8d73e394b1
MD5 ebb5531c7cc4f3b27cb11bac1f4fb270
BLAKE2b-256 068bf4f6a47e61c9f5ae98c7edfab5713c91f5a0498412794354d93e9992ff4d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page