Skip to content

Commit

Permalink
Add alias:chapter option to get.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamuko committed Oct 2, 2015
1 parent e55c2b4 commit 0fa81f0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ follow Follow a series.
--download Downloads the chapters for the added follows.
--ignore Ignores the chapters for the added follows.
follows List all follows.
get Download chapters by URL.
get Download chapters by URL or by alias:chapter.
ignore Ignore chapters for a series.
new List all new chapters.
open Open the series URL in a browser.
Expand Down
36 changes: 26 additions & 10 deletions cum/cum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

@click.group()
def cli():
global db, output, series_by_url
global db, chapter_by_url, output, series_by_url
from cum import db, output
from cum.scrapers import series_by_url
from cum.scrapers import chapter_by_url, series_by_url


@cli.command()
Expand Down Expand Up @@ -102,14 +102,30 @@ def follows():


@cli.command()
@click.argument('urls', required=True, nargs=-1)
def get(urls):
"""Download chapters by URL.
The command will not add the downloaded chapters into the cum database."""
for url in urls:
chapter = chapter_by_url(url)
chapter.get(use_db=False)
@click.argument('input', required=True, nargs=-1)
def get(input):
"""Download chapters by URL or by alias:chapter.
The command accepts input as either the chapter of the URL or the
alias:chapter combination (e.g. 'bakuon:11'), if the chapter is already
found in the database through a follow. The command will not enter the
downloads in the database in case of URLs and ignores downloaded status
in case of alias:chapter, so it can be used to download one-shots that
don't require follows or for redownloading already downloaded chapters.
"""
for i in input:
chapter = chapter_by_url(i)
if not chapter:
a, c = i.split(':')
chapters = (db.session.query(db.Chapter)
.join(db.Series)
.filter(db.Series.alias == a,
db.Chapter.chapter == c)
.all())
for chapter in chapters:
chapter.to_object().get(use_db=False)
else:
chapter.get(use_db=False)


@cli.command()
Expand Down

0 comments on commit 0fa81f0

Please sign in to comment.