added path option to Comic and Comic Archive; added .egg-info to gitignore

This commit is contained in:
Bryan Bailey
2022-03-14 09:15:35 -04:00
parent 26174d00dc
commit 28b8a199f6
3 changed files with 31 additions and 23 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,4 @@
env
__pycache__
.coverage
.coverage
*.egg-info

View File

@@ -11,15 +11,9 @@ from yoink.comic import Comic
queue = []
@click.group(cls=DefaultGroup, default='init', default_if_no_args=True)
@click.option('-c', '--comic', help='Download a Comic file')
@click.option('-t', '--torrent', help='Download a Torrent')
def yoink(comic, torrent):
if comic:
click.echo('Downloading a comic')
if torrent:
click.echo('Downloading a torrent')
@click.group(cls=DefaultGroup, default='download', default_if_no_args=True)
def yoink():
pass
@@ -30,21 +24,34 @@ def init():
@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')
def download(url):
def download(url, comic, torrent, path):
# Account for whitespace/blank urls
if url.strip() == '':
click.echo('url cannot be blank')
return 1
# comic = Comic(url)
# click.echo(f'Downloading {comic.title}')
# comic.archiver.download()
# click.echo('Building comic archive')
# comic.archiver.generate_archive()
# click.echo('Cleaning up')
# comic.archiver.cleanup_worktree()
# click.echo('Success')
if comic:
try:
comic = Comic(url, path=path if path else None)
except ValueError:
click.echo(f'{url} is not supported or is not a valid URL')
return 1
click.echo(f'Downloading {comic.title}')
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__':

View File

@@ -10,9 +10,9 @@ import urllib
class Comic(Scrapable):
def __init__(self, url) -> None:
def __init__(self, url, path=None) -> None:
super().__init__(url)
self.archiver = ComicArchiver(self)
self.archiver = ComicArchiver(self, library=path)
def __get_image_src(self, comic):
@@ -54,9 +54,9 @@ class Comic(Scrapable):
class ComicArchiver:
def __init__(self, comic : Comic) -> None:
def __init__(self, comic : Comic, library=None) -> None:
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):