flathub / io.mpv.Mpv

https://flathub.org/apps/details/io.mpv.Mpv
8 stars 19 forks source link

--ytdl-raw-options=cookies-from-browser=firefox is not functional in Flatpak MPV #459

Closed askpng closed 1 month ago

askpng commented 1 month ago

Issue

Flatpak MPV is not recognizing Firefox browser cookies for YouTube via --ytdl-raw-options=cookies-from-browser=firefox, -ytdl-raw-options=cookies-from-browser=firefox:~/.var/app/org.mozilla.firefox/.mozilla/firefox. Works fine in the Pacman & AUR version of Flatpak.

Additionally, when --ytdl-raw-options=cookies-from-browser=firefox is used, Flathub MPV refuses to play regular YouTube videos that start with https://. If replaced with ytdl://, regular video plays. When attempting to play membership-only videos with ytdl://, [ytdl_hook] ERROR: [youtube] WATCHCODE: The following content is not available on this app.. Watch on the latest version of YouTube. happens.

Additional info

Was working just fine until about a month ago (April 19-20), during which I could use Flatpak MPV and Celluloid to watch membership-only videos on YouTube. Recently refreshed my computer and tried to restore mpv.conf + adjust --cookies-from-browser firefox:~/.var/app/org.mozilla.firefox/.mozilla/firefox from yt-dlp config into Flatpak MPV and Celluloid config, but getting the atderr: ERROR: could not find firefox cookies database in '/var/home/$USER/.var/app/org.mozilla.firefox/.mozilla/firefox' and errors that follow. Also happening in Celluloid.

yt-dlp added the Firefox flatpak directory by default on their 2024.04.09 release. Could this be related?

I initially thought this could be a formatting error, but I'm unable to get the right entry format for --ytdl-raw-options=cookies-from-browser no matter what combination I try. If it is indeed a formatting error, can you point me to the right format?

Steps to reproduce with logs attached

Regular videos

Flatpak:

  1. Run flatpak run --command=mpv io.mpv.Mpv -v "https://[URL]" --ytdl-raw-options=cookies-from-browser=firefox:~/.var/app/org.mozilla.firefox/.mozilla/firefox
  2. Get the following error:
    [ytdl_hook] stderr: ERROR: could not find firefox cookies database in '/var/home/$USER/.var/app/org.mozilla.firefox/.mozilla/firefox'
    [ytdl_hook] 
    [ytdl_hook] ERROR: could not find firefox cookies database in '/var/home/$USER/.var/app/org.mozilla.firefox/.mozilla/firefox'
    [ytdl_hook] youtube-dl failed: unexpected error occurred
    [cplayer] finished playback, unrecognized file format (reason 4)
    [cplayer] Failed to recognize file format.
    [cplayer] Exiting... (Errors when loading file)

Full log: io.mpv.Mpv from flatpak

Pacman/AUR:

  1. Run mpv -v "https://[URL]" --ytdl-raw-options=cookies-from-browser=firefox:~/.var/app/org.mozilla.firefox/.mozilla/firefox with mpv from pacman or mpv-full-git from AUR
  2. Target video plays as expected

Full log: mpv from pacman Full log: mpv-full-git from AUR

Membership-only videos

Flatpak:

  1. Play membership-only videos on YouTube by running flatpak run --command=mpv io.mpv.Mpv -v "ytdl://[URL]" --ytdl-raw-options=cookies-from-browser=firefox:~/.var/app/org.mozilla.firefox/.mozilla/firefox
  2. Get the following error:
    [ytdl_hook] stderr: ERROR: [youtube] WATCHCODE: The following content is not available on this app.. Watch on the latest version of YouTube.
    [ytdl_hook] 
    [ytdl_hook] ERROR: [youtube] WATCHCODE: The following content is not available on this app.. Watch on the latest version of YouTube.
    [ytdl_hook] youtube-dl failed: unexpected error occurred
    [cplayer] Running hook: ytdl_hook/on_load
    [ytdl_hook] playlist hook
    [cplayer] Running hook: auto_profiles/on_load
    [stream_callback] Opening ytdl://www.youtube.com/watch?v=WATCHCODE
    [stream] No protocol handler found to open URL ytdl://www.youtube.com/watch?v=WATCHCODE
    [stream] The protocol is either unsupported, or was disabled at compile-time.
    [cplayer] Opening failed or was aborted: ytdl://www.youtube.com/watch?v=WATCHCODE
    [cplayer] Running hook: ytdl_hook/on_load_fail
    [ytdl_hook] full hook
    [ytdl_hook] status: 1
    [ytdl_hook] reason: 
    [ytdl_hook] stdout: null
    [ytdl_hook] 
    [ytdl_hook] stderr: ERROR: [youtube] WATCHCODE: The following content is not available on this app.. Watch on the latest version of YouTube.
    [ytdl_hook] 
    [ytdl_hook] ERROR: [youtube] WATCHCODE: The following content is not available on this app.. Watch on the latest version of YouTube.
    [ytdl_hook] youtube-dl failed: unexpected error occurred
    [cplayer] finished playback, loading failed (reason 4)
    [cplayer] Exiting... (Errors when loading file)

Full log: io.mpv.Mpv from flatpak

Pacman/AUR

  1. Play membership-only videos on YouTube by running mpv -v "https://[URL]" --ytdl-raw-options=cookies-from-browser=firefox:~/.var/app/org.mozilla.firefox/.mozilla/firefox with mpv from pacman or mpv-full-git from AUR
  2. Target video plays as expected

Version info

Flatpak

> flatpak run --command=mpv io.mpv.Mpv --version
mpv v0.38.0 Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
libplacebo version: v6.338.2
FFmpeg version: n7.0
FFmpeg library versions:
   libavutil       59.8.100
   libavcodec      61.3.100
   libavformat     61.1.100
   libswscale      8.1.100
   libavfilter     10.1.100
   libswresample   5.1.100
> flatpak run --command=yt-dlp io.mpv.Mpv --version
2024.04.09

pacman

> mpv --version
mpv v0.38.0 Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
 built on Apr 18 2024 06:31:17
libplacebo version: v6.338.2
FFmpeg version: n6.1.1
FFmpeg library versions:
   libavutil       58.29.100
   libavcodec      60.31.102
   libavformat     60.16.100
   libswscale      7.5.100
   libavfilter     9.12.100
   libswresample   4.12.100
> yt-dlp --version
2024.04.09

AUR

> mpv --version
mpv v0.38.0-116-gc4b6d0da38 Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
libplacebo version: v6.338.2
FFmpeg version: N-115359-g3d1597d3e2
FFmpeg library versions:
   libavutil       59.16.101 (runtime 59.19.100)
   libavcodec      61.5.103 (runtime 61.5.104)
   libavformat     61.3.103
   libswscale      8.2.100
   libavfilter     10.2.101 (runtime 10.2.102)
   libswresample   5.2.100
> yt-dlp --version
2024.04.09
Erick555 commented 1 month ago

did you add --filesystem=~/.var/app/org.mozilla.firefox/.mozilla to mpv flatpak? I don't see it in the commands above

askpng commented 1 month ago

With or without explicit access to filesystem=host, host-os, host-etc, and home or manual specification of the Firefox Flatpak folder via Flatpak I still get these errors. Previously it was working just with cookies-from-browser passed from Firefox to MPV, without needing to modify filesystem permissions on Flatpak.

> flatpak run --command=mpv io.mpv.Mpv '[URL]' --ytdl-raw-options=cookies-from-browser=firefox:~/.var/app/org.mozilla.firefox/.mozilla/firefox
[ytdl_hook] ERROR: could not find firefox cookies database in '/var/home/mel/.var/app/org.mozilla.firefox/.mozilla/firefox'
[ytdl_hook] youtube-dl failed: unexpected error occurred
Failed to recognize file format.
Exiting... (Errors when loading file)

When using ytdl-raw-options="cookies-from-browser firefox:~/.var/app/org.mozilla.firefox/.mozilla" in the mpv.config file:

> flatpak run --command=mpv io.mpv.Mpv '[URL]' --config-dir=~/.var/app/io.mpv.Mpv/config/mpv/mpv.conf
[ytdl_hook] ERROR: [youtube] WATCHCODE: The following content is not available on this app.. Watch on the latest version of YouTube.
[ytdl_hook] youtube-dl failed: unexpected error occurred
Failed to recognize file format.
Exiting... (Errors when loading file)
Erick555 commented 1 month ago

With or without explicit access to filesystem=host, host-os, host-etc, and home or manual specification of the Firefox Flatpak folder via Flatpak I still get these errors

Please post flatpak run --filesystem=~/.var/app/org.mozilla.firefox/.mozilla --command=mpv io.mpv.Mpv '[URL]' --ytdl-raw-options=cookies-from-browser=firefox:~/.var/app/org.mozilla.firefox/.mozilla/firefox anything else else isn't supposed to work - home or host are irrelevant.

askpng commented 1 month ago

Gotcha. Working now with membership-only video link:

flatpak run --filesystem=~/.var/app/org.mozilla.firefox/.mozilla --command=mpv io.mpv.Mpv '[URL]' --ytdl-raw-options=cookies-from-browser=firefox:~/.var/app/org.mozilla.firefox/.mozilla/firefox
 (+) Video --vid=1 (*) (vp9 1920x1080 60.000fps)
 (+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
     Subs  --sid=1 --slang=live_chat 'json' (null) (external)
File tags:
 Uploader: [CHANNEL NAME]
 Channel_URL: [URL]
AO: [pipewire] 48000Hz stereo 2ch floatp
VO: [gpu] 1920x1080 yuv420p
(Paused) AV: 00:00:03 / 00:29:28 (0%) A-V:  0.000 Dropped: 3 Cache: 7.9s/1MB
Exiting... (Quit)

Thanks a bunch for pointing me to the right direction! Did something recently change that affected this? I don't recall ever having to set filesystem to the Firefox dir up until now.

Add.: --ytdl-raw-options=cookies-from-browser=firefox also simply works too, following the yt-dlp 2024.04.09 changelog. Could this be the cause?

fastrizwaan commented 1 month ago

Glad it worked for you. mpv has limited filesystem access. so, one needs to give access to the required directory, here sandboxed mpv and yt-dlp required access to --filesystem=~/.var/app/org.mozilla.firefox/.mozilla.

askpng commented 1 month ago

Weird, I actually don't recall ever having to explicitly specify the filesystem path before to get browser cookies to work! But it's working now so all's well. Thanks so much for the assistance!