Repository: yt-dlp/yt-dlp

Issue:
aitube.kz support
### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting a new site support request
- [X] I've verified that I'm running yt-dlp version **2022.11.11** ([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 none of provided URLs [violate any copyrights](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-website-primarily-used-for-piracy) or contain any [DRM](https://en.wikipedia.org/wiki/Digital_rights_management) to the best of my knowledge
- [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 am willing to share it if required

### Region

Kazakhstan

### Example URLs

https://aitube.page.link/x33Q
https://aitube.kz/video?id=9291d29b-c038-49a1-ad42-3da2051d353c&playlistId=d55b1f5f-ef2a-4f23-b646-2a86275b86b7&season=1

### Provide a description that is worded well enough to be understood

aitube.kz is not supported. I would like to ask if possible. Some videos may not open from other countries, but I watched through VPN from "France"

### 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', 'https://aitube.page.link/x33Q']
[debug] Home config "yt-dlp.conf": ['-o', 'E:/Downloads/%(title)s.%(ext)s']
[debug] Encodings: locale cp1251, fs utf-8, pref cp1251, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.11.11 [8b64402] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.22621-SP0 (OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: ffmpeg 2022-10-24-git-d79c240196-full_build-www.gyan.dev (setts), ffprobe 2022-10-24-git-d79c240196-full_build-www.gyan.dev
[debug] Optional libraries: Cryptodome-3.15.0, brotli-1.0.9, certifi-2022.09.24, mutagen-1.46.0, sqlite3-2.6.0, websockets-10.4
[debug] Proxy map: {}
[debug] Loaded 1723 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2022.11.11, Current version: 2022.11.11
yt-dlp is up to date (2022.11.11)
[debug] [generic] Extracting URL: https://aitube.page.link/x33Q
[generic] x33Q: Downloading webpage
[redirect] Following redirect to https://aitube.kz/video?id=b0292c2a-1ddb-4c35-9906-3b8d175ce0f0
[debug] [generic] Extracting URL: https://aitube.kz/video?id=b0292c2a-1ddb-4c35-9906-3b8d175ce0f0
[generic] video?id=b0292c2a-1ddb-4c35-9906-3b8d175ce0f0: Downloading webpage
WARNING: [generic] Falling back on generic information extractor
[generic] video?id=b0292c2a-1ddb-4c35-9906-3b8d175ce0f0: Extracting information
[debug] Looking for embeds
ERROR: Unsupported URL: https://aitube.kz/video?id=b0292c2a-1ddb-4c35-9906-3b8d175ce0f0
Traceback (most recent call last):
  File "yt_dlp\YoutubeDL.py", line 1485, in wrapper
  File "yt_dlp\YoutubeDL.py", line 1561, in __extract_info
  File "yt_dlp\extractor\common.py", line 674, in extract
  File "yt_dlp\extractor\generic.py", line 2721, in _real_extract
yt_dlp.utils.UnsupportedError: Unsupported URL: https://aitube.kz/video?id=b0292c2a-1ddb-4c35-9906-3b8d175ce0f0

PS C:\Users\sartu>
```



Discussion:
The video manifest can be found by request to `https://api-http.aitube.kz/kz.aitudala.aitube.staticaccess/video/<video_id>/video`. The metadata can be found with `__NEXT_DATA__` json

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
@@ -79,6 +79,7 @@
 )
 from .airmozilla import AirMozillaIE
 from .airtv import AirTVIE
+from .aitube import AitubeKZVideoIE
 from .aljazeera import AlJazeeraIE
 from .alphaporno import AlphaPornoIE
 from .amara import AmaraIE
diff --git a/yt_dlp/extractor/aitube.py b/yt_dlp/extractor/aitube.py
new file mode 100644
--- /dev/null
+++ b/yt_dlp/extractor/aitube.py
@@ -0,0 +1,60 @@
+from .common import InfoExtractor
+from ..utils import int_or_none, merge_dicts
+
+
+class AitubeKZVideoIE(InfoExtractor):
+    _VALID_URL = r'https?://aitube\.kz/(?:video|embed/)\?(?:[^\?]+)?id=(?P<id>[\w-]+)'
+    _TESTS = [{
+        # id paramater as first parameter
+        'url': 'https://aitube.kz/video?id=9291d29b-c038-49a1-ad42-3da2051d353c&playlistId=d55b1f5f-ef2a-4f23-b646-2a86275b86b7&season=1',
+        'info_dict': {
+            'id': '9291d29b-c038-49a1-ad42-3da2051d353c',
+            'ext': 'mp4',
+            'duration': 2174.0,
+            'channel_id': '94962f73-013b-432c-8853-1bd78ca860fe',
+            'like_count': int,
+            'channel': 'ASTANA TV',
+            'comment_count': int,
+            'view_count': int,
+            'description': 'Смотреть любимые сериалы и видео, поделиться видео и сериалами с друзьями и близкими',
+            'thumbnail': 'https://cdn.static02.aitube.kz/kz.aitudala.aitube.staticaccess/files/ddf2a2ff-bee3-409b-b5f2-2a8202bba75b',
+            'upload_date': '20221102',
+            'timestamp': 1667370519,
+            'title': 'Ангел хранитель 1 серия',
+            'channel_follower_count': int,
+        }
+    }, {
+        # embed url
+        'url': 'https://aitube.kz/embed/?id=9291d29b-c038-49a1-ad42-3da2051d353c',
+        'only_matching': True,
+    }, {
+        # id parameter is not as first paramater
+        'url': 'https://aitube.kz/video?season=1&id=9291d29b-c038-49a1-ad42-3da2051d353c&playlistId=d55b1f5f-ef2a-4f23-b646-2a86275b86b7',
+        'only_matching': True,
+    }]
+
+    def _real_extract(self, url):
+        video_id = self._match_id(url)
+        webpage = self._download_webpage(url, video_id)
+
+        nextjs_data = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['videoInfo']
+        json_ld_data = self._search_json_ld(webpage, video_id)
+
+        formats, subtitles = self._extract_m3u8_formats_and_subtitles(
+            f'https://api-http.aitube.kz/kz.aitudala.aitube.staticaccess/video/{video_id}/video', video_id)
+
+        return merge_dicts({
+            'id': video_id,
+            'title': nextjs_data.get('title') or self._html_search_meta(['name', 'og:title'], webpage),
+            'description': nextjs_data.get('description'),
+            'formats': formats,
+            'subtitles': subtitles,
+            'view_count': (nextjs_data.get('viewCount')
+                           or int_or_none(self._html_search_meta('ya:ovs:views_total', webpage))),
+            'like_count': nextjs_data.get('likeCount'),
+            'channel': nextjs_data.get('channelTitle'),
+            'channel_id': nextjs_data.get('channelId'),
+            'thumbnail': nextjs_data.get('coverUrl'),
+            'comment_count': nextjs_data.get('commentCount'),
+            'channel_follower_count': int_or_none(nextjs_data.get('channelSubscriberCount')),
+        }, json_ld_data)


Test patch: