Compare commits

...

9 Commits

Author SHA1 Message Date
Han Hyeji
f593bb169b
Merge 1e4ea76441dd4a3d28cf8c5140ace7ae825b161a into 3eb8d22ddb8982ca4fb56bb7a8d6517538bf14c6 2025-04-01 09:14:48 +02:00
dirkf
3eb8d22ddb
[JSInterp] Temporary fix for #33102 2025-03-31 04:21:09 +01:00
dirkf
4e714f9df1 [Misc] Correct [_]IE_DESC/NAME in a few IEs
* thx seproDev, yt-dlp/yt-dlp/pull/12694/commits/ae69e3c
* also add documenting comment in `InfoExtractor`
2025-03-26 12:47:19 +00:00
dirkf
c1ea7f5a24 [ITV] Mark ITVX not working
* update old shim
* correct [_]IE_DESC
2025-03-26 12:17:49 +00:00
dirkf
1e4ea76441
Include NateProgramIE 2023-08-31 16:37:20 +01:00
dirkf
ba06388c8c
Update from yt-dlp extractor 2023-08-31 16:34:09 +01:00
Han Hyeji
8cf64dcbbf [nate] add new site 2021-12-07 19:09:23 +09:00
hyeeji
a0bb1d8c0d Feat:add Site 2021-12-07 13:18:15 +09:00
hyeeji
2b0623b116 Test 2021-12-07 03:11:01 +09:00
8 changed files with 210 additions and 15 deletions

View File

