diff options
| author | Cody Logan <cody@lokken.dev> | 2023-10-20 16:23:28 -0700 |
|---|---|---|
| committer | Cody Logan <cody@lokken.dev> | 2023-10-20 16:23:28 -0700 |
| commit | 05457af0d73ff3a820c0b465e6607fc5832a6e74 (patch) | |
| tree | cc1a6e13d2a651c4048c5092c4f7891bb982c676 /src/wikiget/dl.py | |
| parent | 59b97c7bef21cf68935b68fa7de6fd67653e21af (diff) | |
| download | wikiget-05457af0d73ff3a820c0b465e6607fc5832a6e74.tar.gz wikiget-05457af0d73ff3a820c0b465e6607fc5832a6e74.zip | |
Reorganize File class
Diffstat (limited to 'src/wikiget/dl.py')
| -rw-r--r-- | src/wikiget/dl.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/wikiget/dl.py b/src/wikiget/dl.py index 4521b72..171b017 100644 --- a/src/wikiget/dl.py +++ b/src/wikiget/dl.py @@ -30,10 +30,8 @@ from wikiget.validations import verify_hash def query_api(filename, site_name, args): - logging.debug(f"User agent: {wikiget.USER_AGENT}") - # connect to site and identify ourselves - logging.info(f"Site name: {site_name}") + logging.info(f"Connecting to {site_name}") try: site = Site(site_name, path=args.path, clients_useragent=wikiget.USER_AGENT) if args.username and args.password: @@ -60,7 +58,7 @@ def query_api(filename, site_name, args): # get info about the target file try: - file = site.images[filename] + image = site.images[filename] except APIError as e: # an API error at this point likely means access is denied, which could happen # with a private wiki @@ -71,23 +69,22 @@ def query_api(filename, site_name, args): logging.debug(i) raise - return file, site + return image def prep_download(dl, args): - filename, dest, site_name = get_dest(dl, args) - file = File(filename, dest) - file.object, file.site = query_api(file.name, site_name, args) + file = get_dest(dl, args) + file.image = query_api(file.name, file.site, args) return file def download(f, args): - file = f.object + file = f.image filename = f.name - site = f.site dest = f.dest + site = file.site - if file.imageinfo != {}: + if file.exists: # file exists either locally or at a common repository, like Wikimedia Commons file_url = file.imageinfo["url"] file_size = file.imageinfo["size"] |
