yt-dlp: `--cookies-from-browser` failing with Linux chromium: XDG_CURRENT_DESKTOP is set to an unknown value: "MATE"
Checklist
- I’m asking a question and not reporting a bug or requesting a feature
- I’ve looked through the README
- I’ve verified that I have updated yt-dlp to nightly or master (update instructions)
- I’ve searched known issues, the FAQ, and the bugtracker for similar questions including closed ones. DO NOT post duplicates
Please make sure the question is worded well enough to be understood
I have tried following the instructions in the FAQ and also searched for issue topis discussing this issue. I found this one: https://github.com/yt-dlp/yt-dlp/issues/11981 but I couldn’t understand what they were discussing.
I have also tried referencing ‘firefox’ since those cookies aren’t encrypted, but that didn’t work either.
Provide verbose output that clearly demonstrates the problem
- Run your yt-dlp command with -vU flag added (
yt-dlp -vU <your command line>) - If using API, add
'verbose': TruetoYoutubeDLparams instead - Copy the WHOLE output (starting with
[debug] Command-line config) and insert it below
Complete Verbose Output
$ yt-dlp -vU --cookies-from-browser chrome:~/.var/app/com.google.Chrome/ https://www.youtube.com/watch?v=_x4Jk9Te_zE
[debug] Command-line config: ['-vU', '--cookies-from-browser', 'chrome:~/.var/app/com.google.Chrome/', 'https://www.youtube.com/watch?v=_x4Jk9Te_zE']
[debug] User config "/home/halvor/.config/yt-dlp/config": ['-o', '(%(upload_date)s) %(title)s (%(uploader)s - %(extractor)s - %(id)s).%(ext)s', '-S', 'res:360']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2025.03.31 from yt-dlp/yt-dlp [5e457af57] (pip)
[debug] Python 3.10.12 (CPython x86_64 64bit) - Linux-5.15.0-136-generic-x86_64-with-glibc2.35 (OpenSSL 3.0.2 15 Mar 2022, glibc 2.35)
[debug] exe versions: ffmpeg 4.4.2 (setts), ffprobe 4.4.2
[debug] Optional libraries: Cryptodome-3.15.0, brotli-1.0.9, certifi-2020.06.20, mutagen-1.45.1, requests-2.32.3, secretstorage-3.3.1, sqlite3-3.37.2, urllib3-2.1.0, websockets-13.1
[debug] Proxy map: {}
Extracting cookies from chrome
[debug] Extracting cookies from: "/home/halvor/.var/app/com.google.Chrome/config/google-chrome/Default/Cookies"
[Cookies] Loading cookie 0/ 12XDG_CURRENT_DESKTOP is set to an unknown value: "MATE"
[debug] detected desktop environment: OTHER
[debug] Chosen keyring: BASICTEXT
WARNING: cannot decrypt v11 cookies: no key found
Extracted 0 cookies from chrome (12 could not be decrypted)
[debug] cookie version breakdown: {'v10': 0, 'v11': 12, 'other': 0, 'unencrypted': 0}
[debug] Request Handlers: urllib, requests, websockets
[debug] Plugin directories: none
[debug] Loaded 1850 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: stable@2025.03.31 from yt-dlp/yt-dlp
yt-dlp is up to date (stable@2025.03.31 from yt-dlp/yt-dlp)
[youtube] Extracting URL: https://www.youtube.com/watch?v=_x4Jk9Te_zE
[youtube] _x4Jk9Te_zE: Downloading webpage
[youtube] _x4Jk9Te_zE: Downloading tv client config
[youtube] _x4Jk9Te_zE: Downloading player 9599b765-main
[youtube] _x4Jk9Te_zE: Downloading tv player API JSON
[youtube] _x4Jk9Te_zE: Downloading ios player API JSON
ERROR: [youtube] _x4Jk9Te_zE: Sign in to confirm you’re not a bot. Use --cookies-from-browser or --cookies for the authentication. See https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp for how to manually pass cookies. Also see https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies for tips on effectively exporting YouTube cookies
File "/home/halvor/.local/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 748, in extract
ie_result = self._real_extract(url)
File "/home/halvor/.local/lib/python3.10/site-packages/yt_dlp/extractor/youtube/_video.py", line 3649, in _real_extract
self.raise_no_formats(reason, expected=True)
File "/home/halvor/.local/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 1269, in raise_no_formats
raise ExtractorError(msg, expected=expected, video_id=video_id)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (9 by maintainers)
Commits related to this issue
- [cookies] Fix Linux desktop environment detection (#13197) Closes #12885 Authored by: mbway — committed to yt-dlp/yt-dlp by mbway a year ago
yes, I see what you mean now. I’m putting a PR together with this and some other fixes.
This is what I think the bug in yt-dlp is. Line 802 is an elif statement, so it won’t be run if
xdg_current_desktop is not None, hence, if I’m reading the code correctly, the desktop_session fallback won’t work for unknown XDG_CURRENT_DESKTOP values. That bug is not replicated in Chromium’s source code: https://chromium.googlesource.com/chromium/src/+/refs/heads/main/base/nix/xdg_util.cc#149(in fact, it looks like all the else/elif statements in _get_linux_desktop_environment are redundant at best and problematic at worst)
It looks like there are multiple issues here, I’ll focus on the cookies/desktop selection.
Indicates that the keyring selection is not the problem.
Regarding the issue title:
I checked the chromium source and if
XDG_CURRENT_DESKTOPis set toMATEthen chromium will fallback to readingDESKTOP_SESSIONwhich in the case of MATE should be set to"mate"which would result in yt-dlp choosing gnome keyring, but on your system the desktop session was detected as OTHER so gnome keyring was not chosen. If chrome/chromium is running in the same environment then it also should be choosing basic text instead of gnome keyring.Implementing the same control flow as chromium is the easiest way to make sure we select the correct keyring. The correct behaviour is whatever chromium does, not what the actual truth is (i.e. if chromium has a bug we should duplicate that bug). I checked and there haven’t been any changes on the chromium side so yt-dlp is still in sync.
can you try running this command to see which keyring chrome is choosing
I’m happy to stay involved but I can’t promise quick responses.
per https://github.com/mikf/gallery-dl/issues/7336, does it work if you add
+gnomekeyring, like this:?
also I’m not sure why you’re using
chromeinstead ofbrave, so if the above fails, also try these: