Repository: yt-dlp/yt-dlp

Issue:
[youtube] Cannot access private playlist even when cookies are supplied
<!--

######################################################################
  WARNING!
  IGNORING THE FOLLOWING TEMPLATE WILL RESULT IN ISSUE CLOSED AS INCOMPLETE
######################################################################

-->


## Checklist

<!--
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of yt-dlp:
- First of, make sure you are using the latest version of yt-dlp. Run `yt-dlp --version` and ensure your version is 2021.07.07. If it's not, see https://github.com/yt-dlp/yt-dlp on how to update. Issues with outdated version will be REJECTED.
- Make sure that all provided video/audio/playlist URLs (if any) are alive and playable in a browser.
- Make sure that all URLs and arguments with special characters are properly quoted or escaped as explained in https://github.com/yt-dlp/yt-dlp.
- Search the bugtracker for similar issues: https://github.com/yt-dlp/yt-dlp. DO NOT post duplicates.
- Read bugs section in FAQ: https://github.com/yt-dlp/yt-dlp
- Finally, put x into all relevant boxes like this [x] (Dont forget to delete the empty space)
-->

- [x] I'm reporting a broken site support issue
- [x] I've verified that I'm running yt-dlp version **2021.07.07**
- [x] I've checked that all provided URLs are alive and playable in a browser
- [x] I've checked that all URLs and arguments with special characters are properly quoted or escaped
- [x] I've searched the bugtracker for similar bug reports including closed ones
- [x] I've read bugs section in FAQ


## Verbose log

