diff options
author | neodarz <neodarz@neodarz.net> | 2020-08-15 14:07:15 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2020-08-15 14:07:15 +0200 |
commit | c4fb7fda5b1b6bb22db1f517f71cf393f68c6a9b (patch) | |
tree | 746b1c9e7d5b2f49e338706fec9f9c0d74f9f7c3 /main.py | |
download | music_downloader-c4fb7fda5b1b6bb22db1f517f71cf393f68c6a9b.tar.xz music_downloader-c4fb7fda5b1b6bb22db1f517f71cf393f68c6a9b.zip |
Initial commit
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 55 |
1 files changed, 55 insertions, 0 deletions
@@ -0,0 +1,55 @@ +#!/bin/python + +import os +import argparse +from pathlib import Path +from extractors.job import DlJob +from utils import read_file + +module_path = os.path.abspath(__file__) +ROOT = Path(module_path).parent + +parser = argparse.ArgumentParser(description="Custom album downloader tool") +parser.add_argument('--url', help="link to the file to download") +parser.add_argument( + '--update', help='update all albums from cache', action="store_true") +parser.add_argument('--file', help="read url from file") +parser.add_argument( + '--output', + help="folder where to put downloaded albums. " + "Default to: " + str(ROOT) + "/out/", + default=str(ROOT) + "/out/") + +args = parser.parse_args() + +if not args.output.endswith("/"): + args.output = args.output + "/" + +if args.update: + print('Updating from cache...') + + + cache_file = Path(ROOT, '.urls_cache.txt') + + urls_cache = read_file(cache_file) + + for url in urls_cache: + dl_job = DlJob(url, args.output) + dl_job.run() + +if args.url: + print('Downloading from url...') + dl_job = DlJob(args.url, args.output) + dl_job.run() + +if args.file: + print("Downloading from file...") + + urls = read_file(args.file) + + for url in urls: + dl_job = DlJob(url, args.output) + dl_job.run() + +if not args.url and not args.update and not args.file: + parser.print_help() |