From 9b6e9fc7a6b047242f972ff86f4c3cb5772c096d Mon Sep 17 00:00:00 2001 From: Leonetienne Date: Fri, 4 Feb 2022 15:15:59 +0100 Subject: [PATCH] Added possibility to download stuff once --- .gitignore | 3 +- download-mp3.sh => download-music.sh | 0 download-once.py | 42 ++++++++++++++++++++++++++++ download-videos.sh | 2 +- download.sh | 2 +- 5 files changed, 46 insertions(+), 3 deletions(-) rename download-mp3.sh => download-music.sh (100%) create mode 100644 download-once.py diff --git a/.gitignore b/.gitignore index 6a7796f..e0cd07c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /music/ /videos/ /linklist-*.txt -/alreadydownloaded-*.txt +/alreadydownloaded*.txt +/once.yaml \ No newline at end of file diff --git a/download-mp3.sh b/download-music.sh similarity index 100% rename from download-mp3.sh rename to download-music.sh diff --git a/download-once.py b/download-once.py new file mode 100644 index 0000000..9c04c90 --- /dev/null +++ b/download-once.py @@ -0,0 +1,42 @@ +# This script is for downloading stuff ONCE. This is for, let's say, playlists that will never change again that you want to download. +import yaml +import os + +with open("once.yaml", "r") as yamlfile: + try: + config = yaml.safe_load(yamlfile) + + for entry in config: + print(f"\033[92mGrabbing {entry['type']} '{entry['url']}':") + + if entry["type"] == "music": + os.system(f""" + yt-dlp + -c + --extract-audio + --audio-format mp3 + -o 'music/{entry['folder-name']}/%(title)s.%(ext)s' + --extractor-args youtube:player_client=android + --throttled-rate 100M + --restrict-filenames + --download-archive alreadydownloadedonce-music.txt + '{entry['url']}' + """.replace('\n', " ") + ) + + elif entry["type"] == "video" or entry["type"] == "videos": + os.system(f""" + yt-dlp + -c + --merge-output-format mkv + -o 'videos/{entry['folder-name']}/%(title)s.%(ext)s' + --extractor-args youtube:player_client=android + --throttled-rate 100M + --restrict-filenames + --download-archive alreadydownloadedonce-videos.txt + '{entry['url']}' + """.replace('\n', " ") + ) + + except yaml.YAMLError as exc: + print("You fucked up the yaml format.") diff --git a/download-videos.sh b/download-videos.sh index 8f3f974..83fa071 100644 --- a/download-videos.sh +++ b/download-videos.sh @@ -6,4 +6,4 @@ yt-dlp \ --extractor-args youtube:player_client=android \ --throttled-rate 100M \ --restrict-filenames \ ---download-archive alreadydownloaded-video.txt +--download-archive alreadydownloaded-videos.txt diff --git a/download.sh b/download.sh index 5604366..8c8be7d 100644 --- a/download.sh +++ b/download.sh @@ -1,2 +1,2 @@ ./download-videos.sh -./download-mp3.sh +./download-music.sh