initial commit
This commit is contained in:
59
deezer_downloader/cli/deezer-downloader.ini.template
Normal file
59
deezer_downloader/cli/deezer-downloader.ini.template
Normal file
@@ -0,0 +1,59 @@
|
||||
;;; template configuration for deezer-downlaoder
|
||||
;;; you need to adjust: deezer.cookie_arl
|
||||
|
||||
[mpd]
|
||||
; if you set this to True, the backend will connect to mpd (localhost:6600) and update
|
||||
; the music database after a completed download
|
||||
use_mpd = False
|
||||
host = localhost
|
||||
port = 6600
|
||||
music_dir_root = /tmp/deezer-downloader
|
||||
|
||||
[download_dirs]
|
||||
base = /tmp/deezer-downloader
|
||||
|
||||
songs = %(base)s/songs
|
||||
albums = %(base)s/albums
|
||||
zips = %(base)s/zips
|
||||
playlists = %(base)s/playlists
|
||||
youtubedl = %(base)s/youtube-dl
|
||||
|
||||
[debug]
|
||||
; debug output used for /debug
|
||||
command = journalctl -u deezer-downloader -n 100 --output cat
|
||||
|
||||
[http]
|
||||
; web backend options
|
||||
host = 127.0.0.1
|
||||
port = 5000
|
||||
|
||||
; if used behind a proxy, specify base url prefix
|
||||
; url_prefix = /deezer
|
||||
url_prefix =
|
||||
api_root = %(url_prefix)s
|
||||
static_root = %(url_prefix)s/static
|
||||
|
||||
[proxy]
|
||||
; server:
|
||||
; - https://user:pass@host:port
|
||||
; - socks5://127.0.0.1:9050
|
||||
; - socks5h://127.0.0.1:9050 (DNS goes also over proxy)
|
||||
server =
|
||||
|
||||
[threadpool]
|
||||
; number of workers in thread pool, this specifies the maximum number of parallel downloads
|
||||
workers = 4
|
||||
|
||||
[deezer]
|
||||
; valid arl cookie value
|
||||
; login manually using your web browser and take the arl cookie
|
||||
cookie_arl = [a-f0-9]{192}
|
||||
; mp3 or flac - flac needs premium subscription
|
||||
quality = mp3
|
||||
|
||||
[youtubedl]
|
||||
; you are responsible for keeping yt-dlp up-to-date (https://github.com/yt-dlp/yt-dlp)
|
||||
; command = /home/kmille/projects/deezer-downloader/app/venv/bin/yt-dlp
|
||||
command = /usr/bin/yt-dlp
|
||||
|
||||
; vim: syntax=dosini
|
||||
56
deezer_downloader/cli/runner.py
Normal file
56
deezer_downloader/cli/runner.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import waitress
|
||||
|
||||
|
||||
def get_version():
|
||||
from importlib.metadata import version
|
||||
v = version("deezer_downloader")
|
||||
return f"v{v}"
|
||||
|
||||
|
||||
def run_backend():
|
||||
from deezer_downloader.configuration import config
|
||||
from deezer_downloader.web.app import app
|
||||
|
||||
print(f"Listening on {config['http']['host']}:{config['http'].getint('port')} (version {get_version()})")
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True,
|
||||
host=config['http']['host'],
|
||||
port=config['http'].getint('port'))
|
||||
else:
|
||||
listen = f"{config['http']['host']}:{config['http'].getint('port')}"
|
||||
waitress.serve(app, listen=listen)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(prog='deezer-downloader',
|
||||
description="Download music from Deezer and Spotify with a simple web frontend, through a local-hosted service written in Python.",
|
||||
epilog="More info at https://github.com/kmille/deezer-downloader.")
|
||||
parser.add_argument("-v", "--version", action='store_true', help="show version and exit")
|
||||
parser.add_argument("-t", "--show-config-template", action='store_true', help="show config template - you have to provide the ARL cookie at least")
|
||||
parser.add_argument("-c", "--config", help="config file - if not supplied, the following directories are considered looking for deezer-downloader.ini: current working directory, XDG_CONFIG_HOME environment variable, ~/.config, /etc)")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
if args.version:
|
||||
print(sys.argv[0], get_version())
|
||||
sys.exit(0)
|
||||
|
||||
if args.show_config_template:
|
||||
print((Path(__file__).parent / Path("deezer-downloader.ini.template")).read_text(), end="")
|
||||
sys.exit(0)
|
||||
|
||||
from deezer_downloader.configuration import load_config
|
||||
load_config(args.config)
|
||||
run_backend()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user