Closed LawrenceJGD closed 6 years ago
That's already supported under the name of option access. You could either do it at initation (e.g. mp = MPV(ytdl_format='best')
) or like in the given link.
Oh, I had not seen it, but is it possible to do something similar to --ytdl-format=244+bestaudio
? because I can not make it work well.
Excuse me if I ask silly questions, I'm a novice in programming.
I'm afraid that 244+bestaudio
is not a valid format. It can only be either a format code (244), or an expression describing the format (bestaudio), not both.
Edit: Accept my apology, 244+bestaudio
does work because the format 244 is video only. Does this work for you:
from mpv import MPV
mp = MPV(ytdl=True, ytdl_format='244+bestaudio', input_default_bindings=True,
input_vo_keyboard=True)
mp.play('https://www.youtube.com/watch?v=n5PvkLg8LQk')
mp.wait_for_playback()
mp.quit()
Now it works, thanks for the help.
I'm glad to hear so. If everything runs fine, please close the issue. Thanks.
Apparently ytdl_raw_options doesn't work, i'm trying to use --no-cache-dir because that's a fix from their issues section.
Edit: it actually works, and just for the sake of people like me that can't find any information about this heres what you do:
player = mpv.MPV(ytdl=True,ytdl_raw_options="no-cache-dir="
if you have a no argument flag you have to end with '=', that was my problem.
The following works:
import mpv
player = mpv.MPV(ytdl = True, log_handler=print, loglevel='debug', ytdl_raw_options='foo=bar,baz=23')
player.play('https://www.youtube.com/watch?v=SkgTxQm9DWM')
You can see that the correct options are passed to youtube-dl in the console debug output. Direct passthrough of python dicts as MPV node objects indeed seems to be broken, but the fall-back to passing command-line strings is ok I think.
You can also change this option at runtime, AFAICT with the updated arguments being used for the next youtube-dl invocation:
player['ytdl-raw-options'] = 'foo=bar,baz=42'
You could add Youtube DL options such as changing the video format or even give options using
--ytdl-raw-options
, it would be very useful for certain scripts to choose predefined formats.Sorry for my bad English.