Repository: yt-dlp
Issue: Add support for niconico channel playlist
Labels: account-needed,site-enhancement,patch-available,needs-testing

### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

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

### Checklist

- [X] I'm requesting a site-specific feature
- [X] I've verified that I have **updated yt-dlp to nightly or master** ([update instructions](https://github.com/yt-dlp/yt-dlp#update-channels))
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and 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

_No response_

### Example URLs

https://ch.nicovideo.jp/tenshi-nano/video

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

Niconico has a channel subdomain `ch.niconico.jp` apart from its channelplus.
Support for `ch.niconico.jp` is missing.
Below is a PoC and someone with active niconico subscriptions may adopt (based on current Niconico extractor) and complete it.

```diff
diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py
index 583477b98..179c5db53 100644
--- a/yt_dlp/extractor/_extractors.py
+++ b/yt_dlp/extractor/_extractors.py
@@ -1286,6 +1286,7 @@
     NicovideoSearchIE,
     NicovideoSearchURLIE,
     NicovideoTagURLIE,
+    NiconicoChannelIE,
     NiconicoLiveIE,
 )
 from .ninaprotocol import NinaProtocolIE
diff --git a/yt_dlp/extractor/niconico.py b/yt_dlp/extractor/niconico.py
index b889c752c..5a51b7fd4 100644
--- a/yt_dlp/extractor/niconico.py
+++ b/yt_dlp/extractor/niconico.py
@@ -416,12 +416,27 @@ def _real_extract(self, url):
         def get_video_info(*items, get_first=True, **kwargs):
             return traverse_obj(api_data, ('video', *items), get_all=not get_first, **kwargs)
 
-        quality_info = api_data['media']['delivery']['movie']
-        session_api_data = quality_info['session']
-        for (audio_quality, video_quality, protocol) in itertools.product(quality_info['audios'], quality_info['videos'], session_api_data['protocols']):
-            fmt = self._extract_format_for_quality(video_id, audio_quality, video_quality, protocol)
-            if fmt:
-                formats.append(fmt)
+        if api_data['media']['delivery']:
+            quality_info = api_data['media']['delivery']['movie']
+            session_api_data = quality_info['session']
+            for (audio_quality, video_quality, protocol) in itertools.product(quality_info['audios'], quality_info['videos'], session_api_data['protocols']):
+                fmt = self._extract_format_for_quality(video_id, audio_quality, video_quality, protocol)
+                if fmt:
+                    formats.append(fmt)
+        else:
+            watch_id, track_id = traverse_obj(api_data, ('client', ('watchId', 'watchTrackId')))
+            access_key = api_data['media']['domand']['accessRightKey']
+            format_ids = traverse_obj(api_data, (
+                'media', 'domand', ('videos', 'audios'), lambda _, v: v['isAvailable'], 'id'))
+            for format_id in format_ids:
+                m3u8_formats = self._extract_m3u8_formats(self._download_json(
+                    f'https://nvapi.nicovideo.jp/v1/watch/{watch_id}/access-rights/hls?actionTrackId={track_id}',
+                    video_id, note=f'Downloading format {format_id}',
+                    headers={**self._API_HEADERS, 'x-request-with': 'https://www.nicovideo.jp',
+                             'x-access-right-key': access_key},
+                    data=json.dumps({"outputs": [[format_id]]}).encode()
+                )['data']['contentUrl'], video_id)
+                formats.extend([{**f, 'format_id': format_id} for f in m3u8_formats])

         # Start extracting information
         tags = None
@@ -829,6 +844,38 @@ def _real_extract(self, url):
         return self.playlist_result(self._entries(list_id), list_id, ie=NiconicoIE.ie_key())


+class NiconicoChannelIE(InfoExtractor):
+    IE_NAME = 'niconico:ch'
+    _VALID_URL = r'https://ch.nicovideo.jp/(?P<id>[\w-]+)(?:/video)?/?(?:$|[#?])'
+
+    def _entries(self, webpage, channel_id):
+        total_pages = max(map(int, re.findall(
+            r'<option value="(\d+)"',
+            self._search_regex(r'<li class="pages">\s*<select[^>]+>([\s\S]*?)</select>', webpage, 'pages')
+        )))
+        for page_num in range(1, total_pages + 1):
+            if page_num > 1:
+                webpage = self._download_webpage(
+                    f'https://ch.nicovideo.jp/{channel_id}/video?page={page_num}',
+                    channel_id, f'Downloading video page {page_num}')
+            for match in re.finditer(
+                r'<div class="item_right">\s*<h6 class="title">\s*<a href="([^"]+)"[^<]+</a>\s*</h6>', webpage
+            ):
+                yield self.url_result(match[1])
+
+    def _real_extract(self, url):
+        channel_id = self._match_id(url)
+        if '/video' not in url:
+            self.to_screen(f'Downloading only videos on https://ch.nicovideo.jp/{channel_id}/video')
+        webpage = self._download_webpage(
+            f'https://ch.nicovideo.jp/{channel_id}/video', channel_id, 'Downloading video page 1')
+        return self.playlist_result(self._entries(webpage, channel_id), channel_id, **{
+            'title': self._og_search_property('site_name', webpage, 'title'),
+            'description': self._og_search_description(webpage),
+            'thumbnail': self._og_search_thumbnail(webpage),
+        })
+
+
 ```

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [ ] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [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://ch.nicovideo.jp/tenshi-nano/video']
[debug] Encodings: locale cp936, fs utf-8, pref cp936, out utf-8, error utf-8, screen utf-8 
[debug] yt-dlp version stable@2024.03.10 from yt-dlp/yt-dlp [615a84447] (source) 
[debug] Lazy loading extractors is disabled
[debug] Git HEAD: 8463fb510 
[debug] Python 3.8.3 (CPython AMD64 64bit) - Windows-10-10.0.18362-SP0 (OpenSSL 1.1.1f  31 Mar 2020) 
[debug] exe versions: ffmpeg 4.4-full_build-www.gyan.dev (setts), ffprobe 4.4-full_build-www.gyan.dev, phantomjs 2.1.1 
[debug] Optional libraries: Cryptodome-3.16.0, brotli-1.0.9, certifi-2020.04.05.1, mutagen-1.46.0, requests-2.28.1, sqlite3-3.31.1, urllib3-1.25.9, websockets-10.2 
[debug] Proxy map: {}
[debug] Request Handlers: urllib
[debug] Loaded 1803 extractors 
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest 
Latest version: stable@2024.03.10 from yt-dlp/yt-dlp 
yt-dlp is up to date (stable@2024.03.10 from yt-dlp/yt-dlp)
[generic] Extracting URL: https://ch.nicovideo.jp/tenshi-nano/video 
[generic] video: Downloading webpage 
WARNING: [generic] Falling back on generic information extractor 
[generic] video: Extracting information
[debug] Looking for embeds
ERROR: Unsupported URL: https://ch.nicovideo.jp/tenshi-nano/video
Traceback (most recent call last):
  File "F:\cbasalt-github\yt-dlp\yt_dlp\YoutubeDL.py", line 1594, in wrapper
    return func(self, *args, **kwargs)
  File "F:\cbasalt-github\yt-dlp\yt_dlp\YoutubeDL.py", line 1729, in __extract_info
    ie_result = ie.extract(url)
  File "F:\cbasalt-github\yt-dlp\yt_dlp\extractor\common.py", line 732, in extract
    ie_result = self._real_extract(url)
  File "F:\cbasalt-github\yt-dlp\yt_dlp\extractor\generic.py", line 2530, in _real_extract
    raise UnsupportedError(url)
yt_dlp.utils.UnsupportedError: Unsupported URL: https://ch.nicovideo.jp/tenshi-nano/video
```