From 0badcddcd2bf392abdd97f01822cd92d7739f114 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 13 Apr 2021 17:09:28 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20First=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 +++ .idea/discord.xml | 6 ++ .idea/inspectionProfiles/Project_Default.xml | 71 ++++++++++++++++++++ .idea/misc.xml | 12 ++++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 ++ poetry.lock | 18 +++++ pyproject.toml | 15 +++++ youtubedlez.iml | 9 +++ youtubedlez/__main__.py | 58 ++++++++++++++++ youtubedlez/sample_input.txt | 2 + 11 files changed, 213 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/discord.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 poetry.lock create mode 100644 pyproject.toml create mode 100644 youtubedlez.iml create mode 100644 youtubedlez/__main__.py create mode 100644 youtubedlez/sample_input.txt diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..cd711a0 --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..bc9ee74 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,71 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a5ef922 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + IDE + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..70bf729 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..b20adcd --- /dev/null +++ b/poetry.lock @@ -0,0 +1,18 @@ +[[package]] +name = "youtube-dl" +version = "2021.4.7" +description = "YouTube video downloader" +category = "main" +optional = false +python-versions = "*" + +[metadata] +lock-version = "1.1" +python-versions = "^3.9" +content-hash = "16918e22e736eef3cde5e96a31e1d884972cd3c6546696f9c48e4afd39c42c73" + +[metadata.files] +youtube-dl = [ + {file = "youtube_dl-2021.4.7-py2.py3-none-any.whl", hash = "sha256:5031125b13c92d23197adbe5d20f7a0a03befc510cabbfccb757703b7e35c140"}, + {file = "youtube_dl-2021.4.7.tar.gz", hash = "sha256:34a034d9b2062e428710d4cd6365db7a64cd388e51a3f9ab74058179c95d8654"}, +] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ef998d9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,15 @@ +[tool.poetry] +name = "youtubedlez" +version = "0.1.0" +description = "A fast and easy way to use YoutubeDL" +authors = ["Stefano Pigozzi "] + +[tool.poetry.dependencies] +python = "^3.9" +youtube_dl = "*" + +[tool.poetry.dev-dependencies] + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/youtubedlez.iml b/youtubedlez.iml new file mode 100644 index 0000000..ad3c0a3 --- /dev/null +++ b/youtubedlez.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/youtubedlez/__main__.py b/youtubedlez/__main__.py new file mode 100644 index 0000000..2286899 --- /dev/null +++ b/youtubedlez/__main__.py @@ -0,0 +1,58 @@ +import youtube_dl +import pathlib +import datetime +import os + + +print(f"Easy Youtube Downloader") +print(f"(c) {datetime.datetime.now().year} Stefano Pigozzi") +print(f"Released under the GPL 3.0") +print("-" * 80) +print() + +dl_url = input("What video(s) do you want to download? ") + +while True: + dl_format = input("What format to you want the downloaded file(s) to have? ") + video_formats = ['mp4', 'flv', 'webm', 'ogg', 'mkv', 'avi'] + audio_formats = ['best', 'aac', 'flac', 'mp3', 'm4a', 'opus', 'vorbis', 'wav'] + + if dl_format in video_formats: + postprocessors = [ + { + 'key': 'FFmpegVideoConvertor', + 'preferedformat': dl_format, + }, + ] + break + elif dl_format in audio_formats: + postprocessors = [ + { + 'key': 'FFmpegExtractAudio', + 'preferredcodec': dl_format, + }, + ] + break + else: + print("Invalid format specified") + print("Formats available: ") + print("Video: " + " ".join(video_formats)) + print("Audio: " + " ".join(audio_formats)) + + +dl_location = pathlib.Path.home().joinpath("Downloads") +os.makedirs(name=dl_location, exist_ok=True) +print(f"The downloads will be saved in: {dl_location}") + +print() +with youtube_dl.YoutubeDL({ + "noplaylist": True, + "prefer_ffmpeg": True, + "outtmpl": f"{dl_location}/%(extractor)s__%(title)s.%(ext)s" +}) as ytdl: + ytdl.download([dl_url]) +print() + +print("Download complete!") +print("Press any key to exit.") +input() diff --git a/youtubedlez/sample_input.txt b/youtubedlez/sample_input.txt new file mode 100644 index 0000000..827a357 --- /dev/null +++ b/youtubedlez/sample_input.txt @@ -0,0 +1,2 @@ +https://www.youtube.com/watch?v=BaW_jenozKc +mp3