TheBookKnight / Python-Fragments

Python scripts based on what I found on the internet
0 stars 0 forks source link

Download Youtube Videos #1

Closed TheBookKnight closed 7 months ago

TheBookKnight commented 7 months ago

Based off CL Coding post https://twitter.com/clcoding/status/1713296926894969123

Image

TheBookKnight commented 7 months ago

Ok, so if I just run pip install it'll install it globally (reference).

But, I want it to install just to the project. To do so, I need to create a Virtual Environment.

Fortunately, there's a Virtual Environment Manager called pipenv that fulfills such need.

TheBookKnight commented 7 months ago

Realized, I need pip in the first place.

Had to set my PATH to library modules as well so I can access Python via

python <CMD>

Got Python 3.12 working via DMG installer

TheBookKnight commented 7 months ago

Got the latest PIP per version as well

Successfully installed pip-23.3.1
TheBookKnight commented 7 months ago

Confirmed pipenv installation

To install a package with pipenv, I use below

pipenv install <LIBRARY>

To run a script using pipenv, I use below

pipenv run python <SCRIPT_NAME>.py
TheBookKnight commented 7 months ago

Installed the Youtube vid downloader library yt_dlp

% pipenv install yt-dlp
Creating a virtualenv for this project...
Pipfile: /Users/macpro/Documents/GitHub/Python-Fragments/Download YouTube Videos/Pipfile
Using default python from /Library/Frameworks/Python.framework/Versions/3.12/bin/python3 (3.12.0) to create virtualenv...
⠹ Creating virtual environment...created virtual environment CPython3.12.0.final.0-64 in 207ms
  creator CPython3Posix(dest=/Users/macpro/.local/share/virtualenvs/Download_YouTube_Videos-UJQlTFJo, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, via=copy, app_data_dir=/Users/macpro/Library/Application Support/virtualenv)
    added seed packages: pip==23.3.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment!
Virtualenv location: /Users/macpro/.local/share/virtualenvs/Download_YouTube_Videos-UJQlTFJo
Creating a Pipfile for this project...
Installing yt-dlp...
Resolving yt-dlp...
Added yt-dlp to Pipfile's [packages] ...
✔ Installation Succeeded
Pipfile.lock not found, creating...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success!
Locking [dev-packages] dependencies...
Updated Pipfile.lock (374bc052b402813bf007eafa765b911959dcad671d2291dda544be64d7452f93)!
Installing dependencies from Pipfile.lock (452f93)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
TheBookKnight commented 7 months ago

There's a nice section called custom format selectors to checkout as well. Like check what format of vid you want https://pypi.org/project/yt-dlp/#download-options