Repository: yt-dlp/yt-dlp

Issue:
[TVer] Some URLs are not recognized
### Checklist

- [X] I'm reporting a broken site
- [X] I've verified that I'm running yt-dlp version **2022.05.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

Japan

### Description

TVer Extractor may not recognize some URLs.
for ex.
https://tver.jp/episodes/epm8kjl7ze
https://tver.jp/episodes/epmf7b32xx

The URL in question can be opened in the browser without any problem, but yt-dlp will display "Not Found".
(This is at 17:00:00 on 6/8/2022)

### Verbose log

```shell
$ yt-dlp -vU https://tver.jp/episodes/epm8kjl7ze
[debug] Command-line config: ['-vU', 'https://tver.jp/episodes/epm8kjl7ze']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.05.18 [b14d52355]
[debug] Python version 3.8.10 (CPython 64bit) - Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29
[debug] Checking exe version: ffprobe -bsfs
[debug] Checking exe version: avprobe -bsfs
[debug] Checking exe version: ffmpeg -bsfs
[debug] Checking exe version: avconv -bsfs
[debug] exe versions: none
[debug] Optional libraries: Cryptodome-3.14.1, brotli-1.0.9, certifi-2019.11.28, mutagen-1.45.1, secretstorage-2.3.1, sqlite3-2.6.0, websockets-10.3
[debug] Proxy map: {}
Latest version: 2022.05.18, Current version: 2022.05.18
yt-dlp is up to date (2022.05.18)
[TVer] Creating session
[debug] [TVer] Extracting URL: https://tver.jp/episodes/epm8kjl7ze
[TVer] epm8kjl7ze: Downloading JSON metadata
[TVer] epm8kjl7ze: Downloading JSON metadata
[debug] [brightcove:new] Extracting URL: http://players.brightcove.net/6191645753001/default_default/index.html?videoId=ref:2302810259_20220604#__youtubedl_smuggle=%7B%22geo_countries%22%3A+%5B%22JP%22%5D%7D
[debug] Using fake IP 133.19.253.45 (JP) as X-Forwarded-For
[debug] Loading brightcove.6191645753001_default from cache
[brightcove:new] ref:2302810259_20220604: Downloading JSON metadata
ERROR: [brightcove:new] Unable to download JSON metadata: HTTP Error 404: Not Found (caused by <HTTPError 404: 'Not Found'>); 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 "/home/hide/.local/lib/python3.8/site-packages/yt_dlp/extractor/common.py", line 642, in extract
    ie_result = self._real_extract(url)
  File "/home/hide/.local/lib/python3.8/site-packages/yt_dlp/extractor/brightcove.py", line 648, in _real_extract
    json_data = self._download_json(api_url, video_id, headers=headers)
  File "/home/hide/.local/lib/python3.8/site-packages/yt_dlp/extractor/common.py", line 1030, in _download_json
    res = self._download_json_handle(
  File "/home/hide/.local/lib/python3.8/site-packages/yt_dlp/extractor/common.py", line 1009, in _download_json_handle
    res = self._download_webpage_handle(
  File "/home/hide/.local/lib/python3.8/site-packages/yt_dlp/extractor/adobepass.py", line 1364, in _download_webpage_handle
    return super(AdobePassIE, self)._download_webpage_handle(
  File "/home/hide/.local/lib/python3.8/site-packages/yt_dlp/extractor/common.py", line 801, in _download_webpage_handle
    urlh = self._request_webpage(url_or_request, video_id, note, errnote, fatal, data=data, headers=headers, query=query, expected_status=expected_status)
  File "/home/hide/.local/lib/python3.8/site-packages/yt_dlp/extractor/common.py", line 786, in _request_webpage
    raise ExtractorError(errmsg, cause=err)

  File "/home/hide/.local/lib/python3.8/site-packages/yt_dlp/extractor/common.py", line 768, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/home/hide/.local/lib/python3.8/site-packages/yt_dlp/YoutubeDL.py", line 3596, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
```



Discussion:

Resolving patch:
diff --git a/yt_dlp/extractor/tver.py b/yt_dlp/extractor/tver.py
--- a/yt_dlp/extractor/tver.py
+++ b/yt_dlp/extractor/tver.py
@@ -54,38 +54,41 @@ def _real_extract(self, url):
             video_id = self._match_id(self._search_regex(
                 (r'canonical"\s*href="(https?://tver\.jp/[^"]+)"', r'&link=(https?://tver\.jp/[^?&]+)[?&]'),
                 webpage, 'url regex'))
+
+        episode_info = self._download_json(
+            f'https://platform-api.tver.jp/service/api/v1/callEpisode/{video_id}?require_data=mylist,later[epefy106ur],good[epefy106ur],resume[epefy106ur]',
+            video_id, fatal=False,
+            query={
+                'platform_uid': self._PLATFORM_UID,
+                'platform_token': self._PLATFORM_TOKEN,
+            }, headers={
+                'x-tver-platform-type': 'web'
+            })
+        episode_content = traverse_obj(
+            episode_info, ('result', 'episode', 'content')) or {}
+
         video_info = self._download_json(
             f'https://statics.tver.jp/content/episode/{video_id}.json', video_id,
-            query={'v': '5'}, headers={
+            query={
+                'v': str_or_none(episode_content.get('version')) or '5',
+            }, headers={
                 'Origin': 'https://tver.jp',
                 'Referer': 'https://tver.jp/',
             })
         p_id = video_info['video']['accountID']
-        r_id = traverse_obj(video_info, ('video', ('videoRefID', 'videoID')), get_all=False)
+        r_id = traverse_obj(video_info, ('video', ('videoRefID', 'videoID')))
         if not r_id:
             raise ExtractorError('Failed to extract reference ID for Brightcove')
         if not r_id.isdigit():
             r_id = f'ref:{r_id}'
 
-        additional_info = self._download_json(
-            f'https://platform-api.tver.jp/service/api/v1/callEpisode/{video_id}?require_data=mylist,later[epefy106ur],good[epefy106ur],resume[epefy106ur]',
-            video_id, fatal=False,
-            query={
-                'platform_uid': self._PLATFORM_UID,
-                'platform_token': self._PLATFORM_TOKEN,
-            }, headers={
-                'x-tver-platform-type': 'web'
-            })
-
-        additional_content_info = traverse_obj(
-            additional_info, ('result', 'episode', 'content'), get_all=False) or {}
-        episode = strip_or_none(additional_content_info.get('title'))
-        series = str_or_none(additional_content_info.get('seriesTitle'))
+        episode = strip_or_none(episode_content.get('title'))
+        series = str_or_none(episode_content.get('seriesTitle'))
         title = (
             join_nonempty(series, episode, delim=' ')
             or str_or_none(video_info.get('title')))
-        provider = str_or_none(additional_content_info.get('productionProviderName'))
-        onair_label = str_or_none(additional_content_info.get('broadcastDateLabel'))
+        provider = str_or_none(episode_content.get('productionProviderName'))
+        onair_label = str_or_none(episode_content.get('broadcastDateLabel'))
 
         return {
             '_type': 'url_transparent',


Test patch: