mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-07 20:30:41 -05:00
[niconico:tag] Add support for searching tags (#2789)
This commit is contained in:
parent
df635a09a4
commit
9a5b012575
2 changed files with 23 additions and 1 deletions
|
@ -1011,6 +1011,7 @@
|
|||
NicovideoSearchDateIE,
|
||||
NicovideoSearchIE,
|
||||
NicovideoSearchURLIE,
|
||||
NicovideoTagURLIE,
|
||||
)
|
||||
from .ninecninemedia import (
|
||||
NineCNineMediaIE,
|
||||
|
|
|
@ -663,6 +663,8 @@ def pagefunc(pagenum):
|
|||
|
||||
|
||||
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 @@ def _entries(self, url, item_id, query=None, note='Downloading page %(page)s'):
|
|||
|
||||
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 @@ def _get_entries_for_date(self, url, item_id, start_date, end_date=None, page_nu
|
|||
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<id>[^?#&]+)?'
|
||||
_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<id>\d+)/?(?:$|[#?])'
|
||||
_TEST = {
|
||||
|
|
Loading…
Reference in a new issue