Repository: yt-dlp/yt-dlp

Issue:
Downloads from Nova Play / play.nova.bg are not working anymore
### Checklist

- [X] I'm reporting a broken site
- [X] I've verified that I'm running yt-dlp version **2022.07.18** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/ytdl-org/youtube-dl#video-url-contains-an-ampersand-and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [X] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

Bulgaria

### Provide a description that is worded well enough to be understood

Downloading videos from the Nova Play portal @ [play.nova.bg](https://play.nova.bg) (a Bulgarian TV channel) is no longer working. They are using JW Player 8.25.7 and this used to work last month (my latest download from there using yt-dlp was on the 17th of June).
Streamlink works fine and is able to download everything.
Since I am currently located there, I am not using a VPN (I think it's geoblocked otherwise), but I tested it with a Bulgarian server on ExpressVPN just to make sure and it makes no difference. 

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
[debug] Command-line config: ['-vU', '-F', 'https://play.nova.bg/video/zdravei-bulgariya/season-12/zdravei-2022-07-22/606608']
[debug] Encodings: locale cp1251, fs utf-8, pref cp1251, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.06.22.1 [a86e01e] (win32_exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.19044-SP0
[debug] Checking exe version: ffmpeg -bsfs
[debug] Checking exe version: ffprobe -bsfs
[debug] exe versions: ffmpeg 4.4-essentials_build-www.gyan.dev (setts), ffprobe 4.4-essentials_build-www.gyan.dev
[debug] Optional libraries: Cryptodome-3.14.1, brotli-1.0.9, certifi-2022.06.15, mutagen-1.45.1, sqlite3-2.6.0, websockets-10.3
[debug] Proxy map: {}
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2022.07.18, Current version: 2022.06.22.1
Current Build Hash 027c60e57aae7d5ab0604a19404e20935994ac2536a33ccb5cf5facae382bdfe
Updating to version 2022.07.18 ...
[debug] Downloading yt-dlp.exe from https://github.com/yt-dlp/yt-dlp/releases/download/2022.07.18/yt-dlp.exe
[debug] Downloading SHA2-256SUMS from https://github.com/yt-dlp/yt-dlp/releases/download/2022.07.18/SHA2-256SUMS
Updated yt-dlp to version 2022.07.18
[debug] Restarting: yt-dlp -vU -F "https://play.nova.bg/video/zdravei-bulgariya/season-12/zdravei-2022-07-22/606608"
[debug] Command-line config: ['-vU', '-F', 'https://play.nova.bg/video/zdravei-bulgariya/season-12/zdravei-2022-07-22/606608']
[debug] Encodings: locale cp1251, fs utf-8, pref cp1251, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.07.18 [135f05e] (win32_exe)
[debug] Python 3.8.10 (CPython 64bit) - Windows-10-10.0.19044-SP0
[debug] Checking exe version: ffmpeg -bsfs
[debug] Checking exe version: ffprobe -bsfs
[debug] exe versions: ffmpeg 4.4-essentials_build-www.gyan.dev (setts), ffprobe 4.4-essentials_build-www.gyan.dev
[debug] Optional libraries: Cryptodome-3.15.0, brotli-1.0.9, certifi-2022.06.15, mutagen-1.45.1, sqlite3-2.6.0, websockets-10.3
[debug] Proxy map: {}
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2022.07.18, Current version: 2022.07.18
yt-dlp is up to date (2022.07.18)
[debug] [NovaPlay] Extracting URL: https://play.nova.bg/video/zdravei-bulgariya/season-12/zdravei-2022-07-22/606608
[NovaPlay] 606608: Downloading webpage
[NovaPlay] 606608: Downloading JSON metadata
ERROR: [NovaPlay] 606608: Unable to download JSON metadata: HTTP Error 401: Unauthorized (caused by <HTTPError 401: 'Unauthorized'>); please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  File "yt_dlp\extractor\common.py", line 644, in extract
  File "yt_dlp\extractor\novaplay.py", line 44, in _real_extract
  File "yt_dlp\extractor\common.py", line 1004, in download_content
  File "yt_dlp\extractor\common.py", line 968, in download_handle
  File "yt_dlp\extractor\common.py", line 838, in _download_webpage_handle
  File "yt_dlp\extractor\common.py", line 795, in _request_webpage

  File "yt_dlp\extractor\common.py", line 777, in _request_webpage
  File "yt_dlp\YoutubeDL.py", line 3639, in urlopen
  File "urllib\request.py", line 531, in open
  File "urllib\request.py", line 640, in http_response
  File "urllib\request.py", line 569, in error
  File "urllib\request.py", line 502, in _call_chain
  File "urllib\request.py", line 649, in http_error_default
urllib.error.HTTPError: HTTP Error 401: Unauthorized
```



Discussion:

Resolving patch:
diff --git a/yt_dlp/extractor/novaplay.py b/yt_dlp/extractor/novaplay.py
--- a/yt_dlp/extractor/novaplay.py
+++ b/yt_dlp/extractor/novaplay.py
@@ -6,44 +6,54 @@ class NovaPlayIE(InfoExtractor):
     _VALID_URL = r'https://play.nova\.bg/video/.*/(?P<id>\d+)'
     _TESTS = [
         {
-            'url': 'https://play.nova.bg/video/bratya/season-3/bratq-2021-10-08/548677',
-            'md5': 'b1127a84e61bed1632b7c2ca9cbb4153',
+            'url': 'https://play.nova.bg/video/ochakvaite/season-0/ochakvaite-2022-07-22-sybudi-se-sat/606627',
+            'md5': 'd79dff2d09d196c595a7290f48e33399',
             'info_dict': {
-                'id': '548677',
+                'id': '606627',
                 'ext': 'mp4',
-                'title': 'Братя',
-                'alt_title': 'bratya/season-3/bratq-2021-10-08',
-                'duration': 1603.0,
-                'timestamp': 1633724150,
-                'upload_date': '20211008',
-                'thumbnail': 'https://nbg-img.fite.tv/img/548677_460x260.jpg',
-                'description': 'Сезон 3 Епизод 25'
+                'title': 'Събуди се - събота по NOVA (23.07.2022)',
+                'alt_title': 'ochakvaite/season-0/ochakvaite-2022-07-22-sybudi-se-sat',
+                'duration': 29.0,
+                'timestamp': 1658491547,
+                'upload_date': '20220722',
+                'thumbnail': 'https://nbg-img.fite.tv/img/606627_460x260.jpg',
+                'description': '29 сек',
+                'view_count': False
             },
         },
         {
-            'url': 'https://play.nova.bg/video/igri-na-volqta/season-3/igri-na-volqta-2021-09-20-1/548227',
-            'md5': '5fd61b8ecbe582fc021019d570965d58',
+            'url': 'https://play.nova.bg/video/ochakvaite/season-0/ochakvaite-2022-07-22-cherry-tazi/606609',
+            'md5': 'f3e973e2ed1a5b9b3f498b1ab82d01b3',
             'info_dict': {
-                'id': '548227',
+                'id': '606609',
                 'ext': 'mp4',
-                'title': 'Игри на волята: България (20.09.2021) - част 1',
-                'alt_title': 'gri-na-volqta/season-3/igri-na-volqta-2021-09-20-1',
-                'duration': 4060.0,
-                'timestamp': 1632167564,
-                'upload_date': '20210920',
-                'thumbnail': 'https://nbg-img.fite.tv/img/548227_460x260.jpg',
-                'description': 'Сезон 3 Епизод 13'
+                'title': 'Черешката на тортата - тази вечер по NOVA (22.07.2022)',
+                'alt_title': 'ochakvaite/season-0/ochakvaite-2022-07-22-cherry-tazi',
+                'duration': 29.0,
+                'timestamp': 1658476303,
+                'upload_date': '20220722',
+                'thumbnail': 'https://nbg-img.fite.tv/img/606609_460x260.jpg',
+                'description': '29 сек',
+                'view_count': False
             },
         }
     ]
 
+    _access_token = None
+
     def _real_extract(self, url):
         video_id = self._match_id(url)
         webpage = self._download_webpage(url, video_id)
+        self._access_token = self._access_token or self._download_json(
+            'https://play.nova.bg/api/client', None, note='Fetching access token')['accessToken']
         video_props = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['video']
         m3u8_url = self._download_json(
             f'https://nbg-api.fite.tv/api/v2/videos/{video_id}/streams',
-            video_id, headers={'x-flipps-user-agent': 'Flipps/75/9.7'})[0]['url']
+            video_id, headers={
+                'x-flipps-user-agent': 'Flipps/75/9.7',
+                'x-flipps-version': '2022-05-17',
+                'Authorization': f'Bearer {self._access_token}'
+            })[0]['links']['play']['href']
         formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', m3u8_id='hls')
         self._sort_formats(formats)
 


Test patch: