-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to embedding twitch-dl in a python application? #107
Comments
My friend and my solution was to copy some of the private? functions in download.py into our own file and call them when needed Being able to import it like ytdl and pass options for like quality/target filename/format would be handy though EMBEDDING YOUTUBE-DL |
It might be ugly but I use |
This is available as a Python package, so if you do import twitchdl.commands.download as download
class DotDict(dict):
"""dot.notation access to dictionary attributes"""
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
download_args = DotDict(
{
"videos": ["1584666791"],
"format": "mkv",
"keep": False,
"quality": "720p60",
"max_workers": 20,
"no_join": False,
"overwrite": True,
"start": None,
"end": None,
"output": "{date}_{channel_login}_{id}.{format}",
}
)
download(download_args) I'm using DotDict here because the download arguments need to be accessible in dot notation, you can also create an arguments class and create a new instance the class for your arguments and pass that through. You need to provide all arguments and set the ones that you don't need to their default value, as specified in the docs/help page, or set them to |
As you may have guessed, twitch-dl was not built to be used as a library. This is something I'd like to change, but requires a non-trivial effort so I can't tell you when it's going to happen. The suggestions by @FunnyPocketBook and @maskym will work in a pinch. |
There is some wicked magic going on with Twitch-DL to be able to download the video streams from Twitch since that isn't functionality, they expose in the Helix API anymore. I do everything else with the Helix API though using twitchAPI lib for Python (pip install twitchAPI) because it's pretty well documented despite all the async stuff being a little annoying. When I want to download a file, I just create a subprocess to call twitch-dl and make sure it's in the system path and it works just fine. So I would say leave this as an EXE for now instead of making it work directly from Python because if you do that Twitch might re-roll the dice and stop people from downloading again. import subprocess def Download(clip_url):
|
I'm trying to build an application which gets info from a channel like
twitch-dl videos <channel_name> -j --all
and then to filter this metadata list and download some of the videostwitch-dl download <id> -q source -o <some_format>
of the list.I tried to play a bit with the source code to see if i can get something working but I couldn't, so I was wondering if there's some way for me to do it?
The text was updated successfully, but these errors were encountered: