commit ca0f98ecec2657eee7cc8a6a4f3e1eab4d1ec76a Author: jowj Date: Sun Oct 6 18:15:13 2019 -0500 Initial commit. - brief readme - initial working commit of the youtube-dl script i use diff --git a/dwim-youtube-dl.py b/dwim-youtube-dl.py new file mode 100644 index 0000000..8044f20 --- /dev/null +++ b/dwim-youtube-dl.py @@ -0,0 +1,40 @@ +import os +import argparse +import subprocess +import shutil +from pathlib import Path + +if __name__ == '__main__': + MUSIC_DEST = + VIDEO_DEST = + + PARSER = argparse.ArgumentParser() + PARSER.add_argument('-t', '--type', help="aud or vid?", type=str) + PARSER.add_argument('-u', '--url', help="link?", type=str) + + ARGS = PARSER.parse_args() + + TEMP_PATH = os.getcwd() + '/temp' + os.mkdir(TEMP_PATH) + os.chdir(TEMP_PATH) + + if ARGS.type == 'music': + # this will download a video an convert to just mp3 + URL = ARGS.url + DEST_ROOT = MUSIC_DEST + subprocess.call(["youtube-dl", "-i", "--extract-audio", + "--audio-format", "mp3", "--yes-playlist", + "-o", "%(playlist_title)s/%(title)s.%(ext)s", + URL]) + if ARGS.type == 'video': + # this actually downloads the videos in a playlist to seperate files. + URL = ARGS.url + DEST_ROOT = VIDEO_DEST + subprocess.call(["youtube-dl", "-i", "-f" + "mp4", "-o", "%(playlist_title)s/%(title)s.%(ext)s", + URL]) + + PLAYLIST = os.listdir(".") + DEST = DEST_ROOT + "/" + PLAYLIST[0] + shutil.move(PLAYLIST[0], DEST) + os.rmdir(TEMP_PATH) diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..2f9057c --- /dev/null +++ b/readme.md @@ -0,0 +1,13 @@ +# utils +this repo houses some random shit i wrote that does stuff for me. almost no one will want this stuff. + +## dwim-youtube-dl +youtube-dl is fucking amazing. its one of the coolest / most useful things maintained by oss people that regular, normal humans see. but it doesn't do what i want it to do out of the box. + +### features +- infer if the item given is part of a playlist or not + - if its in a playlist, each file downloaded goes in a folder named after the playlist + - if its not a playlist..what should happen? + +- declare a flag that determines what library the target should go to + - video vs audio, etc