@ -32,7 +32,7 @@ class BokeCCBaseIE(InfoExtractor):
class BokeCCIE(BokeCCBaseIE): class BokeCCIE(BokeCCBaseIE):
_IE_DESC = 'CC视频' IE_DESC = 'CC视频'
_VALID_URL = r'https?://union\.bokecc\.com/playvideo\.bo\?(?P<query>.*)' _VALID_URL = r'https?://union\.bokecc\.com/playvideo\.bo\?(?P<query>.*)'
_TESTS = [{ _TESTS = [{

View File

@ -9,7 +9,7 @@ from ..utils import (
class CloudyIE(InfoExtractor): class CloudyIE(InfoExtractor):
_IE_DESC = 'cloudy.ec' IE_DESC = 'cloudy.ec'
_VALID_URL = r'https?://(?:www\.)?cloudy\.ec/(?:v/|embed\.php\?.*?\bid=)(?P<id>[A-Za-z0-9]+)' _VALID_URL = r'https?://(?:www\.)?cloudy\.ec/(?:v/|embed\.php\?.*?\bid=)(?P<id>[A-Za-z0-9]+)'
_TESTS = [{ _TESTS = [{
'url': 'https://www.cloudy.ec/v/af511e2527aac', 'url': 'https://www.cloudy.ec/v/af511e2527aac',

View File

@ -422,6 +422,8 @@ class InfoExtractor(object):
_GEO_COUNTRIES = None _GEO_COUNTRIES = None
_GEO_IP_BLOCKS = None _GEO_IP_BLOCKS = None
_WORKING = True _WORKING = True
# supply this in public subclasses: used in supported sites list, etc
# IE_DESC = 'short description of IE'
def __init__(self, downloader=None): def __init__(self, downloader=None):
"""Constructor. Receives an optional downloader.""" """Constructor. Receives an optional downloader."""

View File

@ -750,6 +750,10 @@ from .nationalgeographic import (
NationalGeographicVideoIE, NationalGeographicVideoIE,
NationalGeographicTVIE, NationalGeographicTVIE,
) )
from .nate import (
NateIE,
NateProgramIE,
)
from .naver import NaverIE from .naver import NaverIE
from .nba import ( from .nba import (
NBAWatchEmbedIE, NBAWatchEmbedIE,

View File

@ -35,15 +35,6 @@ from ..utils import (
class ITVBaseIE(InfoExtractor): class ITVBaseIE(InfoExtractor):
def _search_nextjs_data(self, webpage, video_id, **kw):
transform_source = kw.pop('transform_source', None)
fatal = kw.pop('fatal', True)
return self._parse_json(
self._search_regex(
r'''<script\b[^>]+\bid=('|")__NEXT_DATA__\1[^>]*>(?P<js>[^<]+)</script>''',
webpage, 'next.js data', group='js', fatal=fatal, **kw),
video_id, transform_source=transform_source, fatal=fatal)
def __handle_request_webpage_error(self, err, video_id=None, errnote=None, fatal=True): def __handle_request_webpage_error(self, err, video_id=None, errnote=None, fatal=True):
if errnote is False: if errnote is False:
return False return False
@ -109,7 +100,9 @@ class ITVBaseIE(InfoExtractor):
class ITVIE(ITVBaseIE): class ITVIE(ITVBaseIE):
_VALID_URL = r'https?://(?:www\.)?itv\.com/(?:(?P<w>watch)|hub)/[^/]+/(?(w)[\w-]+/)(?P<id>\w+)' _VALID_URL = r'https?://(?:www\.)?itv\.com/(?:(?P<w>watch)|hub)/[^/]+/(?(w)[\w-]+/)(?P<id>\w+)'
_IE_DESC = 'ITVX' IE_DESC = 'ITVX'
_WORKING = False
_TESTS = [{ _TESTS = [{
'note': 'Hub URLs redirect to ITVX', 'note': 'Hub URLs redirect to ITVX',
'url': 'https://www.itv.com/hub/liar/2a4547a0012', 'url': 'https://www.itv.com/hub/liar/2a4547a0012',
@ -270,7 +263,7 @@ class ITVIE(ITVBaseIE):
'ext': determine_ext(href, 'vtt'), 'ext': determine_ext(href, 'vtt'),
}) })
next_data = self._search_nextjs_data(webpage, video_id, fatal=False, default='{}') next_data = self._search_nextjs_data(webpage, video_id, fatal=False, default={})
video_data.update(traverse_obj(next_data, ('props', 'pageProps', ('title', 'episode')), expected_type=dict)[0] or {}) video_data.update(traverse_obj(next_data, ('props', 'pageProps', ('title', 'episode')), expected_type=dict)[0] or {})
title = traverse_obj(video_data, 'headerTitle', 'episodeTitle') title = traverse_obj(video_data, 'headerTitle', 'episodeTitle')
info = self._og_extract(webpage, require_title=not title) info = self._og_extract(webpage, require_title=not title)
@ -323,7 +316,7 @@ class ITVIE(ITVBaseIE):
class ITVBTCCIE(ITVBaseIE): class ITVBTCCIE(ITVBaseIE):
_VALID_URL = r'https?://(?:www\.)?itv\.com/(?!(?:watch|hub)/)(?:[^/]+/)+(?P<id>[^/?#&]+)' _VALID_URL = r'https?://(?:www\.)?itv\.com/(?!(?:watch|hub)/)(?:[^/]+/)+(?P<id>[^/?#&]+)'
_IE_DESC = 'ITV articles: News, British Touring Car Championship' IE_DESC = 'ITV articles: News, British Touring Car Championship'
_TESTS = [{ _TESTS = [{
'note': 'British Touring Car Championship', 'note': 'British Touring Car Championship',
'url': 'https://www.itv.com/btcc/articles/btcc-2018-all-the-action-from-brands-hatch', 'url': 'https://www.itv.com/btcc/articles/btcc-2018-all-the-action-from-brands-hatch',

View File

@ -0,0 +1,194 @@
# coding: utf-8
from __future__ import unicode_literals
import itertools
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
merge_dicts,
T,
traverse_obj,
txt_or_none,
unified_strdate,
url_or_none,
)
class NateBaseIE(InfoExtractor):
_API_BASE = 'https://tv.nate.com/api/v1/'
def _download_webpage_handle(self, url_or_request, video_id, *args, **kwargs):
fatal = kwargs.get('fatal', True)
kwargs['fatal'] = False
res = super(NateBaseIE, self)._download_webpage_handle(
url_or_request, video_id, *args, **kwargs)
if not res:
if fatal:
raise ExtractorError('Failed to download webpage')
return res
status = res[1].getcode()
if 200 <= status < 400:
new_url = res[1].geturl()
if url_or_request != new_url and '/Error.html' in new_url:
raise ExtractorError(
'Download redirected to Error.html: expired?',
expected=True)
else:
msg = 'Failed to download webpage: HTTP code %d' % status
if fatal:
raise ExtractorError(msg)
else:
self.report_warning(msg)
return res
class NateIE(NateBaseIE):
_VALID_URL = r'https?://(?:m\.)?tv\.nate\.com/clip/(?P<id>[0-9]+)'
_TESTS = [{
'url': 'https://tv.nate.com/clip/1848976',
'info_dict': {
'id': '1848976',
'ext': 'mp4',
'title': '[결승 오프닝 타이틀] 2018 LCK 서머 스플릿 결승전 kt Rolster VS Griffin',
'description': 'md5:e1b79a7dcf0d8d586443f11366f50e6f',
'thumbnail': r're:^http?://.*\.jpg$',
'upload_date': '20180908',
'age_limit': 15,
'duration': 73,
'uploader': '2018 LCK 서머 스플릿(롤챔스)',
'channel': '2018 LCK 서머 스플릿(롤챔스)',
'channel_id': '3606',
'uploader_id': '3606',
'tags': 'count:59',
},
'skip': 'Redirect to Error.html',
}, {
'url': 'https://tv.nate.com/clip/4300566',
# 'md5': '02D3CAB3907B60C58043761F8B5BF2B3',
'info_dict': {
'id': '4300566',
'ext': 'mp4',
'title': '[심쿵엔딩] 이준호x이세영, 서로를 기억하며 끌어안는 두 사람!💕, MBC 211204 방송',
'description': 'md5:edf489c54ea2682c7973154b2089aa0e',
'thumbnail': r're:^http?://.*\.jpg$',
'upload_date': '20211204',
'age_limit': 15,
'duration': 201,
'uploader': '옷소매 붉은 끝동',
'channel': '옷소매 붉은 끝동',
'channel_id': '27987',
'uploader_id': '27987',
'tags': 'count:20',
},
'params': {'skip_download': True},
}, {
'url': 'https://tv.nate.com/clip/4764792',
'info_dict': {
'id': '4764792',
'ext': 'mp4',
'title': '흥을 돋우는 가야금 연주와 트롯의 만남⬈ ‘열두줄’♪ TV CHOSUN 230625 방송',
'description': 'md5:85734d3f9daebe4aa4f20cc73bdcc90c',
'upload_date': '20230625',
'uploader_id': '29116',
'uploader': '쇼퀸',
'age_limit': 15,
'thumbnail': r're:^http?://.*\.jpg$',
'duration': 182,
'channel': '쇼퀸',
'channel_id': '29116',
'tags': 'count:25',
},
'params': {'skip_download': True},
}]
_QUALITY = {
'36': 2160,
'35': 1080,
'34': 720,
'33': 480,
'32': 360,
'31': 270,
}
def _real_extract(self, url):
video_id = self._match_id(url)
video_data, urlh = self._download_json_handle(
'{0}clip/{1}'.format(self._API_BASE, video_id), video_id,
fatal=False)
if not video_data:
raise ExtractorError('Empty programme JSON')
title = video_data['clipTitle']
formats = []
for f_url in traverse_obj(video_data, ('smcUriList', Ellipsis, T(url_or_none))):
fmt_id = f_url[-2:]
formats.append({
'format_id': fmt_id,
'url': f_url,
'height': self._QUALITY.get(fmt_id),
'quality': int_or_none(fmt_id),
})
self._sort_formats(formats)
info = traverse_obj(video_data, {
'uploader': ('programTitle', T(txt_or_none)),
'uploader_id': ('programSeq', T(txt_or_none)),
})
for up, ch in (('uploader', 'channel'), ('uploader_id', 'channel_id')):
info[ch] = info.get(up)
return merge_dicts({
'id': video_id,
'title': title,
'formats': formats,
}, info, traverse_obj(video_data, {
'description': ('synopsis', T(txt_or_none)),
'thumbnail': ('contentImg', T(url_or_none)),
'upload_date': (('broadDate', 'regDate'), T(unified_strdate)),
'age_limit': ('targetAge', T(int_or_none)),
'duration': ('playTime', T(int_or_none)),
'tags': ('hashTag', T(lambda s: s.split(',') or None)),
}, get_all=False))
class NateProgramIE(NateBaseIE):
_VALID_URL = r'https?://tv\.nate\.com/program/clips/(?P<id>[0-9]+)'
_TESTS = [{
'url': 'https://tv.nate.com/program/clips/27987',
'playlist_mincount': 191,
'info_dict': {
'id': '27987',
},
}, {
'url': 'https://tv.nate.com/program/clips/3606',
'playlist_mincount': 15,
'info_dict': {
'id': '3606',
},
'skip': 'Redirect to Error.html',
}]
def _entries(self, pl_id):
for page_num in itertools.count(1):
program_data, urlh = self._download_json_handle(
'{0}program/{1}/clip/ranking'.format(self._API_BASE, pl_id),
pl_id, query={'size': 20, 'page': page_num},
note='Downloading page {0}'.format(page_num), fatal=False)
empty = True
for clip_id in traverse_obj(program_data, ('content', Ellipsis, 'clipSeq', T(txt_or_none))):
yield self.url_result(
'https://tv.nate.com/clip/%s' % clip_id,
ie=NateIE.ie_key(), video_id=clip_id)
empty = False
if traverse_obj(program_data, 'last') or (program_data and empty):
break
def _real_extract(self, url):
pl_id = self._match_id(url)
return self.playlist_result(self._entries(pl_id), playlist_id=pl_id)

View File

@ -47,7 +47,7 @@ class SenateISVPIE(InfoExtractor):
['vetaff', '76462', 'http://vetaff-f.akamaihd.net'], ['vetaff', '76462', 'http://vetaff-f.akamaihd.net'],
['arch', '', 'http://ussenate-f.akamaihd.net/'] ['arch', '', 'http://ussenate-f.akamaihd.net/']
] ]
_IE_NAME = 'senate.gov' IE_NAME = 'senate.gov'
_VALID_URL = r'https?://(?:www\.)?senate\.gov/isvp/?\?(?P<qs>.+)' _VALID_URL = r'https?://(?:www\.)?senate\.gov/isvp/?\?(?P<qs>.+)'
_TESTS = [{ _TESTS = [{
'url': 'http://www.senate.gov/isvp/?comm=judiciary&type=live&stt=&filename=judiciary031715&auto_play=false&wmode=transparent&poster=http%3A%2F%2Fwww.judiciary.senate.gov%2Fthemes%2Fjudiciary%2Fimages%2Fvideo-poster-flash-fit.png', 'url': 'http://www.senate.gov/isvp/?comm=judiciary&type=live&stt=&filename=judiciary031715&auto_play=false&wmode=transparent&poster=http%3A%2F%2Fwww.judiciary.senate.gov%2Fthemes%2Fjudiciary%2Fimages%2Fvideo-poster-flash-fit.png',

View File

@ -686,6 +686,8 @@ class JSInterpreter(object):
raise self.Exception('Cannot get index {idx!r:.100}'.format(**locals()), expr=repr(obj), cause=e) raise self.Exception('Cannot get index {idx!r:.100}'.format(**locals()), expr=repr(obj), cause=e)
def _dump(self, obj, namespace): def _dump(self, obj, namespace):
if obj is JS_Undefined:
return 'undefined'
try: try:
return json.dumps(obj) return json.dumps(obj)
except TypeError: except TypeError: