snek-dl
An intuitive wrapper for youtube-dl, to be used as a Python module.
Installation
pip install snek-dl
Why snek-dl?
youtube-dl is a very good CLI tool. However, it can be very confusing to use it within Python, despite being written
in Python. snek-dl aims to target that problem and make youtube-dl more intuitive to use in Python,
right out of the box.
Okay, but seriously, why snek-dl?
-
Accurate URL retrieval
- When
youtube-dlusesffmpegto merge.webmand.m4ainto a video-and-audio file format, the URL retrieved from Python methodget_url()is wrong: it only retrieves the audio URL. snek-dlreturns both the video and audio's URLs, accurately.
- When
-
Remedied inaccurate filename issue
- Same issue as above: it's weirdly hard to get the output video file's name when
youtube-dlusesffmpegto merge the video and audio streams into one file. So it becomes extremely annoying to do any post-processing on the downloaded videos. snek-dlreturns the metadata after downloading the video, which includes basic information such as the actual correct filepath.
- Same issue as above: it's weirdly hard to get the output video file's name when
-
Readable, pretty output
- Any information you
print()for the sake of just looking at the output is so much more readable than the standardyoutube-dloutputs. - Pretty-printing dictionaries and lists is built-in for humans, but it also does not affect any machines reading the objects.
- Any information you
And more to come! The more I use youtube-dl as a Python module, more weirdness I run into. I will be adding some of
the remedies for things that aren't smooth-sailing.
Usage
from snek_dl import Snek
# Initialize your snek engine
engine = Snek(
url="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
name_format="%(title)s-(%(format_id)s)-%(height)sp.%(ext)s", # ex) video_title-(22)-720p.mp4
output_format="bestvideo[ext=mp4]" # picks the best video that has mp4 extension
)
# or you can put youtube-dl's option dictionary
from snek_dl import Snek
opts = {
"outtmpl": "%(title)s-(%(format_id)s)-%(height)sp.%(ext)s",
"format": "bestvideo[ext=mp4]"
}
engine = Snek(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ", options=opts)
# with the initialized snek engine, you can retrieve info like metadata
from snek_dl import Snek
engine = Snek(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ")
# if you set download to false, it only retrieves metadata and does not trigger the download process.
# default is False
info = engine.info(download=False) # returns the metadata
# or if you only want one thing from the metadata:
info = engine.info_detail(detail="id") # returns the id
# there's a special method for retrieving and parsing available formats
# if you set full to true, it will return every detail. default is false
formats = engine.formats(full=False) # returns simplified formats
# if you finished tweaking the engine, and want to start downloading:
from snek_dl import Snek
opts = {
"outtmpl": "%(title)s-(%(format_id)s)-%(height)sp.%(ext)s",
"format": "bestvideo[ext=mp4]"
}
engine = Snek(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ", options=opts)
output = engine.download() # returns filename, id, url, format, and filesize after downloading
Metadata
Release files for snek-dl 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| snek_dl-0.0.6.tar.gz | 16.4 kB | Without provenance | Details for snek_dl-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| snek_dl-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for snek_dl-0.0.6-py3-none-any.whl |
Total release size: 33.1 kB
Release files / snek_dl-0.0.6.tar.gz
| Download URL | snek_dl-0.0.6.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4cdb1a5ff2e3dcd6c35a29e0078952901e97b53350da2c57a18df6565a5150c
|
|
BLAKE2b-256 checksum How to use checksums |
ea054d1f6d29e6c0b4ded34560c65ec6eb2f939c2e7751da897725816c0d9314
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
|
Release files / snek_dl-0.0.6-py3-none-any.whl
| Download URL | snek_dl-0.0.6-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8816cec4ff093f4d7a132a1a405dae254593dca09af5bc5369b3ea351a3496f8
|
|
BLAKE2b-256 checksum How to use checksums |
3bddffbb2ea9a5e16c5fbe199fd4978eb3fb46b1cc0aee68e26b0164cbc250f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
|
Security for snek-dl 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.