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.4.tar.gz (4.7 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for marvelous-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b7879f18343e3f8babd26f9a3d5c7e3bc47c3e943c462647bedf848f863b2d1d
MD5 c0cd90a44d0b66939f0a996ed52c8fe5
BLAKE2b-256 2ed9dc85901a044175b5e33115cb4f12ca9a81896d1af15c3c7830f930d6f167

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