springheel_jacky package — springheel_jacky 1.0.0 documentation

Skip to main content

# springheel_jacky package

## Submodules

## springheel_jacky.categories module

Show data on categories.

springheel_jacky.categories.getCatInfo(j: dict, cat_name: str) → Union[dict, bool]

  Get information on one category.

  Parameters
    jdict

      The site JSON contents.

    cat_namestr

      The name of the category.

  Returns
    dict or False

      A dictionary full of information about the category, or False if no such category exists.

## springheel_jacky.chapters module

Show data on chapters.

springheel_jacky.chapters.getChapters(j: dict) → Union[dict, bool]

  Try to get chapter info for all comics.

  Parameters
    jdict

      The site JSON contents.

  Returns
    dict or False

      If existent, a dictionary mapping category names to lists of chapter number: title dictionaries.

## springheel_jacky.cli module

Operate through the command line.

springheel_jacky.cli.all_images_cmd(j: dict, commands: argparse.Namespace) → None

  List URLs of all comic image files.

  Parameters
    jdict

      Site JSON contents.

    commandsargparse.Namespace

      Command input.

springheel_jacky.cli.all_links_cmd(j: dict, commands: argparse.Namespace) → None

  List permalinks to all comic pages.

  Parameters
    jdict

      Site JSON contents.

    commandsargparse.Namespace

      Command input.

springheel_jacky.cli.cat_cmd(j: dict, commands: argparse.Namespace) → None

  Display info on a single category.

  Parameters
    jdict

      Site JSON contents.

    commandsargparse.Namespace

      Command input. A string for commands.category is expected. An optional bool for commands.no_strips removes the `strips` key from output.

springheel_jacky.cli.cat_images_cmd(j: dict, commands: argparse.Namespace) → None

  List URLs of comic image files in one category.

  Parameters
    jdict

      Site JSON contents.

    commandsargparse.Namespace

      Command input. A string for command.category is expected.

springheel_jacky.cli.cat_links_cmd(j: dict, commands: argparse.Namespace) → None

  List permalinks to comic pages in one category.

  Parameters
    jdict

      Site JSON contents.

    commandsargparse.Namespace

      Command input. A string for command.category is expected.

springheel_jacky.cli.chap_images_cmd(j: dict, commands: argparse.Namespace) → None

  List URLs of all comic image files in one chapter.

  Parameters
    jdict

      Site JSON contents.

    commandsargparse.Namespace

      Command input. Strings for commands.category and commands.chapter are expected.

springheel_jacky.cli.chap_links_cmd(j: dict, commands: argparse.Namespace) → None

  List permalinks to comic pages in one chapter.

  Parameters
    jdict

      Site JSON contents.

    commandsargparse.Namespace

      Command input. Strings for commands.category and commands.chapter are expected.

springheel_jacky.cli.chapter_print(cd: dict) → None

  Pretty-print a chapter info dictionary.

  Parameters
    cddict

      A chapter info dictionary.

springheel_jacky.cli.chapters_cmd(j: dict, commands: argparse.Namespace) → None

  List chapter information, if available.

  Parameters
    jdict

      Site JSON contents.

    commandsargparse.Namespace

      Command input.

springheel_jacky.cli.getCommands() → argparse.Namespace

  Extract commands from the command line.

  Returns
    argparse.Namespace

      Command input.

springheel_jacky.cli.pretty_list(l: list) → None

  Pretty-print a list.

springheel_jacky.cli.save_cmd(j: dict, commands: argparse.Namespace) → None

  Save a site.json file locally.

  Parameters
    jdict

      Site JSON contents.

    commandsargparse.Namespace

      Command input. An optional filename in commands.filename is usable but not required.

springheel_jacky.cli.search_cmd(j: dict, commands: argparse.Namespace) → None

  Search comic transcripts for a case-insensitive word or phrase.

  Parameters
    jdict

      Site JSON contents.

    commandsargparse.Namespace

      Command input. A string for either commands.query or commands.tag is expected.

springheel_jacky.cli.strip_cmd(j: dict, commands: argparse.Namespace) → None

  Display info on a single strip.

  Parameters
    jdict

      Site JSON contents.

    commandsargparse.Namespace

      Command input. Strings for commands.category and commands.page are expected.

## springheel_jacky.cbz module

Create CBZ archives from downloaded comics.

springheel_jacky.cbz.constructMeta(j: dict, commands: argparse.Namespace, imageurls: list) → dict

  Construct a metadata dictionary to use as a zip comment.

  Parameters
    jdict

      Site JSON contents.

    commandsargparse.Namespace

      Command input. Optional strings include commands.category (to limit results to one category) and commands.chapter (to limit results to one chapter; does nothing without a category).

    imageurlslist of str

      The list of image URLS related to this download. Used to estimate page count.

  Returns
    dict

      A dictionary with information about the downloaded comic.

springheel_jacky.cbz.createCbzs(j: dict, commands: argparse.Namespace) → None

  Download strips from a site and save them as a CBZ archive.

  Parameters
    jdict

      Site JSON contents.

    commandsargparse.Namespace

      Command input. Optional strings include commands.category (to limit results to one category), commands.chapter (to limit results to one chapter; does nothing without a category), and commands.filename (specifies an output filename).

springheel_jacky.cbz.createCometMeta(meta: dict, out_dir: str) → str

  Create a CoMet-formatted comic metadata file.

  Parameters
    metadict

      The metadata to use.

    out_dirstr

      The directory where the XML file should go.

  Returns
    str

      String containing XML data, for testing purposes.

springheel_jacky.cbz.createComicInfo(meta: dict, out_dir: str) → str

  Create a ComicInfo.xml file.

  Parameters
    metadict

      The metadata to use.

    out_dirstr

      The directory where the XML file should go.

  Returns
    str

      String containing XML data, for testing purposes.

springheel_jacky.cbz.getFilename(metadata: dict, u_fn: Optional[str]) → str

  Safely construct a filename for output.

  Parameters
    metadatadict

      A dictionary providing information about the comic. Should at minimum contain the key “outname” with a string value.

    u_fnstr or None

      A user-specified filename, if available.

springheel_jacky.cbz.writeCbz(out_fn: str, imagefiles: list, zip_comment: str) → None

  Write a CBZ archive.

  Parameters
    out_fnstr

      The output filename.

    imagefileslist of str

      A list of image file paths to add to the zip file.

    zip_commentstr

      A string to use as the zip comment.

springheel_jacky.cbz.zipcomment(meta: dict) → str

  Create a zip comment from metadata.

  Parameters
    metadict

      A metadata dictionary constructed by `constructMeta()`.

  Returns
    str

      The zip comment, formatted like ComicTagger.

## springheel_jacky.images module

Get info on image files.

springheel_jacky.images.getAllStrips(j: dict) → list

  Get strip images for all comics on the site.

  Parameters
    jdict

      The site JSON contents.

  Returns
    list of list

      A list of lists – one for each category – of comic strip image URLs on the site.

springheel_jacky.images.getCatStrips(j: dict, cat_name: str) → Union[list, bool]

  Get URLs for one category on the site.

  Parameters
    jdict

      The site JSON contents.

    cat_namestr
  Returns
    list of str

      A list of all comic page URLs in the category, or False if no such category exists.

springheel_jacky.images.getChapStrips(j: dict, cat_name: str, chap_num: int) → Union[list, bool]

  Get URLs for one chapter.

  Parameters
    jdict

      The site JSON contents.

    cat_namestr

      The name of the category to search.

    chap_numint

      The chapter number to retrieve pages from.

  Returns
    list of str

      A list of all comic page URLs in the chapter, or False if no such chapter exists.

springheel_jacky.images.makeFilename(base_url, img)

## springheel_jacky.internet module

Request resources from the Internet.

springheel_jacky.internet.dlImgs(imagelist: list, out_dir: str) → list

  Download images from a list to the specified directory.

  Parameters
    imagelistlist of str

      A list of image URLs.

    out_dirstr

      The output directory to use. Created if it doesn’t already exist.

  Returns
    list

      A list of status codes from the download process (for debug purposes).

springheel_jacky.internet.getSite(url: str) → Union[str, bool]

  Get the site URL to parse and clean it up a bit.

  Parameters
    urlstr

      The first argument passed to the command line.

  Returns
    str or False

      The URL, if it very loosely appears to be a URL. False otherwise.

springheel_jacky.internet.retrieveJson(url: str) → dict

  Retrieve the JSON endpoints file from a site.

  Parameters
    urlstr

      The site URL.

  Returns
    dict

      JSON endpoint data for the site.

springheel_jacky.internet.saveImg(img: str, out_fn: str, codes: list) → list

  Save an image locally.

  Parameters
    imgstr

      The URL of an image to download.

    out_fnstr

      The output file to save to.

    codeslist

      A list to use for recording status codes.

  Returns
    list

      A list of HTTP status codes.

## springheel_jacky.links module

Get info on URLs.

springheel_jacky.links.getAllPermalinks(j: dict) → list

  Get URLs for all comics on the site.

  Parameters
    jdict

      The site JSON contents.

  Returns
    list of list

      A list of lists – one for each category – of comic page URLs on the site.

springheel_jacky.links.getCatPermalinks(j: dict, cat_name: str) → list

  Get URLs for one category on the site.

  Parameters
    jdict

      The site JSON contents.

    cat_namestr

      The name of the category to search.

  Returns
    list of str

      A list of all comic page URLs in the category.

springheel_jacky.links.getChapPermalinks(j: dict, cat_name: str, chap_num: int) → list

  Get URLs for one chapter.

  Parameters
    jdict

      The site JSON contents.

    cat_namestr

      The name of the category to search.

    chap_numint

      The chapter number to retrieve pages from.

  Returns
    list of str

      A list of all comic page URLs in the chapter.

## springheel_jacky.search module

Search comics for dialogue for tags.

springheel_jacky.search.formatResults(results_comics: list, key: str, searchstring: str) → list

  Process search results for display in the console.

  Parameters
    results_comicslist of dict

      A list of dictionaries representing comic strips, returned by one of the search functions.

    keystr

      The type to format the results for. Either “dialogue” or “tags”.

    searchstringstr

      The original search string.

  Returns
    list

      A list of formatted search results.

springheel_jacky.search.searchDialogue(j: dict, searchstring: str) → list

  Search comic transcripts.

  Parameters
    jdict

      The site JSON contents.

    searchstringstr

      The string to search for.

  Returns
    list

      If not empty, a list of dictionaries for any strips that contain matches for the search string.

springheel_jacky.search.searchTags(j: dict, tag: str) → list

  Search comic tags.

  Parameters
    jdict

      The site JSON contents.

    tagstr

      The string to search for.

  Returns
    list of dict

      If not empty, a list of dictionaries with any strips that are tagged with the queried tag.

## springheel_jacky.strips module

Get info on individual strips.

springheel_jacky.strips.getStripInfo(j: dict, cat_name: str, page_num: str) → Union[dict, bool]

  Get information on one strip.

  Parameters
    jdict

      The site JSON contents.

    cat_namestr

      The name of the strip’s category.

    page_numstr

      The page number. Leading zeroes are stripped.

  Returns
    dict or False

      A dictionary full of information about the strip, or False if no such strip exists.

## Module contents

Get and view resources from Springheel sites.