Skip to content

feat: add cookies_file option for NetEase provider (workaround for yt-dlp DPAPI issue on Windows) #263

@karenepitaya

Description

@karenepitaya

Problem

When configuring NetEase Cloud Music via cliamp setup on Windows, validation fails with:

netease: validation: netease: load browser cookies: ERROR: Failed to decrypt with DPAPI.
See https://github.com/yt-dlp/yt-dlp/issues/10927 for more info

This is a known yt-dlp bug (yt-dlp#10927) where --cookies-from-browser fails on Windows due to DPAPI decryption issues. The issue is still open with no fix available.

Currently, the NetEase provider only supports cookies_from (browser name), which maps to yt-dlp --cookies-from-browser. There is no way to use a pre-exported cookies file.

Proposed solution

Add a cookies_file config option as an alternative to cookies_from. When set, the provider reads cookies directly from the Netscape-format file instead of calling yt-dlp --cookies-from-browser.

This serves as a workaround for the yt-dlp DPAPI issue on Windows, and is also useful for headless/CI environments where no browser is available.

[netease]
enabled = true
cookies_file = "/path/to/cookies.txt"
user_id = "your-account-user-id"

Verified implementation

I have built and tested a working implementation locally. The changes are minimal:

  1. config/config.go — add CookiesFile field to NetEaseConfig, parse cookies_file key
  2. external/netease/provider.go — add cookiesFile to Config and Provider; in ensureCookieHeader, read directly from file when cookiesFile is set, bypassing yt-dlp
  3. resolve/resolve.go — add SetYTDLCookiesFile function
  4. player/ytdl.go — add SetYTDLCookiesFile, pass --cookies <file> to yt-dlp instead of --cookies-from-browser
  5. main.go — wire CookiesFile from config to provider and player

Tested on Windows 11 with a valid cookies.txt containing MUSIC_U — NetEase provider loads correctly, playlists display, and VIP playback works at full quality (lossless 797kbps).

Workaround attempted before this change

  • Closing Chrome completely (including background processes) — still fails
  • Exporting cookies.txt via browser extension — cliamp ignores it, still calls --cookies-from-browser

Environment

  • cliamp: v1.57.0
  • yt-dlp: 2026.06.09
  • OS: Windows 11 Pro

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions