From b490164429e45acfdc321b1cd7894c1d0cf36ad5 Mon Sep 17 00:00:00 2001 From: Leonetienne Date: Sat, 26 Feb 2022 14:24:22 +0100 Subject: [PATCH] Switched to more elaborate python scripts and yaml lists. Specific directory names for can now be specified for downloads. --- .gitignore | 4 ++-- download-music.py | 31 +++++++++++++++++++++++++++++++ download-videos.py | 29 +++++++++++++++++++++++++++++ download.sh | 4 ++-- sync-to-nas.bat | 3 +++ 5 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 download-music.py create mode 100644 download-videos.py create mode 100644 sync-to-nas.bat diff --git a/.gitignore b/.gitignore index e0cd07c..44b7275 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /music/ /videos/ -/linklist-*.txt +/linklist-* /alreadydownloaded*.txt -/once.yaml \ No newline at end of file +/once.yaml diff --git a/download-music.py b/download-music.py new file mode 100644 index 0000000..ca6857f --- /dev/null +++ b/download-music.py @@ -0,0 +1,31 @@ +import yaml +import os + +with open("linklist-music.yaml", "r") as yamlfile: + try: + config = yaml.safe_load(yamlfile) + + for entry in config: + print(f"\033[92mGrabbing '{entry['url']}':") + + folderName = entry["folder-name"] if "folder-name" in entry else "/\%(uploader)s" + + os.system(f""" + yt-dlp + -c + --extract-audio + --audio-format mp3 + --merge-output-format mkv + -o 'music/{folderName}/%(title)s.%(ext)s' + --extractor-args youtube:player_client=android + --throttled-rate 100M + --restrict-filenames + --download-archive alreadydownloaded-music.txt + '{entry['url']}' + """.replace('\n', " ") + ) + + + except yaml.YAMLError as exc: + print("You fucked up the yaml format.") + diff --git a/download-videos.py b/download-videos.py new file mode 100644 index 0000000..f3bbe21 --- /dev/null +++ b/download-videos.py @@ -0,0 +1,29 @@ +import yaml +import os + +with open("linklist-videos.yaml", "r") as yamlfile: + try: + config = yaml.safe_load(yamlfile) + + for entry in config: + print(f"\033[92mGrabbing '{entry['url']}':") + + folderName = entry["folder-name"] if "folder-name" in entry else "\%(uploader)s" + + os.system(f""" + yt-dlp + -c + --merge-output-format mkv + -o 'videos/{folderName}/%(title)s.%(ext)s' + --extractor-args youtube:player_client=android + --throttled-rate 100M + --restrict-filenames + --download-archive alreadydownloaded-videos.txt + '{entry['url']}' + """.replace('\n', " ") + ) + + + except yaml.YAMLError as exc: + print("You fucked up the yaml format.") + diff --git a/download.sh b/download.sh index 8c8be7d..aa3d059 100644 --- a/download.sh +++ b/download.sh @@ -1,2 +1,2 @@ -./download-videos.sh -./download-music.sh +python3 ./download-videos.py +python3 ./download-music.py diff --git a/sync-to-nas.bat b/sync-to-nas.bat new file mode 100644 index 0000000..0ae18e3 --- /dev/null +++ b/sync-to-nas.bat @@ -0,0 +1,3 @@ +robocopy music\ Y:\Leon\Mediafarm\Youtube-Archive\music\ /e /z /j /xo /move +robocopy videos\ Y:\Leon\Mediafarm\Youtube-Archive\videos\ /e /z /j /xo /move +robocopy alreadydownloaded*.txt Y:\Leon\Mediafarm\Youtube-Archive\ /z