Repository: youtube-dl
Issue: HTTP Error 401 when downloading playlist from ufcfightpass.com
Labels: account-needed

<!--

######################################################################
  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 youtube-dl:
- First of, make sure you are using the latest version of youtube-dl. Run `youtube-dl --version` and ensure your version is 2020.05.29. If it's not, see https://yt-dl.org/update 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 http://yt-dl.org/escape.
- Search the bugtracker for similar issues: http://yt-dl.org/search-issues. DO NOT post duplicates.
- Finally, put x into all relevant boxes (like this [x])
-->

- [x] I'm reporting a broken site support
- [x] I've verified that I'm running youtube-dl version **2020.05.29**
- [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 issues including closed ones


## Verbose log

<!--
Provide the complete verbose output of youtube-dl that clearly demonstrates the problem.
Add the `-v` flag to your command line you run youtube-dl with (`youtube-dl -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_jenozKcj']
 [debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
 [debug] youtube-dl version 2020.05.29
 [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>
-->

```
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '--write-sub', '--playlist-reverse', '-f', 'bestvideo[height<=?1300][container=mp4_dash]+bestaudio/best[height<=?1300]', '--fragment-retries=infinite', '--username', 'PRIVATE', '--password', 'PRIVATE', 'https://ufcfightpass.com/playlist/1861']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2020.05.29
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.18362
[debug] exe versions: ffmpeg 4.2.2, ffprobe 4.2.2
[debug] Proxy map: {}
[UFCTV] Logging in
[UFCTV] 1861: Downloading JSON metadata
[download] Downloading playlist: UFC 2005 REPLAYS
[UFCTV] playlist UFC 2005 REPLAYS: Collected 10 video ids (downloading 10 of them)
[download] Downloading video 1 of 10
[UFCTV] 32534: Downloading JSON metadata
[UFCTV] 32534: Downloading JSON metadata
[UFCTV] 32534: Downloading m3u8 information
[UFCTV] 32534: Downloading MPD manifest
[download] UFC 51 - Super Saturday-32534.mp4 has already been downloaded and merged
[download] Downloading video 2 of 10
[UFCTV] 31561: Downloading JSON metadata
[UFCTV] 31561: Downloading JSON metadata
[UFCTV] 31561: Downloading m3u8 information
[UFCTV] 31561: Downloading MPD manifest
[download] TUF 1 Finale - TUF 1 Finale-31561.mp4 has already been downloaded and merged
[download] Downloading video 3 of 10
[UFCTV] 30494: Downloading JSON metadata
[UFCTV] 30494: Downloading JSON metadata
[UFCTV] 30494: Downloading m3u8 information
[UFCTV] 30494: Downloading MPD manifest
[download] UFC 52 - Couture vs Liddell 2-30494.mp4 has already been downloaded and merged
[download] Downloading video 4 of 10
[UFCTV] 30482: Downloading JSON metadata
[UFCTV] 30482: Downloading JSON metadata
[UFCTV] 30482: Downloading m3u8 information
[UFCTV] 30482: Downloading MPD manifest
[debug] Invoking downloader on 'https://dve-streams.akamaized.net/MjAxOQ/Mw/M_TQ/NzE_0NzM/REFTSA/MQ/master.mpd?hdnea=exp=1590785870~acl=/MjAxOQ/Mw/M_TQ/NzE_0NzM/REFTSA/MQ/*~id=39ceb221-d55a-422e-aa34-cdaa59d51bb1~hmac=ad1e3ed84e6c09803dce4dc14f7b09dc9784b3d5c9df31d63a62a01e719bbe55'
[dashsegments] Total fragments: 1155
[download] Destination: UFC 53 - Heavy Hitters-30482.fdash-6.mp4
[download] 100% of 2.42GiB in 42:44
[debug] Invoking downloader on 'https://dve-streams.akamaized.net/MjAxOQ/Mw/M_TQ/NzE_0NzM/REFTSA/MQ/master.mpd?hdnea=exp=1590785870~acl=/MjAxOQ/Mw/M_TQ/NzE_0NzM/REFTSA/MQ/*~id=39ceb221-d55a-422e-aa34-cdaa59d51bb1~hmac=ad1e3ed84e6c09803dce4dc14f7b09dc9784b3d5c9df31d63a62a01e719bbe55'
[dashsegments] Total fragments: 1155
[download] Destination: UFC 53 - Heavy Hitters-30482.fdash-5.m4a
[download] 100% of 108.15MiB in 10:54
[ffmpeg] Merging formats into "UFC 53 - Heavy Hitters-30482.mp4"
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:UFC 53 - Heavy Hitters-30482.fdash-6.mp4" -i "file:UFC 53 - Heavy Hitters-30482.fdash-5.m4a" -c copy -map "0:v:0" -map "1:a:0" "file:UFC 53 - Heavy Hitters-30482.temp.mp4"
Deleting original file UFC 53 - Heavy Hitters-30482.fdash-6.mp4 (pass -k to keep)
Deleting original file UFC 53 - Heavy Hitters-30482.fdash-5.m4a (pass -k to keep)
[download] Downloading video 5 of 10
[UFCTV] 31195: Downloading JSON metadata
ERROR: Unable to download JSON metadata: HTTP Error 401: Unauthorized (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpxtvjzx45\build\youtube_dl\extractor\common.py", line 627, in _request_webpage
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpxtvjzx45\build\youtube_dl\YoutubeDL.py", line 2238, in urlopen
  File "C:\Python\Python34\lib\urllib\request.py", line 470, in open
  File "C:\Python\Python34\lib\urllib\request.py", line 580, in http_response
  File "C:\Python\Python34\lib\urllib\request.py", line 508, in error
  File "C:\Python\Python34\lib\urllib\request.py", line 442, in _call_chain
  File "C:\Python\Python34\lib\urllib\request.py", line 588, in http_error_default
```


## Description

<!--
Provide an explanation of your issue in an arbitrary form. 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.
-->

Fails with an HTTP Error 401 when trying to download a playlist, but it only happens after yt-dl finished downloading the previous video on the list.
Notice in the above log there's no problem going through the previously-downloaded videos (1st-3rd out of 10), there's no problem downloading a video which wasn't previously downloaded (4th), the error only comes up with the next one (5th).
Restarting yt-dl with the exact same command will do the same thing - it'll go through the list, skip the now-downloaded video (4th), download the one which yt-dl failed at (5th), and fail with the next one (6th out of 10).
Starting yt-dl with each specific video url instead of playlist url won't have this issue whether running in series or in parallel.
Happens from both ends of the list, as in with and without --playlist-reverse.

I suspect maybe the authentication gets dropped once yt-dl finishes downloading a video for some reason, and yt-dl would have to re-authenticate after every downloaded video in a list?

Edit: Forgot to provide example url:
https://ufcfightpass.com/playlist/1861
It happens with every playlist I tried there.