This repository has been archived on 2020-10-28. You can view files and clone it, but cannot push or open issues or pull requests.
yams/yams

33 lines
1.4 KiB
Python
Executable File

#!/usr/bin/python
import mangadex
import argparse
import os
argparser = argparse.ArgumentParser()
argparser.add_argument("url", help="the manga URL. Can be a mangadex chapter (/chapter/) or manga series (/title/) URL.")
argparser.add_argument("-l","--language","--lang", help="the language code to download chapters in. Only relevent to series URLs.", default=None)
argparser.add_argument("-c","--chapterrange", help="the range of chapters to download, in \"start,end\" format. Only relevent to manga series URLs.", default=None)
argparser.add_argument("-g","--group", help="the transation group to download chapters from. This is a group ID not a group name. Only relevent to manga series URLs.", default=None)
argparser.add_argument("-o","--output", help="output directory", default=None)
args = argparser.parse_args()
split_url = args.url.split("/")
if args.chapterrange != None:
csplit = [int(x) for x in args.chapterrange.split(',')]
crange = range(csplit[0],csplit[1]+1)
else:
crange = None
if args.output != None:
os.chdir(args.output)
for t in range(len(split_url)):
if split_url[t] == "chapter":
mangadex.save_chapter(split_url[t+1])
if split_url[t] == "title":
g = mangadex.get_chapters(split_url[t+1], args.language, args.group, crange)
for cid in g:
print("DOWNLOADING CHAPTER: " + cid)
mangadex.save_chapter(cid)