We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
One seemingly random "Unsupported URL", while others works just fine

## Checklist

- [x] I'm reporting a broken site support
- [x] I've verified that I'm running youtube-dl version **2021.06.06**
- [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


```
youtube-dl -v -F  https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999a34/
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '-F', 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999a34/']
[debug] Encodings: locale cp65001, fs mbcs, out cp65001, pref cp65001
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.19041
[debug] exe versions: ffmpeg 4.2.3, ffprobe git-2019-12-17-bd83191
[debug] Proxy map: {}
[generic] 9999a34: Requesting header
WARNING: Falling back on generic information extractor.
[generic] 9999a34: Downloading webpage
[generic] 9999a34: Extracting information
ERROR: Unsupported URL: https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999a34/
Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 815, in wrapper
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\YoutubeDL.py", line 836, in __extract_info
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\extractor\common.py", line 534, in extract
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpkqxnwl31\build\youtube_dl\extractor\generic.py", line 3520, in _real_extract
youtube_dl.utils.UnsupportedError: Unsupported URL: https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999a34/

```


## Description

I'm getting " Unsupported URL" for this single link. Every other url I've tried from the nhk site (https://www3.nhk.or.jp/nhkworld/), formatted exactly like this one, downloads just fine.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `youtube_dl/extractor/nhk.py`
Content:
```
1 from __future__ import unicode_literals
2 
3 import re
4 
5 from .common import InfoExtractor
6 from ..utils import urljoin
7 
8 
9 class NhkBaseIE(InfoExtractor):
10     _API_URL_TEMPLATE = 'https://api.nhk.or.jp/nhkworld/%sod%slist/v7a/%s/%s/%s/all%s.json'
11     _BASE_URL_REGEX = r'https?://www3\.nhk\.or\.jp/nhkworld/(?P<lang>[a-z]{2})/ondemand'
12     _TYPE_REGEX = r'/(?P<type>video|audio)/'
13 
14     def _call_api(self, m_id, lang, is_video, is_episode, is_clip):
15         return self._download_json(
16             self._API_URL_TEMPLATE % (
17                 'v' if is_video else 'r',
18                 'clip' if is_clip else 'esd',
19                 'episode' if is_episode else 'program',
20                 m_id, lang, '/all' if is_video else ''),
21             m_id, query={'apikey': 'EJfK8jdS57GqlupFgAfAAwr573q01y6k'})['data']['episodes'] or []
22 
23     def _extract_episode_info(self, url, episode=None):
24         fetch_episode = episode is None
25         lang, m_type, episode_id = re.match(NhkVodIE._VALID_URL, url).groups()
26         if episode_id.isdigit():
27             episode_id = episode_id[:4] + '-' + episode_id[4:]
28 
29         is_video = m_type == 'video'
30         if fetch_episode:
31             episode = self._call_api(
32                 episode_id, lang, is_video, True, episode_id[:4] == '9999')[0]
33         title = episode.get('sub_title_clean') or episode['sub_title']
34 
35         def get_clean_field(key):
36             return episode.get(key + '_clean') or episode.get(key)
37 
38         series = get_clean_field('title')
39 
40         thumbnails = []
41         for s, w, h in [('', 640, 360), ('_l', 1280, 720)]:
42             img_path = episode.get('image' + s)
43             if not img_path:
44                 continue
45             thumbnails.append({
46                 'id': '%dp' % h,
47                 'height': h,
48                 'width': w,
49                 'url': 'https://www3.nhk.or.jp' + img_path,
50             })
51 
52         info = {
53             'id': episode_id + '-' + lang,
54             'title': '%s - %s' % (series, title) if series and title else title,
55             'description': get_clean_field('description'),
56             'thumbnails': thumbnails,
57             'series': series,
58             'episode': title,
59         }
60         if is_video:
61             vod_id = episode['vod_id']
62             info.update({
63                 '_type': 'url_transparent',
64                 'ie_key': 'Piksel',
65                 'url': 'https://player.piksel.com/v/refid/nhkworld/prefid/' + vod_id,
66                 'id': vod_id,
67             })
68         else:
69             if fetch_episode:
70                 audio_path = episode['audio']['audio']
71                 info['formats'] = self._extract_m3u8_formats(
72                     'https://nhkworld-vh.akamaihd.net/i%s/master.m3u8' % audio_path,
73                     episode_id, 'm4a', entry_protocol='m3u8_native',
74                     m3u8_id='hls', fatal=False)
75                 for f in info['formats']:
76                     f['language'] = lang
77             else:
78                 info.update({
79                     '_type': 'url_transparent',
80                     'ie_key': NhkVodIE.ie_key(),
81                     'url': url,
82                 })
83         return info
84 
85 
86 class NhkVodIE(NhkBaseIE):
87     _VALID_URL = r'%s%s(?P<id>\d{7}|[^/]+?-\d{8}-[0-9a-z]+)' % (NhkBaseIE._BASE_URL_REGEX, NhkBaseIE._TYPE_REGEX)
88     # Content available only for a limited period of time. Visit
89     # https://www3.nhk.or.jp/nhkworld/en/ondemand/ for working samples.
90     _TESTS = [{
91         # video clip
92         'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999011/',
93         'md5': '7a90abcfe610ec22a6bfe15bd46b30ca',
94         'info_dict': {
95             'id': 'a95j5iza',
96             'ext': 'mp4',
97             'title': "Dining with the Chef - Chef Saito's Family recipe: MENCHI-KATSU",
98             'description': 'md5:5aee4a9f9d81c26281862382103b0ea5',
99             'timestamp': 1565965194,
100             'upload_date': '20190816',
101         },
102     }, {
103         # audio clip
104         'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/r_inventions-20201104-1/',
105         'info_dict': {
106             'id': 'r_inventions-20201104-1-en',
107             'ext': 'm4a',
108             'title': "Japan's Top Inventions - Miniature Video Cameras",
109             'description': 'md5:07ea722bdbbb4936fdd360b6a480c25b',
110         },
111         'params': {
112             # m3u8 download
113             'skip_download': True,
114         },
115     }, {
116         'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/2015173/',
117         'only_matching': True,
118     }, {
119         'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/plugin-20190404-1/',
120         'only_matching': True,
121     }, {
122         'url': 'https://www3.nhk.or.jp/nhkworld/fr/ondemand/audio/plugin-20190404-1/',
123         'only_matching': True,
124     }, {
125         'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/j_art-20150903-1/',
126         'only_matching': True,
127     }]
128 
129     def _real_extract(self, url):
130         return self._extract_episode_info(url)
131 
132 
133 class NhkVodProgramIE(NhkBaseIE):
134     _VALID_URL = r'%s/program%s(?P<id>[0-9a-z]+)(?:.+?\btype=(?P<episode_type>clip|(?:radio|tv)Episode))?' % (NhkBaseIE._BASE_URL_REGEX, NhkBaseIE._TYPE_REGEX)
135     _TESTS = [{
136         # video program episodes
137         'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/video/japanrailway',
138         'info_dict': {
139             'id': 'japanrailway',
140             'title': 'Japan Railway Journal',
141         },
142         'playlist_mincount': 1,
143     }, {
144         # video program clips
145         'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/video/japanrailway/?type=clip',
146         'info_dict': {
147             'id': 'japanrailway',
148             'title': 'Japan Railway Journal',
149         },
150         'playlist_mincount': 5,
151     }, {
152         'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/video/10yearshayaomiyazaki/',
153         'only_matching': True,
154     }, {
155         # audio program
156         'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/audio/listener/',
157         'only_matching': True,
158     }]
159 
160     def _real_extract(self, url):
161         lang, m_type, program_id, episode_type = re.match(self._VALID_URL, url).groups()
162 
163         episodes = self._call_api(
164             program_id, lang, m_type == 'video', False, episode_type == 'clip')
165 
166         entries = []
167         for episode in episodes:
168             episode_path = episode.get('url')
169             if not episode_path:
170                 continue
171             entries.append(self._extract_episode_info(
172                 urljoin(url, episode_path), episode))
173 
174         program_title = None
175         if entries:
176             program_title = entries[0].get('series')
177 
178         return self.playlist_result(entries, program_id, program_title)
179
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/youtube_dl/extractor/nhk.py b/youtube_dl/extractor/nhk.py
--- a/youtube_dl/extractor/nhk.py
+++ b/youtube_dl/extractor/nhk.py
@@ -1,3 +1,4 @@
+# coding: utf-8
 from __future__ import unicode_literals
 
 import re
@@ -23,7 +24,7 @@
     def _extract_episode_info(self, url, episode=None):
         fetch_episode = episode is None
         lang, m_type, episode_id = re.match(NhkVodIE._VALID_URL, url).groups()
-        if episode_id.isdigit():
+        if len(episode_id) == 7:
             episode_id = episode_id[:4] + '-' + episode_id[4:]
 
         is_video = m_type == 'video'
@@ -84,7 +85,8 @@
 
 
 class NhkVodIE(NhkBaseIE):
-    _VALID_URL = r'%s%s(?P<id>\d{7}|[^/]+?-\d{8}-[0-9a-z]+)' % (NhkBaseIE._BASE_URL_REGEX, NhkBaseIE._TYPE_REGEX)
+    # the 7-character IDs can have alphabetic chars too: assume [a-z] rather than just [a-f], eg
+    _VALID_URL = r'%s%s(?P<id>[0-9a-z]{7}|[^/]+?-\d{8}-[0-9a-z]+)' % (NhkBaseIE._BASE_URL_REGEX, NhkBaseIE._TYPE_REGEX)
     # Content available only for a limited period of time. Visit
     # https://www3.nhk.or.jp/nhkworld/en/ondemand/ for working samples.
     _TESTS = [{
@@ -124,6 +126,19 @@
     }, {
         'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/j_art-20150903-1/',
         'only_matching': True,
+    }, {
+        # video, alphabetic character in ID #29670
+        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999a34/',
+        'only_matching': True,
+        'info_dict': {
+            'id': 'qfjay6cg',
+            'ext': 'mp4',
+            'title': 'DESIGN TALKS plus - Fishermen’s Finery',
+            'description': 'md5:8a8f958aaafb0d7cb59d38de53f1e448',
+            'thumbnail': r're:^https?:/(/[a-z0-9.-]+)+\.jpg\?w=1920&h=1080$',
+            'upload_date': '20210615',
+            'timestamp': 1623722008,
+        }
     }]
 
     def _real_extract(self, url):

{"golden_diff": "diff --git a/youtube_dl/extractor/nhk.py b/youtube_dl/extractor/nhk.py\n--- a/youtube_dl/extractor/nhk.py\n+++ b/youtube_dl/extractor/nhk.py\n@@ -1,3 +1,4 @@\n+# coding: utf-8\n from __future__ import unicode_literals\n \n import re\n@@ -23,7 +24,7 @@\n     def _extract_episode_info(self, url, episode=None):\n         fetch_episode = episode is None\n         lang, m_type, episode_id = re.match(NhkVodIE._VALID_URL, url).groups()\n-        if episode_id.isdigit():\n+        if len(episode_id) == 7:\n             episode_id = episode_id[:4] + '-' + episode_id[4:]\n \n         is_video = m_type == 'video'\n@@ -84,7 +85,8 @@\n \n \n class NhkVodIE(NhkBaseIE):\n-    _VALID_URL = r'%s%s(?P<id>\\d{7}|[^/]+?-\\d{8}-[0-9a-z]+)' % (NhkBaseIE._BASE_URL_REGEX, NhkBaseIE._TYPE_REGEX)\n+    # the 7-character IDs can have alphabetic chars too: assume [a-z] rather than just [a-f], eg\n+    _VALID_URL = r'%s%s(?P<id>[0-9a-z]{7}|[^/]+?-\\d{8}-[0-9a-z]+)' % (NhkBaseIE._BASE_URL_REGEX, NhkBaseIE._TYPE_REGEX)\n     # Content available only for a limited period of time. Visit\n     # https://www3.nhk.or.jp/nhkworld/en/ondemand/ for working samples.\n     _TESTS = [{\n@@ -124,6 +126,19 @@\n     }, {\n         'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/j_art-20150903-1/',\n         'only_matching': True,\n+    }, {\n+        # video, alphabetic character in ID #29670\n+        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999a34/',\n+        'only_matching': True,\n+        'info_dict': {\n+            'id': 'qfjay6cg',\n+            'ext': 'mp4',\n+            'title': 'DESIGN TALKS plus - Fishermen\u2019s Finery',\n+            'description': 'md5:8a8f958aaafb0d7cb59d38de53f1e448',\n+            'thumbnail': r're:^https?:/(/[a-z0-9.-]+)+\\.jpg\\?w=1920&h=1080$',\n+            'upload_date': '20210615',\n+            'timestamp': 1623722008,\n+        }\n     }]\n \n     def _real_extract(self, url):\n", "issue": "One seemingly random \"Unsupported URL\", while others works just fine\n\r\n## Checklist\r\n\r\n- [x] I'm reporting a broken site support\r\n- [x] I've verified that I'm running youtube-dl version **2021.06.06**\r\n- [x] I've checked that all provided URLs are alive and playable in a browser\r\n- [x] I've checked that all URLs and arguments with special characters are properly quoted or escaped\r\n- [x] I've searched the bugtracker for similar issues including closed ones\r\n\r\n\r\n## Verbose log\r\n\r\n\r\n```\r\nyoutube-dl -v -F  https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999a34/\r\n[debug] System config: []\r\n[debug] User config: []\r\n[debug] Custom config: []\r\n[debug] Command-line args: ['-v', '-F', 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999a34/']\r\n[debug] Encodings: locale cp65001, fs mbcs, out cp65001, pref cp65001\r\n[debug] youtube-dl version 2021.06.06\r\n[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.19041\r\n[debug] exe versions: ffmpeg 4.2.3, ffprobe git-2019-12-17-bd83191\r\n[debug] Proxy map: {}\r\n[generic] 9999a34: Requesting header\r\nWARNING: Falling back on generic information extractor.\r\n[generic] 9999a34: Downloading webpage\r\n[generic] 9999a34: Extracting information\r\nERROR: Unsupported URL: https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999a34/\r\nTraceback (most recent call last):\r\n  File \"C:\\Users\\dst\\AppData\\Roaming\\Build archive\\youtube-dl\\ytdl-org\\tmpkqxnwl31\\build\\youtube_dl\\YoutubeDL.py\", line 815, in wrapper\r\n  File \"C:\\Users\\dst\\AppData\\Roaming\\Build archive\\youtube-dl\\ytdl-org\\tmpkqxnwl31\\build\\youtube_dl\\YoutubeDL.py\", line 836, in __extract_info\r\n  File \"C:\\Users\\dst\\AppData\\Roaming\\Build archive\\youtube-dl\\ytdl-org\\tmpkqxnwl31\\build\\youtube_dl\\extractor\\common.py\", line 534, in extract\r\n  File \"C:\\Users\\dst\\AppData\\Roaming\\Build archive\\youtube-dl\\ytdl-org\\tmpkqxnwl31\\build\\youtube_dl\\extractor\\generic.py\", line 3520, in _real_extract\r\nyoutube_dl.utils.UnsupportedError: Unsupported URL: https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999a34/\r\n\r\n```\r\n\r\n\r\n## Description\r\n\r\nI'm getting \" Unsupported URL\" for this single link. Every other url I've tried from the nhk site (https://www3.nhk.or.jp/nhkworld/), formatted exactly like this one, downloads just fine.\r\n\n", "before_files": [{"content": "from __future__ import unicode_literals\n\nimport re\n\nfrom .common import InfoExtractor\nfrom ..utils import urljoin\n\n\nclass NhkBaseIE(InfoExtractor):\n    _API_URL_TEMPLATE = 'https://api.nhk.or.jp/nhkworld/%sod%slist/v7a/%s/%s/%s/all%s.json'\n    _BASE_URL_REGEX = r'https?://www3\\.nhk\\.or\\.jp/nhkworld/(?P<lang>[a-z]{2})/ondemand'\n    _TYPE_REGEX = r'/(?P<type>video|audio)/'\n\n    def _call_api(self, m_id, lang, is_video, is_episode, is_clip):\n        return self._download_json(\n            self._API_URL_TEMPLATE % (\n                'v' if is_video else 'r',\n                'clip' if is_clip else 'esd',\n                'episode' if is_episode else 'program',\n                m_id, lang, '/all' if is_video else ''),\n            m_id, query={'apikey': 'EJfK8jdS57GqlupFgAfAAwr573q01y6k'})['data']['episodes'] or []\n\n    def _extract_episode_info(self, url, episode=None):\n        fetch_episode = episode is None\n        lang, m_type, episode_id = re.match(NhkVodIE._VALID_URL, url).groups()\n        if episode_id.isdigit():\n            episode_id = episode_id[:4] + '-' + episode_id[4:]\n\n        is_video = m_type == 'video'\n        if fetch_episode:\n            episode = self._call_api(\n                episode_id, lang, is_video, True, episode_id[:4] == '9999')[0]\n        title = episode.get('sub_title_clean') or episode['sub_title']\n\n        def get_clean_field(key):\n            return episode.get(key + '_clean') or episode.get(key)\n\n        series = get_clean_field('title')\n\n        thumbnails = []\n        for s, w, h in [('', 640, 360), ('_l', 1280, 720)]:\n            img_path = episode.get('image' + s)\n            if not img_path:\n                continue\n            thumbnails.append({\n                'id': '%dp' % h,\n                'height': h,\n                'width': w,\n                'url': 'https://www3.nhk.or.jp' + img_path,\n            })\n\n        info = {\n            'id': episode_id + '-' + lang,\n            'title': '%s - %s' % (series, title) if series and title else title,\n            'description': get_clean_field('description'),\n            'thumbnails': thumbnails,\n            'series': series,\n            'episode': title,\n        }\n        if is_video:\n            vod_id = episode['vod_id']\n            info.update({\n                '_type': 'url_transparent',\n                'ie_key': 'Piksel',\n                'url': 'https://player.piksel.com/v/refid/nhkworld/prefid/' + vod_id,\n                'id': vod_id,\n            })\n        else:\n            if fetch_episode:\n                audio_path = episode['audio']['audio']\n                info['formats'] = self._extract_m3u8_formats(\n                    'https://nhkworld-vh.akamaihd.net/i%s/master.m3u8' % audio_path,\n                    episode_id, 'm4a', entry_protocol='m3u8_native',\n                    m3u8_id='hls', fatal=False)\n                for f in info['formats']:\n                    f['language'] = lang\n            else:\n                info.update({\n                    '_type': 'url_transparent',\n                    'ie_key': NhkVodIE.ie_key(),\n                    'url': url,\n                })\n        return info\n\n\nclass NhkVodIE(NhkBaseIE):\n    _VALID_URL = r'%s%s(?P<id>\\d{7}|[^/]+?-\\d{8}-[0-9a-z]+)' % (NhkBaseIE._BASE_URL_REGEX, NhkBaseIE._TYPE_REGEX)\n    # Content available only for a limited period of time. Visit\n    # https://www3.nhk.or.jp/nhkworld/en/ondemand/ for working samples.\n    _TESTS = [{\n        # video clip\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999011/',\n        'md5': '7a90abcfe610ec22a6bfe15bd46b30ca',\n        'info_dict': {\n            'id': 'a95j5iza',\n            'ext': 'mp4',\n            'title': \"Dining with the Chef - Chef Saito's Family recipe: MENCHI-KATSU\",\n            'description': 'md5:5aee4a9f9d81c26281862382103b0ea5',\n            'timestamp': 1565965194,\n            'upload_date': '20190816',\n        },\n    }, {\n        # audio clip\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/r_inventions-20201104-1/',\n        'info_dict': {\n            'id': 'r_inventions-20201104-1-en',\n            'ext': 'm4a',\n            'title': \"Japan's Top Inventions - Miniature Video Cameras\",\n            'description': 'md5:07ea722bdbbb4936fdd360b6a480c25b',\n        },\n        'params': {\n            # m3u8 download\n            'skip_download': True,\n        },\n    }, {\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/2015173/',\n        'only_matching': True,\n    }, {\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/plugin-20190404-1/',\n        'only_matching': True,\n    }, {\n        'url': 'https://www3.nhk.or.jp/nhkworld/fr/ondemand/audio/plugin-20190404-1/',\n        'only_matching': True,\n    }, {\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/j_art-20150903-1/',\n        'only_matching': True,\n    }]\n\n    def _real_extract(self, url):\n        return self._extract_episode_info(url)\n\n\nclass NhkVodProgramIE(NhkBaseIE):\n    _VALID_URL = r'%s/program%s(?P<id>[0-9a-z]+)(?:.+?\\btype=(?P<episode_type>clip|(?:radio|tv)Episode))?' % (NhkBaseIE._BASE_URL_REGEX, NhkBaseIE._TYPE_REGEX)\n    _TESTS = [{\n        # video program episodes\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/video/japanrailway',\n        'info_dict': {\n            'id': 'japanrailway',\n            'title': 'Japan Railway Journal',\n        },\n        'playlist_mincount': 1,\n    }, {\n        # video program clips\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/video/japanrailway/?type=clip',\n        'info_dict': {\n            'id': 'japanrailway',\n            'title': 'Japan Railway Journal',\n        },\n        'playlist_mincount': 5,\n    }, {\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/video/10yearshayaomiyazaki/',\n        'only_matching': True,\n    }, {\n        # audio program\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/audio/listener/',\n        'only_matching': True,\n    }]\n\n    def _real_extract(self, url):\n        lang, m_type, program_id, episode_type = re.match(self._VALID_URL, url).groups()\n\n        episodes = self._call_api(\n            program_id, lang, m_type == 'video', False, episode_type == 'clip')\n\n        entries = []\n        for episode in episodes:\n            episode_path = episode.get('url')\n            if not episode_path:\n                continue\n            entries.append(self._extract_episode_info(\n                urljoin(url, episode_path), episode))\n\n        program_title = None\n        if entries:\n            program_title = entries[0].get('series')\n\n        return self.playlist_result(entries, program_id, program_title)\n", "path": "youtube_dl/extractor/nhk.py"}], "after_files": [{"content": "# coding: utf-8\nfrom __future__ import unicode_literals\n\nimport re\n\nfrom .common import InfoExtractor\nfrom ..utils import urljoin\n\n\nclass NhkBaseIE(InfoExtractor):\n    _API_URL_TEMPLATE = 'https://api.nhk.or.jp/nhkworld/%sod%slist/v7a/%s/%s/%s/all%s.json'\n    _BASE_URL_REGEX = r'https?://www3\\.nhk\\.or\\.jp/nhkworld/(?P<lang>[a-z]{2})/ondemand'\n    _TYPE_REGEX = r'/(?P<type>video|audio)/'\n\n    def _call_api(self, m_id, lang, is_video, is_episode, is_clip):\n        return self._download_json(\n            self._API_URL_TEMPLATE % (\n                'v' if is_video else 'r',\n                'clip' if is_clip else 'esd',\n                'episode' if is_episode else 'program',\n                m_id, lang, '/all' if is_video else ''),\n            m_id, query={'apikey': 'EJfK8jdS57GqlupFgAfAAwr573q01y6k'})['data']['episodes'] or []\n\n    def _extract_episode_info(self, url, episode=None):\n        fetch_episode = episode is None\n        lang, m_type, episode_id = re.match(NhkVodIE._VALID_URL, url).groups()\n        if len(episode_id) == 7:\n            episode_id = episode_id[:4] + '-' + episode_id[4:]\n\n        is_video = m_type == 'video'\n        if fetch_episode:\n            episode = self._call_api(\n                episode_id, lang, is_video, True, episode_id[:4] == '9999')[0]\n        title = episode.get('sub_title_clean') or episode['sub_title']\n\n        def get_clean_field(key):\n            return episode.get(key + '_clean') or episode.get(key)\n\n        series = get_clean_field('title')\n\n        thumbnails = []\n        for s, w, h in [('', 640, 360), ('_l', 1280, 720)]:\n            img_path = episode.get('image' + s)\n            if not img_path:\n                continue\n            thumbnails.append({\n                'id': '%dp' % h,\n                'height': h,\n                'width': w,\n                'url': 'https://www3.nhk.or.jp' + img_path,\n            })\n\n        info = {\n            'id': episode_id + '-' + lang,\n            'title': '%s - %s' % (series, title) if series and title else title,\n            'description': get_clean_field('description'),\n            'thumbnails': thumbnails,\n            'series': series,\n            'episode': title,\n        }\n        if is_video:\n            vod_id = episode['vod_id']\n            info.update({\n                '_type': 'url_transparent',\n                'ie_key': 'Piksel',\n                'url': 'https://player.piksel.com/v/refid/nhkworld/prefid/' + vod_id,\n                'id': vod_id,\n            })\n        else:\n            if fetch_episode:\n                audio_path = episode['audio']['audio']\n                info['formats'] = self._extract_m3u8_formats(\n                    'https://nhkworld-vh.akamaihd.net/i%s/master.m3u8' % audio_path,\n                    episode_id, 'm4a', entry_protocol='m3u8_native',\n                    m3u8_id='hls', fatal=False)\n                for f in info['formats']:\n                    f['language'] = lang\n            else:\n                info.update({\n                    '_type': 'url_transparent',\n                    'ie_key': NhkVodIE.ie_key(),\n                    'url': url,\n                })\n        return info\n\n\nclass NhkVodIE(NhkBaseIE):\n    # the 7-character IDs can have alphabetic chars too: assume [a-z] rather than just [a-f], eg\n    _VALID_URL = r'%s%s(?P<id>[0-9a-z]{7}|[^/]+?-\\d{8}-[0-9a-z]+)' % (NhkBaseIE._BASE_URL_REGEX, NhkBaseIE._TYPE_REGEX)\n    # Content available only for a limited period of time. Visit\n    # https://www3.nhk.or.jp/nhkworld/en/ondemand/ for working samples.\n    _TESTS = [{\n        # video clip\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999011/',\n        'md5': '7a90abcfe610ec22a6bfe15bd46b30ca',\n        'info_dict': {\n            'id': 'a95j5iza',\n            'ext': 'mp4',\n            'title': \"Dining with the Chef - Chef Saito's Family recipe: MENCHI-KATSU\",\n            'description': 'md5:5aee4a9f9d81c26281862382103b0ea5',\n            'timestamp': 1565965194,\n            'upload_date': '20190816',\n        },\n    }, {\n        # audio clip\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/r_inventions-20201104-1/',\n        'info_dict': {\n            'id': 'r_inventions-20201104-1-en',\n            'ext': 'm4a',\n            'title': \"Japan's Top Inventions - Miniature Video Cameras\",\n            'description': 'md5:07ea722bdbbb4936fdd360b6a480c25b',\n        },\n        'params': {\n            # m3u8 download\n            'skip_download': True,\n        },\n    }, {\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/2015173/',\n        'only_matching': True,\n    }, {\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/plugin-20190404-1/',\n        'only_matching': True,\n    }, {\n        'url': 'https://www3.nhk.or.jp/nhkworld/fr/ondemand/audio/plugin-20190404-1/',\n        'only_matching': True,\n    }, {\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/j_art-20150903-1/',\n        'only_matching': True,\n    }, {\n        # video, alphabetic character in ID #29670\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999a34/',\n        'only_matching': True,\n        'info_dict': {\n            'id': 'qfjay6cg',\n            'ext': 'mp4',\n            'title': 'DESIGN TALKS plus - Fishermen\u2019s Finery',\n            'description': 'md5:8a8f958aaafb0d7cb59d38de53f1e448',\n            'thumbnail': r're:^https?:/(/[a-z0-9.-]+)+\\.jpg\\?w=1920&h=1080$',\n            'upload_date': '20210615',\n            'timestamp': 1623722008,\n        }\n    }]\n\n    def _real_extract(self, url):\n        return self._extract_episode_info(url)\n\n\nclass NhkVodProgramIE(NhkBaseIE):\n    _VALID_URL = r'%s/program%s(?P<id>[0-9a-z]+)(?:.+?\\btype=(?P<episode_type>clip|(?:radio|tv)Episode))?' % (NhkBaseIE._BASE_URL_REGEX, NhkBaseIE._TYPE_REGEX)\n    _TESTS = [{\n        # video program episodes\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/video/japanrailway',\n        'info_dict': {\n            'id': 'japanrailway',\n            'title': 'Japan Railway Journal',\n        },\n        'playlist_mincount': 1,\n    }, {\n        # video program clips\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/video/japanrailway/?type=clip',\n        'info_dict': {\n            'id': 'japanrailway',\n            'title': 'Japan Railway Journal',\n        },\n        'playlist_mincount': 5,\n    }, {\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/video/10yearshayaomiyazaki/',\n        'only_matching': True,\n    }, {\n        # audio program\n        'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/program/audio/listener/',\n        'only_matching': True,\n    }]\n\n    def _real_extract(self, url):\n        lang, m_type, program_id, episode_type = re.match(self._VALID_URL, url).groups()\n\n        episodes = self._call_api(\n            program_id, lang, m_type == 'video', False, episode_type == 'clip')\n\n        entries = []\n        for episode in episodes:\n            episode_path = episode.get('url')\n            if not episode_path:\n                continue\n            entries.append(self._extract_episode_info(\n                urljoin(url, episode_path), episode))\n\n        program_title = None\n        if entries:\n            program_title = entries[0].get('series')\n\n        return self.playlist_result(entries, program_id, program_title)\n", "path": "youtube_dl/extractor/nhk.py"}]}