1
1
mirror of https://github.com/ytdl-org/youtube-dl synced 2024-09-01 10:55:08 +02:00

Compare commits

...

8 Commits

4 changed files with 77 additions and 6 deletions

View File

@ -166,6 +166,14 @@ _NSIG_TESTS = [
'https://www.youtube.com/s/player/b22ef6e7/player_ias.vflset/en_US/base.js',
'b6HcntHGkvBLk_FRf', 'kNPW6A7FyP2l8A',
),
(
'https://www.youtube.com/s/player/3400486c/player_ias.vflset/en_US/base.js',
'lL46g3XifCKUZn1Xfw', 'z767lhet6V2Skl',
),
(
'https://www.youtube.com/s/player/5604538d/player_ias.vflset/en_US/base.js',
'7X-he4jjvMx7BCX', 'sViSydX8IHtdWA',
),
]

View File

@ -434,7 +434,10 @@ from .frontendmasters import (
FrontendMastersCourseIE
)
from .fujitv import FujiTVFODPlus7IE
from .funimation import FunimationIE
from .funimation import (
FunimationIE,
FunimationShowPlaylistIE
)
from .funk import FunkIE
from .fusion import FusionIE
from .gaia import GaiaIE

View File

@ -11,7 +11,8 @@ from ..utils import (
int_or_none,
js_to_json,
ExtractorError,
urlencode_postdata
urlencode_postdata,
urljoin
)
@ -156,3 +157,58 @@ class FunimationIE(InfoExtractor):
'season_id': title_data.get('seriesId'),
'formats': formats,
}
class FunimationShowPlaylistIE(FunimationIE):
IE_NAME = 'funimation:playlist'
_VALID_URL = r'https?://(?:www\.)?funimation(?:\.com|now\.uk)/(?:[^/]+/)?shows/(?P<id>[^/?#&]+)/?$'
_TESTS = [{
'url': 'https://www.funimation.com/shows/hacksign/',
'info_dict': {
'id': 90646,
'title': '.hack//SIGN'
},
'playlist_count': 28,
'params': {
'skip_download': True,
},
}, {
'url': 'https://www.funimationnow.uk/shows/puzzle-dragons-x/',
'only_matching': True,
}, {
# with lang code
'url': 'https://www.funimation.com/en/shows/hacksign/',
'only_matching': True,
}]
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
title_data = self._parse_json(self._search_regex(
r'TITLE_DATA\s*=\s*({[^}]+})',
webpage, 'title data', default=''),
display_id, js_to_json, fatal=False) or {}
items = self._download_json(
'https://prod-api-funimationnow.dadcdigital.com/api/funimation/episodes/?limit=99999&title_id=%s'
% title_data.get('id'), display_id).get('items')
vod_items = list(map(lambda k:
(k.get('mostRecentSvod') or k.get('mostRecentAvod'))
.get('item'), items))
vod_items = sorted(vod_items, key=lambda k: k.get('episodeOrder'))
entries = []
for vod_item in vod_items:
entries.append(
self.url_result(urljoin(url, vod_item.get('episodeSlug')),
'Funimation', vod_item.get('episodeId'),
vod_item.get('episodeSlug')))
return {
'_type': 'playlist',
'id': title_data.get('id'),
'title': title_data.get('title'),
'entries': entries,
}

View File

@ -1647,7 +1647,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
except JSInterpreter.Exception as e:
self.report_warning(
'%s (%s %s)' % (
'Unable to decode n-parameter: download likely to be throttled',
'Unable to decode n-parameter: expect download to be blocked or throttled',
error_to_compat_str(e),
traceback.format_exc()),
video_id=video_id)
@ -1659,18 +1659,22 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
def _extract_n_function_name(self, jscode):
func_name, idx = self._search_regex(
# new: (b=String.fromCharCode(110),c=a.get(b))&&c=nfunc[idx](c)
# or: (b="nn"[+a.D],c=a.get(b))&&(c=nfunc[idx](c)s
# old: .get("n"))&&(b=nfunc[idx](b)
# older: .get("n"))&&(b=nfunc(b)
r'''(?x)
(?:\(\s*(?P<b>[a-z])\s*=\s*String\s*\.\s*fromCharCode\s*\(\s*110\s*\)\s*,(?P<c>[a-z])\s*=\s*[a-z]\s*)?
\.\s*get\s*\(\s*(?(b)(?P=b)|"n")(?:\s*\)){2}\s*&&\s*\(\s*(?(c)(?P=c)|b)\s*=\s*
(?:\(\s*(?P<b>[a-z])\s*=\s*(?:
String\s*\.\s*fromCharCode\s*\(\s*110\s*\)|
"n+"\[\s*\+?s*[\w$.]+\s*]
)\s*,(?P<c>[a-z])\s*=\s*[a-z]\s*)?
\.\s*get\s*\(\s*(?(b)(?P=b)|"n{1,2}")(?:\s*\)){2}\s*&&\s*\(\s*(?(c)(?P=c)|b)\s*=\s*
(?P<nfunc>[a-zA-Z_$][\w$]*)(?:\s*\[(?P<idx>\d+)\])?\s*\(\s*[\w$]+\s*\)
''', jscode, 'Initial JS player n function name', group=('nfunc', 'idx'))
if not idx:
return func_name
return self._parse_json(self._search_regex(
r'var {0}\s*=\s*(\[.+?\])\s*[,;]'.format(re.escape(func_name)), jscode,
r'var\s+{0}\s*=\s*(\[.+?\])\s*[,;]'.format(re.escape(func_name)), jscode,
'Initial JS player n function list ({0}.{1})'.format(func_name, idx)),
func_name, transform_source=js_to_json)[int(idx)]