diff options
author | neodarz <neodarz@neodarz.net> | 2020-08-15 17:08:58 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2020-08-15 17:08:58 +0200 |
commit | e2099a3e5c8f38c8bae88d862950b0c2bf5b1d13 (patch) | |
tree | 8bec0b584c05b4343ac6f1ea78682747402eb207 /main.py | |
parent | e6097b7d5b6122eeecea6a358a8e74cff5a17bbb (diff) | |
download | music_downloader-e2099a3e5c8f38c8bae88d862950b0c2bf5b1d13.tar.xz music_downloader-e2099a3e5c8f38c8bae88d862950b0c2bf5b1d13.zip |
Add option to specifie extractor
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 29 |
1 files changed, 23 insertions, 6 deletions
@@ -2,10 +2,13 @@ import os import argparse +import logging from pathlib import Path from extractors.job import DlJob from utils import read_file +from utils import NoExtractorException + module_path = os.path.abspath(__file__) ROOT = Path(module_path).parent @@ -19,6 +22,7 @@ parser.add_argument( help="folder where to put downloaded albums. " "Default to: " + str(ROOT) + "/out/", default=str(ROOT) + "/out/") +parser.add_argument('--extractor', help="name of the extractor") args = parser.parse_args() @@ -34,13 +38,23 @@ if args.update: urls_cache = read_file(cache_file) for url in urls_cache: - dl_job = DlJob(url, args.output) - dl_job.run() + try: + args.extractor = url.split(',')[1] + except IndexError: + pass + try: + dl_job = DlJob(url, args.output, args.extractor) + dl_job.run() + except NoExtractorException as exc: + logging.error(exc) if args.url: print('Downloading from url...') - dl_job = DlJob(args.url, args.output) - dl_job.run() + try: + dl_job = DlJob(args.url, args.output, args.extractor) + dl_job.run() + except NoExtractorException as exc: + logging.error(exc) if args.file: print("Downloading from file...") @@ -49,8 +63,11 @@ if args.file: for url in urls: if url: - dl_job = DlJob(url, args.output) - dl_job.run() + try: + dl_job = DlJob(url, args.output, args.extractor) + dl_job.run() + except NoExtractorException as exc: + logging.error(exc) if not args.url and not args.update and not args.file: parser.print_help() |