From 9a5b0125752179f6447ca29deb89ee452fd78b85 Mon Sep 17 00:00:00 2001 From: "Lesmiscore (Naoya Ozaki)" Date: Wed, 16 Feb 2022 02:12:39 +0900 Subject: [PATCH] [niconico:tag] Add support for searching tags (#2789) --- yt_dlp/extractor/extractors.py | 1 + yt_dlp/extractor/niconico.py | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/yt_dlp/extractor/extractors.py b/yt_dlp/extractor/extractors.py index e4dc35f71..c3f3eb974 100644 --- a/yt_dlp/extractor/extractors.py +++ b/yt_dlp/extractor/extractors.py @@ -1011,6 +1011,7 @@ from .niconico import ( NicovideoSearchDateIE, NicovideoSearchIE, NicovideoSearchURLIE, + NicovideoTagURLIE, ) from .ninecninemedia import ( NineCNineMediaIE, diff --git a/yt_dlp/extractor/niconico.py b/yt_dlp/extractor/niconico.py index ee888e9d3..6e561bee5 100644 --- a/yt_dlp/extractor/niconico.py +++ b/yt_dlp/extractor/niconico.py @@ -663,6 +663,8 @@ class NiconicoPlaylistIE(InfoExtractor): class NicovideoSearchBaseIE(InfoExtractor): + _SEARCH_TYPE = 'search' + def _entries(self, url, item_id, query=None, note='Downloading page %(page)s'): query = query or {} pages = [query['page']] if 'page' in query else itertools.count(1) @@ -677,7 +679,7 @@ class NicovideoSearchBaseIE(InfoExtractor): def _search_results(self, query): return self._entries( - self._proto_relative_url(f'//www.nicovideo.jp/search/{query}'), query) + self._proto_relative_url(f'//www.nicovideo.jp/{self._SEARCH_TYPE}/{query}'), query) class NicovideoSearchIE(NicovideoSearchBaseIE, SearchInfoExtractor): @@ -757,6 +759,25 @@ class NicovideoSearchDateIE(NicovideoSearchBaseIE, SearchInfoExtractor): yield from super()._entries(url, item_id, query=query, note=note) +class NicovideoTagURLIE(NicovideoSearchBaseIE): + IE_NAME = 'niconico:tag' + IE_DESC = 'NicoNico video tag URLs' + _SEARCH_TYPE = 'tag' + _VALID_URL = r'https?://(?:www\.)?nicovideo\.jp/tag/(?P[^?#&]+)?' + _TESTS = [{ + 'url': 'https://www.nicovideo.jp/tag/ドキュメンタリー淫夢', + 'info_dict': { + 'id': 'ドキュメンタリー淫夢', + 'title': 'ドキュメンタリー淫夢' + }, + 'playlist_mincount': 400, + }] + + def _real_extract(self, url): + query = self._match_id(url) + return self.playlist_result(self._entries(url, query), query, query) + + class NiconicoUserIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?nicovideo\.jp/user/(?P\d+)/?(?:$|[#?])' _TEST = {