Repository: yt-dlp/yt-dlp

Issue:
trtcocuk.net.tr
### Checklist

- [x] I'm reporting a broken site
- [X] I've verified that I'm running yt-dlp version **2022.02.04**. ([update instructions](https://github.com/yt-dlp/yt-dlp#update))
- [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](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

Turkey

### Description

When try to get video from yt-dlp gives error about bad request.

ERROR: [generic] Unable to download webpage: HTTP Error 400: Bad Request

### Verbose log

```shell
da@ffof:~$ yt-dlp -vU https://www.trtcocuk.net.tr/video/kaptan-pengu-ve-arkadaslari-1
[debug] Command-line config: ['-vU', 'https://www.trtcocuk.net.tr/video/kaptan-pengu-ve-arkadaslari-1']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, err utf-8, pref UTF-8
[debug] yt-dlp version 2022.02.04 [c1653e9ef] (zip)
[debug] Python version 3.9.7 (CPython 64bit) - Linux-5.15.15-76051515-generic-x86_64-with-glibc2.34
[debug] exe versions: ffmpeg 4.4 (setts), ffprobe 4.4, rtmpdump 2.4
[debug] Optional libraries: Cryptodome, secretstorage, sqlite
[debug] Proxy map: {}
Latest version: 2022.02.04, Current version: 2022.02.04
yt-dlp is up to date (2022.02.04)
[debug] [generic] Extracting URL: https://www.trtcocuk.net.tr/video/kaptan-pengu-ve-arkadaslari-1
[generic] kaptan-pengu-ve-arkadaslari-1: Requesting header
WARNING: [generic] Falling back on generic information extractor.
[generic] kaptan-pengu-ve-arkadaslari-1: Downloading webpage
[generic] kaptan-pengu-ve-arkadaslari-1: Extracting information
[debug] Looking for video embeds
[debug] Identified a twitter:player iframe
[debug] [generic] Extracting URL: https://trtcanlitv-lh.akamaihd.net/i/TRTCOCUK_1@181844/master.m3u8
[generic] master: Requesting header
WARNING: [generic] Could not send HEAD request to https://trtcanlitv-lh.akamaihd.net/i/TRTCOCUK_1@181844/master.m3u8: HTTP Error 400: Bad Request
[generic] master: Downloading webpage
ERROR: [generic] Unable to download webpage: HTTP Error 400: Bad Request (caused by <HTTPError 400: 'Bad Request'>); please report this issue on  https://github.com/yt-dlp/yt-dlp , filling out the "Broken site" issue template properly. Confirm you are on the latest version using -U (caused by <HTTPError 400: 'Bad Request'>); please report this issue on  https://github.com/yt-dlp/yt-dlp , filling out the "Broken site" issue template properly. Confirm you are on the latest version using -U
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/common.py", line 730, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 3558, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
```



Discussion:
The video actually is in a `script` tag that contain `window.__NUXT__`. In there, we can get the parse the `data` as json and get the video url from there

Here's a part of json:
```
{
  return {
    layout: "default",
    data: [{
      data: {
        id: 3789738,
        type: h,
        title: aP,
        description: aP,
        mainImageUrl: "https:\u002F\u002Fcdn-i.pr.trt.com.tr\u002Ftrtcocuk\u002F9742474.jpeg",
        contentFormat: "Episode",
        show: [{
          logo: i,
          backgroundImage: j,
          artWork: k,
          mobileCover: l,
          title: g,
          description: m,
          type: n,
          path: o,
          contentId: p,
          badge: b,
          badgeEndTime: b
        }],
        season: 1,
        episodeNo: b,
        video: "https:\u002F\u002Fcdn-v.pr.trt.com.tr\u002Ftrtcocuk\u002Fwebsite\u002Fdfafe719-302b-4597-a863-8cf3b095df2e\u002Fmaster.m3u8",
        path: aQ,
        tags: b,
        publishedDate: "2020-12-09T11:36:14.162Z",
        otherVideos: [{
          id: 7305087,
          type: h,
          title: "Kaptan Pengu ve Arkadaşları 42. Bölüm - Siyah Kar",
          mainImageUrl: "https:\u002F\u002Fcdn-i.pr.trt.com.tr\u002Ftrtcocuk\u002F13386126.jpeg",
          show: [{
            logo: i,
            backgroundImage: j,
            artWork: k,
            mobileCover: l,
            title: g,
            description: m,
            type: n,
            path: o,
            contentId: p,
            badge: b,
            badgeEndTime: b
          }],
          video: "https:\u002F\u002Fcdn-v.pr.trt.com.tr\u002Ftrtcocuk\u002Fwebsite\u002F9d010078-be7e-4300-8c46-30173a04913b\u002Fmaster.m3u8",
          path: "\u002Fvideo\u002Fkaptan-pengu-ve-arkadaslari-42-bolum-siyah-kar",
          publishedDate: "2022-06-03T12:03:58.477Z"
        }, ...

```

Resolving patch:
diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py
--- a/yt_dlp/extractor/_extractors.py
+++ b/yt_dlp/extractor/_extractors.py
@@ -1838,6 +1838,7 @@
     TrovoChannelVodIE,
     TrovoChannelClipIE,
 )
+from .trtcocuk import TrtCocukVideoIE
 from .trueid import TrueIDIE
 from .trunews import TruNewsIE
 from .truth import TruthIE
diff --git a/yt_dlp/extractor/trtcocuk.py b/yt_dlp/extractor/trtcocuk.py
new file mode 100644
--- /dev/null
+++ b/yt_dlp/extractor/trtcocuk.py
@@ -0,0 +1,48 @@
+from .common import InfoExtractor
+from ..utils import ExtractorError, int_or_none, parse_iso8601, traverse_obj
+
+
+class TrtCocukVideoIE(InfoExtractor):
+    _VALID_URL = r'https?://www\.trtcocuk\.net\.tr/video/(?P<id>[\w-]+)'
+    _TESTS = [{
+        'url': 'https://www.trtcocuk.net.tr/video/kaptan-pengu-ve-arkadaslari-1',
+        'info_dict': {
+            'id': '3789738',
+            'ext': 'mp4',
+            'season_number': 1,
+            'series': '"Kaptan Pengu ve Arkadaşları"',
+            'season': 'Season 1',
+            'title': 'Kaptan Pengu ve Arkadaşları 1 Bölüm İzle TRT Çocuk',
+            'release_date': '20201209',
+            'release_timestamp': 1607513774,
+        }
+    }, {
+        'url': 'https://www.trtcocuk.net.tr/video/sef-rokanin-lezzet-dunyasi-17',
+        'info_dict': {
+            'id': '10260842',
+            'ext': 'mp4',
+            'series': '"Şef Roka\'nın Lezzet Dünyası"',
+            'title': 'Şef Roka\'nın Lezzet Dünyası 17 Bölüm İzle TRT Çocuk',
+        }
+    }]
+
+    def _real_extract(self, url):
+        display_id = self._match_id(url)
+        webpage = self._download_webpage(url, display_id)
+        nuxtjs_data = self._search_nuxt_data(webpage, display_id)['data']
+
+        try:
+            video_url = self._parse_json(nuxtjs_data['video'], display_id)
+        except ExtractorError:
+            video_url = nuxtjs_data['video']
+        formats, subtitles = self._extract_m3u8_formats_and_subtitles(video_url, display_id)
+
+        return {
+            'id': str(nuxtjs_data['id']),
+            'formats': formats,
+            'subtitles': subtitles,
+            'season_number': int_or_none(nuxtjs_data.get('season')),
+            'release_timestamp': parse_iso8601(nuxtjs_data.get('publishedDate')),
+            'series': traverse_obj(nuxtjs_data, ('show', 0, 'title')),
+            'title': self._html_extract_title(webpage)  # TODO: get better title
+        }


Test patch: