From fb2935bab4658631ab8dbf7812c52036304c7c5e Mon Sep 17 00:00:00 2001 From: israel Date: Sun, 13 Oct 2024 12:03:01 -0300 Subject: [PATCH 1/2] =?UTF-8?q?Corrige=20erro=20de=20compara=C3=A7=C3=A3o?= =?UTF-8?q?=20de=20'NoneType'=20com=20'int'=20e=20garante=20atualiza=C3=A7?= =?UTF-8?q?=C3=A3o=20de=20ydl=5Fopts=20antes=20do=20download?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YouTube Video Downloader/you_tube_analyzer.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/YouTube Video Downloader/you_tube_analyzer.py b/projects/YouTube Video Downloader/you_tube_analyzer.py index 617f34bf0..f928194af 100644 --- a/projects/YouTube Video Downloader/you_tube_analyzer.py +++ b/projects/YouTube Video Downloader/you_tube_analyzer.py @@ -1,6 +1,5 @@ import yt_dlp - def download_youtube_video(video_url): """Downloads a YouTube video using yt-dlp.""" @@ -24,14 +23,15 @@ def download_youtube_video(video_url): ydl_opts["format"] = format_id else: # Select the highest resolution format - highest_resolution = max(formats, key=lambda x: x.get("height", 0)) + highest_resolution = max(formats, key=lambda x: (x.get("height") or 0)) format_id = highest_resolution["format_id"] ydl_opts["format"] = format_id - # Download the video - ydl.download([video_url]) - print("Download complete using yt-dlp!") - + # Update options with selected format + with yt_dlp.YoutubeDL(ydl_opts) as ydl: + ydl.download([video_url]) + print("Downlaod complete using yt-dlp") + if __name__ == "__main__": video_url = input("Enter the URL: ") From af235490caf3ffff56a42402b80a4ba5026cdba6 Mon Sep 17 00:00:00 2001 From: Israel Alves Date: Sun, 13 Oct 2024 16:11:47 -0300 Subject: [PATCH 2/2] =?UTF-8?q?Atualizando=20o=20README=20para=20conflitos?= =?UTF-8?q?=20em=20sistemas=20LINUX=20com=20depend=C3=AAncias=20divergente?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/YouTube Video Downloader/README.md | 50 +++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 projects/YouTube Video Downloader/README.md diff --git a/projects/YouTube Video Downloader/README.md b/projects/YouTube Video Downloader/README.md new file mode 100644 index 000000000..e2055763f --- /dev/null +++ b/projects/YouTube Video Downloader/README.md @@ -0,0 +1,50 @@ +# youtube_video_downloader + +Este projeto utiliza `yt-dlp` para baixar vídeos do YouTube com a resolução mais alta disponível ou com a resolução escolhida pelo usuário. + +## Descrição + +- **Nome do Script:** `you_tube_analyzer.py` +- **Propósito:** Baixar vídeos do YouTube com alta qualidade. +- **Funcionalidades:** + - Permite ao usuário escolher entre as resoluções disponíveis. + - Seleciona automaticamente a maior resolução disponível, se preferido. + +## Requisitos + +- Python 3 +- yt-dlp + +## Uso + +1. Clone o repositório para sua máquina local. + ```bash + git clone https://github.com/Mrinank-Bhowmick/python-beginner-projects.git + +2. Navegue até o diretório do script + ```bash + cd python-beginner-projects/projects/YouTube\ Video\ Downloader/ + +3. Instale as dependências necessárias. + ```bash + pip install yt-dlp + +4. Execute you_tube_analyzer.py + ```bash + python3 you_tube_analyzer.py + +## Solução de Problemas + +Se você encontrar conflitos de dependências com versões mais recentes, siga os passos +abaixo para configurar um ambiente virtual e instalar as versões específicas necessárias: + +### 1. Crie e ative um ambiente virtual: + ```bash + python3 -m venv meu_ambiente + source meu-ambiente/bin/activate +``` + +### 2. Instale as versões compatíveis das dependências: + ```bash + pip install requests_mock clyent==1.2.1 nbformat==5.4.0 requests==2.28.1 +```