jaseg / python-mpv

Python interface to the awesome mpv media player
https://git.jaseg.de/python-mpv.git
Other
550 stars 68 forks source link

i can not use yt_dlp instead of the youtube-dl #185

Closed musicfunfan closed 2 years ago

musicfunfan commented 2 years ago

hello this is more a question then issue i want to use python-mpv with the yt_dlp and not with youtube-dl is that possible? i manage to do this on mpv player by adding this line: script-opts=ytdl_hook-ytdl_path=/usr/bin/yt-dlp on the .config/mpv.conf Now mpv player uses the yt_dlp can i do something similar on python-mpv when i create the player object like the example

import mpv player = mpv.MPV(ytdl=True) player.play('https://youtu.be/DOmdB7D-pUU') player.wait_for_playback()

i am using archlinux as my os

thenx for any help

jaseg commented 2 years ago

I cannot easily test it, but this should work: mpv.MPV(ytdl=True, script_opts='ytdl_hook-ytdl_path=/usr/bin/yt-dlp') In general, all mpv command-line options also work as arguments in the mpv.MPV(...) constructor. Just remove the leading dashes, and replace all other dashes with underscores.

musicfunfan commented 2 years ago

Thenx for the reply. On archlinux mpv works with yt-dlp by default so all good. On debian based (Linux Mint) its not. And i try this example code but its not working for me.

import mpv player = mpv.MPV(ytdl=True, script_opts='ytdl_hook-ytdl_path=/home/msuicfun/.local/bin/yt-dlp' player.play('https://www.youtube.com/watch?v=TTdjKxF4IAk') player.wait_for_playback()

I also try to insert the script-option command in ~/.config/mpv.conf to see if this is working and i get this output.

[ytdl_hook] script-opts: unknown key ytdl_path, ignoring [ytdl_hook] [ytdl_hook] youtube-dl failed: not found or not enough permissions Failed to recognize file format. The solution i found is to replace the youtube-dl binary with yt-dlp

mv youtube-dl yt-dlp

This is working but this solution is not very elegant :(

Sorry for the on line code by the way i do not know how to do new line on github.com when i use the "code" formating :( .

Also sorry for my bad English i am not good with the language yet.

jaseg commented 2 years ago

Which libmpv version are you running on Linux Mint? It looks like that ytdl_path option was recently added and you need at least libmpv v0.33.0 to get it. Now, AFAICT mint uses ubuntu's package repositories, which theoretically have v0.33.1 already, but if you are on an older version of mint your libmpv might just not have that option yet.

Can you please post what is the output of: python3 -c 'import mpv; print(mpv.MPV().mpv_version)'

musicfunfan commented 2 years ago

The output is...

mpv 0.32.0

So this is my problem then... Weird i am on Linux Mint latest version and i have done all the updates. This is my neofecth for Linux Mint is in a vm.

Screenshot from 2022-04-19 12-41-01

jaseg commented 2 years ago

Weird i am on Linux Mint latest version and i have done all the updates.

Since Mint is Ubuntu/Debian-based, it may well be that the latest Mint version simply does not have an up-to-date mpv package. Debian and derived distros often lag behind with their package versions by several years.

Two things you could try is (1) building your own, up-to-date mpv/libmpv and installing them to /usr/local, or (2) installing a more up-to-date version from an alternative binary packaging system such as flatpak, and telling python-mpv to use that instead through the LD_LIBRARY_PATH environment variable.

musicfunfan commented 2 years ago

Yea this is no issue with the project. This is just old dependencies on Linux Mint side. Thenx for the help.

jaseg commented 2 years ago

You're welcome!