<!--
Provide the complete verbose output of yt-dlp that clearly demonstrates the problem.
Add the `-v` flag to your command line you run yt-dlp with (`yt-dlp -v <your command line>`), copy the WHOLE output and insert it below. It should look similar to this:
 [debug] System config: []
 [debug] User config: []
 [debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKc']
 [debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
 [debug] yt-dlp version 2021.07.07
 [debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2
 [debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4
 [debug] Proxy map: {}
 <more lines>
-->

I'm not sure which log to post, as I've done multiple in an attempt to solve the issue, so I'll post my first encounter with the error first: ([Reddit comment](https://www.reddit.com/r/youtubedl/comments/ol2d4q/im_trying_to_download_unlisted_videos_in_my_watch/h5bq05i?utm_source=share&utm_medium=web2x&context=3)

```
C:\Users\Victoria Redacted\Desktop\Desktop Misc\YouTube DL>yt-dlp "https://www.youtube.com/playlist?list=WL" -o "%(playlist)s [%(playlist_id)s]/%(playlist_index)s_%(upload_date)s - %(title)s [%(id)s].%(ext)s" --match-filter "availability != public" --datebefore 20170101 --playlist-items 1-1000
[youtube:tab] WL: Downloading webpage
[youtube:tab] WL: Downloading API JSON with unavailable videos
WARNING: [youtube:tab] YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
[download] Downloading playlist: Watch later
[youtube:tab] WL page 1: Downloading API JSON
ERROR: YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
C:\Users\Victoria Redacted\Desktop\Desktop Misc\YouTube DL>yt-dlp --verbose
[debug] Portable config file: C:\Users\Victoria Redacted\Desktop\Desktop Misc\YouTube DL\yt-dlp.conf
[debug] Portable config: ['--remux-video', 'mkv', '--no-continue', '--no-cache-dir', '--add-metadata', '--write-description', '--write-thumbnail', '--all-subs', '--write-info-json', '--embed-subs', '--embed-thumbnail', '--download-archive', 'ids.txt', '--min-sleep-interval', '1', '--max-sleep-interval', '15', '--cookies', 'C:\\Users\\Victoria Redacted\\Downloads\\cookies.txt']
[debug] Home config file: yt-dlp.conf
[debug] Home config: ['--remux-video', 'mkv', '--no-continue', '--no-cache-dir', '--add-metadata', '--write-description', '--write-thumbnail', '--all-subs', '--write-info-json', '--embed-subs', '--embed-thumbnail', '--download-archive', 'ids.txt', '--min-sleep-interval', '1', '--max-sleep-interval', '15', '--cookies', 'C:\\Users\\Victoria Redacted\\Downloads\\cookies.txt']
[debug] Command-line config: ['--verbose']
[debug] Loading archive file 'ids.txt'

[debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] yt-dlp version 2021.07.07 (exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.19041-SP0
[debug] exe versions: ffmpeg 2021-07-04-git-301d275301-full_build-www.gyan.dev, ffprobe 2021-07-04-git-301d275301-full_build-www.gyan.dev
[debug] Proxy map: {}
Usage: yt-dlp [OPTIONS] URL [URL...]

yt-dlp: error: You must provide at least one URL.
Type yt-dlp --help to see a list of all options.
```

And here's one of my more recent attempts to run my command. As per one of the youtube-dl subreddit mods, I've tried to run it without using my config file and just putting all my options in my command. ([Reddit comment](https://www.reddit.com/r/youtubedl/comments/ol2d4q/im_trying_to_download_unlisted_videos_in_my_watch/h5c5hvd?utm_source=share&utm_medium=web2x&context=3))

```
C:\Users\Victoria Redacted\Desktop\Desktop Misc\YouTube DL>yt-dlp "https://www.youtube.com/playlist?list=WL" -o "%(playlist)s/%(playlist_index)s_%(upload_date)s - %(title)s [%(id)s].%(ext)s" --match-filter "availability != public" --datebefore 20170101 --playlist-items 1-1000 --cookies cookies.txt --ignore-config --remux-video mkv --no-continue --no-cache-dir --add-metadata --write-description --write-thumbnail --all-subs --write-info-json --embed-subs --embed-thumbnail --write-comments --download-archive ids.txt --min-sleep-interval 1 --max-sleep-interval 15 --verbose
[debug] Command-line config: ['https://www.youtube.com/playlist?list=WL', '-o', '%(playlist)s/%(playlist_index)s_%(upload_date)s - %(title)s [%(id)s].%(ext)s', '--match-filter', 'availability != public', '--datebefore', '20170101', '--playlist-items', '1-1000', '--cookies', 'cookies.txt', '--ignore-config', '--remux-video', 'mkv', '--no-continue', '--no-cache-dir', '--add-metadata', '--write-description', '--write-thumbnail', '--all-subs', '--write-info-json', '--embed-subs', '--embed-thumbnail', '--write-comments', '--download-archive', 'ids.txt', '--min-sleep-interval', '1', '--max-sleep-interval', '15', '--verbose']
[debug] Loading archive file 'ids.txt'
 
[debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] yt-dlp version 2021.07.07 (exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.19041-SP0
[debug] exe versions: ffmpeg 2021-07-04-git-301d275301-full_build-www.gyan.dev, ffprobe 2021-07-04-git-301d275301-full_build-www.gyan.dev
[debug] Proxy map: {}
[debug] [youtube:tab] Extracting URL: https://www.youtube.com/playlist?list=WL
[youtube:tab] WL: Downloading webpage
[debug] [youtube:tab] Final URL: https://www.youtube.com/playlist?list=WL
[youtube:tab] WL: Downloading API JSON with unavailable videos
WARNING: [youtube:tab] YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
[download] Downloading playlist: Watch later
[youtube:tab] WL page 1: Downloading API JSON
ERROR: YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "yt_dlp\YoutubeDL.py", line 1142, in wrapper
  File "yt_dlp\YoutubeDL.py", line 1178, in __extract_info
  File "yt_dlp\YoutubeDL.py", line 1287, in process_ie_result
  File "yt_dlp\YoutubeDL.py", line 1369, in __process_playlist
  File "yt_dlp\utils.py", line 4019, in __getitem__
  File "yt_dlp\extractor\youtube.py", line 3948, in _smuggle_data
  File "yt_dlp\extractor\youtube.py", line 3661, in _entries
  File "yt_dlp\extractor\youtube.py", line 607, in _extract_response
  File "yt_dlp\extractor\youtube.py", line 568, in _extract_and_report_alerts
  File "yt_dlp\extractor\youtube.py", line 565, in _report_alerts
yt_dlp.utils.ExtractorError: YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
```
<!--
Do not remove the above ```
-->


## Description

<!--
Provide an explanation of your issue in an arbitrary form. Please make sure the description is worded well enough to be understood, see https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient. Provide any additional information, suggested solution and as much context and examples as possible.
If work on your issue requires account credentials please provide them or explain how one can obtain them.
-->

This is going to be quite a bit to explain, since like I've said, I was getting help on the youtube-dl subreddit. There were two people trying to help me out on the subreddit, and they were giving me potential solutions and commands to run to rule out any potential issues. However, I still kept getting the same errors, and I honestly don't know what I'm doing wrong.

[**Here is the thread that I've posted, which I feel may be really important to read through to get a sense of my issue.**](https://www.reddit.com/r/youtubedl/comments/ol2d4q/im_trying_to_download_unlisted_videos_in_my_watch/) Excuse the poor formatting of the logs, but I have them pasted in a notepad so I'll just post them again here. I know the title doesn't quite describe my issue, but after that one was solved, this issue started.

I'm trying to run a command to download the unlisted videos posted before 2017 in my Watch Later playlist. I've downloaded the recommended extension to get cookies, [Get cookies.txt](https://chrome.google.com/webstore/detail/get-cookiestxt/bgaddhkoddajcdgocldbbfleckgcbcid?hl=en). I've went on YouTube and exported the cookies. After putting --cookies and the path to the cookies in my config file in quotes, I've gotten an issue saying that the playlist didn't exist.
```
C:\Users\Victoria Redacted\Desktop\Desktop Misc\YouTube DL>yt-dlp "https://www.youtube.com/playlist?list=WL" -o "%(playlist)s [%(playlist_id)s]/%(playlist_index)s_%(upload_date)s - %(title)s [%(id)s].%(ext)s" --match-filter "availability != public" --datebefore 20170101 --playlist-items 1-1000
[youtube:tab] WL: Downloading webpage
[youtube:tab] WL: Downloading API JSON with unavailable videos
WARNING: [youtube:tab] YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
[download] Downloading playlist: Watch later
[youtube:tab] WL page 1: Downloading API JSON
ERROR: YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
```

I've tried re-exporting the cookies twice. It still gave me the same error. Werid, the subreddit mod, suggested that I try putting cookies.txt in the same folder as yt-dlp and then running the command `yt-dlp --ignore-config --cookies cookies.txt --get-title --playlist-end 1 "https://www.youtube.com/playlist?list=WL"` as a way to rule out potential issues. Oddly enough, it said that the playlist didn't exist, only to then print the title of the first video in my playlist in the command prompt. 

I tried running my command (the command I was trying to run) again only with --cookies in the config file (cookies.txt was still in the folder), only to get an error again. I tried to run the command without --cookies in the config file and only in the command, still an error.

I then tried running the command without [%(playlist_id)s] in the output title because I thought that maybe the issue came from the fact that the Watch Later playlist doesn't have an actual playlist ID. Still an error.

One user (colethedj) told me to check if the cookies file contained a SAPISID or __Secure-3PAPISID cookie. It had both when I checked. Then Werid told me to try running that --get-title command from earlier only with verbose. This is what I got:

```
C:\Users\Victoria Redacted\Desktop\Desktop Misc\YouTube DL>yt-dlp --ignore-config --cookies cookies.txt --get-title --playlist-end 1 --verbose "https://www.youtube.com/playlist?list=WL"
[debug] Command-line config: ['--ignore-config', '--cookies', 'cookies.txt', '--get-title', '--playlist-end', '1', '--verbose', 'https://www.youtube.com/playlist?list=WL']
[debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] yt-dlp version 2021.07.07 (exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.19041-SP0
[debug] exe versions: ffmpeg 2021-07-04-git-301d275301-full_build-www.gyan.dev, ffprobe 2021-07-04-git-301d275301-full_build-www.gyan.dev
[debug] Proxy map: {}
[debug] [youtube:tab] Extracting URL: https://www.youtube.com/playlist?list=WL
[youtube:tab] WL: Downloading webpage
[debug] [youtube:tab] Final URL: https://www.youtube.com/playlist?list=WL
[youtube:tab] WL: Downloading API JSON with unavailable videos
WARNING: [youtube:tab] YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
[download] Downloading playlist: Watch later
[youtube:tab] playlist Watch later: Downloading 1 videos
[download] Downloading video 1 of 1
[debug] [youtube] Extracting URL: FR9PFdL8d5Y
[youtube] FR9PFdL8d5Y: Downloading webpage
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, vcodec:vp9.2(10), acodec, filesize, fs_approx, tbr, vbr, abr, asr, proto, vext, aext, hasaud, source, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] FR9PFdL8d5Y: Downloading 1 format(s): 248+251
BLOODLINES EPISODE 1
```

Colethedj then told me to try running the command with `--print-traffic` and seeing if I could find `send: b'POST /youtubei/v1/browse?key=AIza` and, within that line, `Authorization: SAPISIDHASH XXXX_XXXXX...`. According to them, if neither of those lines were there, yt-dlp wasn't able to read the cookies file correctly. However, I was able to find both lines by using Ctrl-F. 

I'm getting the vibes that even the two users are completely stumped on what's going on, and they seem like they're very familiar with how yt-dlp works. Thus I decided to open an issue here, because I honestly don't know what the issue is and it's frustrating. I'm starting to think that this is a bug with yt-dlp and not something I've done wrong. 

Thanks in advance! Let me know if I need to clear anything up because this was kind of messy haha.
[youtube] Cannot access private playlist even when cookies are supplied
<!--

######################################################################
  WARNING!
  IGNORING THE FOLLOWING TEMPLATE WILL RESULT IN ISSUE CLOSED AS INCOMPLETE
######################################################################

-->


## Checklist

<!--
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of yt-dlp:
- First of, make sure you are using the latest version of yt-dlp. Run `yt-dlp --version` and ensure your version is 2021.07.07. If it's not, see https://github.com/yt-dlp/yt-dlp on how to update. Issues with outdated version will be REJECTED.
- Make sure that all provided video/audio/playlist URLs (if any) are alive and playable in a browser.
- Make sure that all URLs and arguments with special characters are properly quoted or escaped as explained in https://github.com/yt-dlp/yt-dlp.
- Search the bugtracker for similar issues: https://github.com/yt-dlp/yt-dlp. DO NOT post duplicates.
- Read bugs section in FAQ: https://github.com/yt-dlp/yt-dlp
- Finally, put x into all relevant boxes like this [x] (Dont forget to delete the empty space)
-->

- [x] I'm reporting a broken site support issue
- [x] I've verified that I'm running yt-dlp version **2021.07.07**
- [x] I've checked that all provided URLs are alive and playable in a browser
- [x] I've checked that all URLs and arguments with special characters are properly quoted or escaped
- [x] I've searched the bugtracker for similar bug reports including closed ones
- [x] I've read bugs section in FAQ


## Verbose log

<!--
Provide the complete verbose output of yt-dlp that clearly demonstrates the problem.
Add the `-v` flag to your command line you run yt-dlp with (`yt-dlp -v <your command line>`), copy the WHOLE output and insert it below. It should look similar to this:
 [debug] System config: []
 [debug] User config: []
 [debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKc']
 [debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
 [debug] yt-dlp version 2021.07.07
 [debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2
 [debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4
 [debug] Proxy map: {}
 <more lines>
-->

I'm not sure which log to post, as I've done multiple in an attempt to solve the issue, so I'll post my first encounter with the error first: ([Reddit comment](https://www.reddit.com/r/youtubedl/comments/ol2d4q/im_trying_to_download_unlisted_videos_in_my_watch/h5bq05i?utm_source=share&utm_medium=web2x&context=3)

```
C:\Users\Victoria Redacted\Desktop\Desktop Misc\YouTube DL>yt-dlp "https://www.youtube.com/playlist?list=WL" -o "%(playlist)s [%(playlist_id)s]/%(playlist_index)s_%(upload_date)s - %(title)s [%(id)s].%(ext)s" --match-filter "availability != public" --datebefore 20170101 --playlist-items 1-1000
[youtube:tab] WL: Downloading webpage
[youtube:tab] WL: Downloading API JSON with unavailable videos
WARNING: [youtube:tab] YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
[download] Downloading playlist: Watch later
[youtube:tab] WL page 1: Downloading API JSON
ERROR: YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
C:\Users\Victoria Redacted\Desktop\Desktop Misc\YouTube DL>yt-dlp --verbose
[debug] Portable config file: C:\Users\Victoria Redacted\Desktop\Desktop Misc\YouTube DL\yt-dlp.conf
[debug] Portable config: ['--remux-video', 'mkv', '--no-continue', '--no-cache-dir', '--add-metadata', '--write-description', '--write-thumbnail', '--all-subs', '--write-info-json', '--embed-subs', '--embed-thumbnail', '--download-archive', 'ids.txt', '--min-sleep-interval', '1', '--max-sleep-interval', '15', '--cookies', 'C:\\Users\\Victoria Redacted\\Downloads\\cookies.txt']
[debug] Home config file: yt-dlp.conf
[debug] Home config: ['--remux-video', 'mkv', '--no-continue', '--no-cache-dir', '--add-metadata', '--write-description', '--write-thumbnail', '--all-subs', '--write-info-json', '--embed-subs', '--embed-thumbnail', '--download-archive', 'ids.txt', '--min-sleep-interval', '1', '--max-sleep-interval', '15', '--cookies', 'C:\\Users\\Victoria Redacted\\Downloads\\cookies.txt']
[debug] Command-line config: ['--verbose']
[debug] Loading archive file 'ids.txt'

[debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] yt-dlp version 2021.07.07 (exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.19041-SP0
[debug] exe versions: ffmpeg 2021-07-04-git-301d275301-full_build-www.gyan.dev, ffprobe 2021-07-04-git-301d275301-full_build-www.gyan.dev
[debug] Proxy map: {}
Usage: yt-dlp [OPTIONS] URL [URL...]

yt-dlp: error: You must provide at least one URL.
Type yt-dlp --help to see a list of all options.
```

And here's one of my more recent attempts to run my command. As per one of the youtube-dl subreddit mods, I've tried to run it without using my config file and just putting all my options in my command. ([Reddit comment](https://www.reddit.com/r/youtubedl/comments/ol2d4q/im_trying_to_download_unlisted_videos_in_my_watch/h5c5hvd?utm_source=share&utm_medium=web2x&context=3))

```
C:\Users\Victoria Redacted\Desktop\Desktop Misc\YouTube DL>yt-dlp "https://www.youtube.com/playlist?list=WL" -o "%(playlist)s/%(playlist_index)s_%(upload_date)s - %(title)s [%(id)s].%(ext)s" --match-filter "availability != public" --datebefore 20170101 --playlist-items 1-1000 --cookies cookies.txt --ignore-config --remux-video mkv --no-continue --no-cache-dir --add-metadata --write-description --write-thumbnail --all-subs --write-info-json --embed-subs --embed-thumbnail --write-comments --download-archive ids.txt --min-sleep-interval 1 --max-sleep-interval 15 --verbose
[debug] Command-line config: ['https://www.youtube.com/playlist?list=WL', '-o', '%(playlist)s/%(playlist_index)s_%(upload_date)s - %(title)s [%(id)s].%(ext)s', '--match-filter', 'availability != public', '--datebefore', '20170101', '--playlist-items', '1-1000', '--cookies', 'cookies.txt', '--ignore-config', '--remux-video', 'mkv', '--no-continue', '--no-cache-dir', '--add-metadata', '--write-description', '--write-thumbnail', '--all-subs', '--write-info-json', '--embed-subs', '--embed-thumbnail', '--write-comments', '--download-archive', 'ids.txt', '--min-sleep-interval', '1', '--max-sleep-interval', '15', '--verbose']
[debug] Loading archive file 'ids.txt'
 
[debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] yt-dlp version 2021.07.07 (exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.19041-SP0
[debug] exe versions: ffmpeg 2021-07-04-git-301d275301-full_build-www.gyan.dev, ffprobe 2021-07-04-git-301d275301-full_build-www.gyan.dev
[debug] Proxy map: {}
[debug] [youtube:tab] Extracting URL: https://www.youtube.com/playlist?list=WL
[youtube:tab] WL: Downloading webpage
[debug] [youtube:tab] Final URL: https://www.youtube.com/playlist?list=WL
[youtube:tab] WL: Downloading API JSON with unavailable videos
WARNING: [youtube:tab] YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
[download] Downloading playlist: Watch later
[youtube:tab] WL page 1: Downloading API JSON
ERROR: YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "yt_dlp\YoutubeDL.py", line 1142, in wrapper
  File "yt_dlp\YoutubeDL.py", line 1178, in __extract_info
  File "yt_dlp\YoutubeDL.py", line 1287, in process_ie_result
  File "yt_dlp\YoutubeDL.py", line 1369, in __process_playlist
  File "yt_dlp\utils.py", line 4019, in __getitem__
  File "yt_dlp\extractor\youtube.py", line 3948, in _smuggle_data
  File "yt_dlp\extractor\youtube.py", line 3661, in _entries
  File "yt_dlp\extractor\youtube.py", line 607, in _extract_response
  File "yt_dlp\extractor\youtube.py", line 568, in _extract_and_report_alerts
  File "yt_dlp\extractor\youtube.py", line 565, in _report_alerts
yt_dlp.utils.ExtractorError: YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
```
<!--
Do not remove the above ```
-->


## Description

<!--
Provide an explanation of your issue in an arbitrary form. Please make sure the description is worded well enough to be understood, see https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient. Provide any additional information, suggested solution and as much context and examples as possible.
If work on your issue requires account credentials please provide them or explain how one can obtain them.
-->

This is going to be quite a bit to explain, since like I've said, I was getting help on the youtube-dl subreddit. There were two people trying to help me out on the subreddit, and they were giving me potential solutions and commands to run to rule out any potential issues. However, I still kept getting the same errors, and I honestly don't know what I'm doing wrong.

[**Here is the thread that I've posted, which I feel may be really important to read through to get a sense of my issue.**](https://www.reddit.com/r/youtubedl/comments/ol2d4q/im_trying_to_download_unlisted_videos_in_my_watch/) Excuse the poor formatting of the logs, but I have them pasted in a notepad so I'll just post them again here. I know the title doesn't quite describe my issue, but after that one was solved, this issue started.

I'm trying to run a command to download the unlisted videos posted before 2017 in my Watch Later playlist. I've downloaded the recommended extension to get cookies, [Get cookies.txt](https://chrome.google.com/webstore/detail/get-cookiestxt/bgaddhkoddajcdgocldbbfleckgcbcid?hl=en). I've went on YouTube and exported the cookies. After putting --cookies and the path to the cookies in my config file in quotes, I've gotten an issue saying that the playlist didn't exist.
```
C:\Users\Victoria Redacted\Desktop\Desktop Misc\YouTube DL>yt-dlp "https://www.youtube.com/playlist?list=WL" -o "%(playlist)s [%(playlist_id)s]/%(playlist_index)s_%(upload_date)s - %(title)s [%(id)s].%(ext)s" --match-filter "availability != public" --datebefore 20170101 --playlist-items 1-1000
[youtube:tab] WL: Downloading webpage
[youtube:tab] WL: Downloading API JSON with unavailable videos
WARNING: [youtube:tab] YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
[download] Downloading playlist: Watch later
[youtube:tab] WL page 1: Downloading API JSON
ERROR: YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
```

I've tried re-exporting the cookies twice. It still gave me the same error. Werid, the subreddit mod, suggested that I try putting cookies.txt in the same folder as yt-dlp and then running the command `yt-dlp --ignore-config --cookies cookies.txt --get-title --playlist-end 1 "https://www.youtube.com/playlist?list=WL"` as a way to rule out potential issues. Oddly enough, it said that the playlist didn't exist, only to then print the title of the first video in my playlist in the command prompt. 

I tried running my command (the command I was trying to run) again only with --cookies in the config file (cookies.txt was still in the folder), only to get an error again. I tried to run the command without --cookies in the config file and only in the command, still an error.

I then tried running the command without [%(playlist_id)s] in the output title because I thought that maybe the issue came from the fact that the Watch Later playlist doesn't have an actual playlist ID. Still an error.

One user (colethedj) told me to check if the cookies file contained a SAPISID or __Secure-3PAPISID cookie. It had both when I checked. Then Werid told me to try running that --get-title command from earlier only with verbose. This is what I got:

```
C:\Users\Victoria Redacted\Desktop\Desktop Misc\YouTube DL>yt-dlp --ignore-config --cookies cookies.txt --get-title --playlist-end 1 --verbose "https://www.youtube.com/playlist?list=WL"
[debug] Command-line config: ['--ignore-config', '--cookies', 'cookies.txt', '--get-title', '--playlist-end', '1', '--verbose', 'https://www.youtube.com/playlist?list=WL']
[debug] Encodings: locale cp1252, fs utf-8, out utf-8, pref cp1252
[debug] yt-dlp version 2021.07.07 (exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.19041-SP0
[debug] exe versions: ffmpeg 2021-07-04-git-301d275301-full_build-www.gyan.dev, ffprobe 2021-07-04-git-301d275301-full_build-www.gyan.dev
[debug] Proxy map: {}
[debug] [youtube:tab] Extracting URL: https://www.youtube.com/playlist?list=WL
[youtube:tab] WL: Downloading webpage
[debug] [youtube:tab] Final URL: https://www.youtube.com/playlist?list=WL
[youtube:tab] WL: Downloading API JSON with unavailable videos
WARNING: [youtube:tab] YouTube said: The playlist does not exist.; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
[download] Downloading playlist: Watch later
[youtube:tab] playlist Watch later: Downloading 1 videos
[download] Downloading video 1 of 1
[debug] [youtube] Extracting URL: FR9PFdL8d5Y
[youtube] FR9PFdL8d5Y: Downloading webpage
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, vcodec:vp9.2(10), acodec, filesize, fs_approx, tbr, vbr, abr, asr, proto, vext, aext, hasaud, source, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] FR9PFdL8d5Y: Downloading 1 format(s): 248+251
BLOODLINES EPISODE 1
```

Colethedj then told me to try running the command with `--print-traffic` and seeing if I could find `send: b'POST /youtubei/v1/browse?key=AIza` and, within that line, `Authorization: SAPISIDHASH XXXX_XXXXX...`. According to them, if neither of those lines were there, yt-dlp wasn't able to read the cookies file correctly. However, I was able to find both lines by using Ctrl-F. 

I'm getting the vibes that even the two users are completely stumped on what's going on, and they seem like they're very familiar with how yt-dlp works. Thus I decided to open an issue here, because I honestly don't know what the issue is and it's frustrating. I'm starting to think that this is a bug with yt-dlp and not something I've done wrong. 

Thanks in advance! Let me know if I need to clear anything up because this was kind of messy haha.


Discussion:
Another thing to check, if you don't mind:
1. open up YouTube on your browser, logged in.
2. open up dev console (F12) and navigate to network tab. Type `youtubei` in the filter and click `XHR`
3. click on a video
4. in the network activity you should see a request like `?player=Alza...`. Click on that
5. In the headers pane scroll down to "Request Headers" check for an Authorization header
6. Check for if it starts with SAPISIDHASH, if it exists. Let me know if otherwise.

![image](https://user-images.githubusercontent.com/27879174/126019152-da6076bb-1a2c-4b4b-9dfc-3021d08555c0.png)

I have in fact been following the thread on reddit, and @colethedj is the one who rewrote the whole auth process last time youtube broke it, so he does know what he's talking about

> I still kept getting the same errors, and I honestly don't know what I'm doing wrong.

You are not doing anything wrong. There is some issue with how the auth is being handled, but the issue is that I can't reproduce the issue and I assume neither can @colethedj. Hence why we are asking you to try various things so that we can figure out what is going on

It would probably be much easier for both sides if you could give your cookies so that we can do the test ourselves. You can DM it to either me or @colethedj on reddit/discord
> yt-dlp --ignore-config --cookies cookies.txt --get-title --playlist-end 1 "https://www.youtube.com/playlist?list=WL" as a way to rule out potential issues. Oddly enough, it said that the playlist didn't exist, only to then print the title of the first video in my playlist in the command prompt.

This happened because yt-dlp is able to get the first page of videos (~100 vids) even with broken auth. So if you want to download just the first 100, you can use `--playlist-end 100` for the time being
Another thing to check, if you don't mind:
1. open up YouTube on your browser, logged in.
2. open up dev console (F12) and navigate to network tab. Type `youtubei` in the filter and click `XHR`
3. click on a video
4. in the network activity you should see a request like `?player=Alza...`. Click on that
5. In the headers pane scroll down to "Request Headers" check for an Authorization header
6. Check for if it starts with SAPISIDHASH, if it exists. Let me know if otherwise.

![image](https://user-images.githubusercontent.com/27879174/126019152-da6076bb-1a2c-4b4b-9dfc-3021d08555c0.png)

I have in fact been following the thread on reddit, and @colethedj is the one who rewrote the whole auth process last time youtube broke it, so he does know what he's talking about

> I still kept getting the same errors, and I honestly don't know what I'm doing wrong.

You are not doing anything wrong. There is some issue with how the auth is being handled, but the issue is that I can't reproduce the issue and I assume neither can @colethedj. Hence why we are asking you to try various things so that we can figure out what is going on

It would probably be much easier for both sides if you could give your cookies so that we can do the test ourselves. You can DM it to either me or @colethedj on reddit/discord
> yt-dlp --ignore-config --cookies cookies.txt --get-title --playlist-end 1 "https://www.youtube.com/playlist?list=WL" as a way to rule out potential issues. Oddly enough, it said that the playlist didn't exist, only to then print the title of the first video in my playlist in the command prompt.

This happened because yt-dlp is able to get the first page of videos (~100 vids) even with broken auth. So if you want to download just the first 100, you can use `--playlist-end 100` for the time being

Resolving patch:
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -533,7 +533,9 @@ def _generate_api_headers(self, ytcfg=None, identity_token=None, account_syncid=
             headers['X-Youtube-Identity-Token'] = identity_token
         if account_syncid:
             headers['X-Goog-PageId'] = account_syncid
-            headers['X-Goog-AuthUser'] = 0
+        session_index = try_get(ytcfg, lambda x: x['SESSION_INDEX'], compat_str)
+        if account_syncid or session_index:
+            headers['X-Goog-AuthUser'] = session_index or 0
         if visitor_data:
             headers['X-Goog-Visitor-Id'] = visitor_data
         auth = self._generate_sapisidhash_header(origin)


Test patch: