An intuitive wrapper for youtube-dl
Project description
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-dl
usesffmpeg
to merge.webm
and.m4a
into a video-and-audio file format, the URL retrieved from Python methodget_url()
is wrong: it only retrieves the audio URL. snek-dl
returns 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-dl
usesffmpeg
to merge the video and audio streams into one file. So it becomes extremely annoying to do any post-processing on the downloaded videos. snek-dl
returns 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-dl
outputs. - 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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file snek_dl-0.0.6.tar.gz
.
File metadata
- Download URL: snek_dl-0.0.6.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4cdb1a5ff2e3dcd6c35a29e0078952901e97b53350da2c57a18df6565a5150c |
|
MD5 | 4c116c3e07d27973ffa313ce8cd70be2 |
|
BLAKE2b-256 | ea054d1f6d29e6c0b4ded34560c65ec6eb2f939c2e7751da897725816c0d9314 |
File details
Details for the file snek_dl-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: snek_dl-0.0.6-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8816cec4ff093f4d7a132a1a405dae254593dca09af5bc5369b3ea351a3496f8 |
|
MD5 | 668db487c83333a5b212d53d3d2a8925 |
|
BLAKE2b-256 | 3bddffbb2ea9a5e16c5fbe199fd4978eb3fb46b1cc0aee68e26b0164cbc250f0 |