added path option to Comic and Comic Archive; added .egg-info to gitignore
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
env
|
env
|
||||||
__pycache__
|
__pycache__
|
||||||
.coverage
|
.coverage
|
||||||
|
*.egg-info
|
||||||
43
yoink/cli.py
43
yoink/cli.py
@@ -11,15 +11,9 @@ from yoink.comic import Comic
|
|||||||
|
|
||||||
queue = []
|
queue = []
|
||||||
|
|
||||||
@click.group(cls=DefaultGroup, default='init', default_if_no_args=True)
|
@click.group(cls=DefaultGroup, default='download', default_if_no_args=True)
|
||||||
@click.option('-c', '--comic', help='Download a Comic file')
|
def yoink():
|
||||||
@click.option('-t', '--torrent', help='Download a Torrent')
|
pass
|
||||||
def yoink(comic, torrent):
|
|
||||||
if comic:
|
|
||||||
click.echo('Downloading a comic')
|
|
||||||
|
|
||||||
if torrent:
|
|
||||||
click.echo('Downloading a torrent')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -30,21 +24,34 @@ def init():
|
|||||||
|
|
||||||
|
|
||||||
@yoink.command()
|
@yoink.command()
|
||||||
|
@click.option('-c', '--comic', is_flag=True, help='Download a Comic file')
|
||||||
|
@click.option('-t', '--torrent', is_flag=True, help='Download a Torrent')
|
||||||
|
@click.option('-p', '--path', help='Change the download path')
|
||||||
@click.argument('url')
|
@click.argument('url')
|
||||||
def download(url):
|
def download(url, comic, torrent, path):
|
||||||
# Account for whitespace/blank urls
|
# Account for whitespace/blank urls
|
||||||
if url.strip() == '':
|
if url.strip() == '':
|
||||||
click.echo('url cannot be blank')
|
click.echo('url cannot be blank')
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# comic = Comic(url)
|
if comic:
|
||||||
# click.echo(f'Downloading {comic.title}')
|
try:
|
||||||
# comic.archiver.download()
|
comic = Comic(url, path=path if path else None)
|
||||||
# click.echo('Building comic archive')
|
except ValueError:
|
||||||
# comic.archiver.generate_archive()
|
click.echo(f'{url} is not supported or is not a valid URL')
|
||||||
# click.echo('Cleaning up')
|
return 1
|
||||||
# comic.archiver.cleanup_worktree()
|
click.echo(f'Downloading {comic.title}')
|
||||||
# click.echo('Success')
|
comic.archiver.download()
|
||||||
|
click.echo('Building comic archive')
|
||||||
|
comic.archiver.generate_archive()
|
||||||
|
click.echo('Cleaning up')
|
||||||
|
comic.archiver.cleanup_worktree()
|
||||||
|
click.echo('Success')
|
||||||
|
|
||||||
|
if torrent:
|
||||||
|
click.echo('Downloading a torrent')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import urllib
|
|||||||
|
|
||||||
|
|
||||||
class Comic(Scrapable):
|
class Comic(Scrapable):
|
||||||
def __init__(self, url) -> None:
|
def __init__(self, url, path=None) -> None:
|
||||||
super().__init__(url)
|
super().__init__(url)
|
||||||
self.archiver = ComicArchiver(self)
|
self.archiver = ComicArchiver(self, library=path)
|
||||||
|
|
||||||
|
|
||||||
def __get_image_src(self, comic):
|
def __get_image_src(self, comic):
|
||||||
@@ -54,9 +54,9 @@ class Comic(Scrapable):
|
|||||||
|
|
||||||
|
|
||||||
class ComicArchiver:
|
class ComicArchiver:
|
||||||
def __init__(self, comic : Comic) -> None:
|
def __init__(self, comic : Comic, library=None) -> None:
|
||||||
self.comic = comic
|
self.comic = comic
|
||||||
self.worktree = os.path.join(library_path, f'comics/{self.comic.title}')
|
self.worktree = library if library else os.path.join(library_path, f'comics/{self.comic.title}')
|
||||||
|
|
||||||
def download(self):
|
def download(self):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user