yahoo.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import hashlib
  4. import itertools
  5. import re
  6. from .common import InfoExtractor, SearchInfoExtractor
  7. from ..compat import (
  8. compat_str,
  9. compat_urllib_parse,
  10. )
  11. from ..utils import (
  12. clean_html,
  13. ExtractorError,
  14. int_or_none,
  15. mimetype2ext,
  16. parse_iso8601,
  17. smuggle_url,
  18. try_get,
  19. url_or_none,
  20. )
  21. from .brightcove import BrightcoveNewIE
  22. class YahooIE(InfoExtractor):
  23. IE_DESC = 'Yahoo screen and movies'
  24. _VALID_URL = r'(?P<url>https?://(?:(?P<country>[a-zA-Z]{2}(?:-[a-zA-Z]{2})?|malaysia)\.)?(?:[\da-zA-Z_-]+\.)?yahoo\.com/(?:[^/]+/)*(?P<id>[^?&#]*-[0-9]+(?:-[a-z]+)?)\.html)'
  25. _TESTS = [{
  26. 'url': 'http://screen.yahoo.com/julian-smith-travis-legg-watch-214727115.html',
  27. 'info_dict': {
  28. 'id': '2d25e626-2378-391f-ada0-ddaf1417e588',
  29. 'ext': 'mp4',
  30. 'title': 'Julian Smith & Travis Legg Watch Julian Smith',
  31. 'description': 'Julian and Travis watch Julian Smith',
  32. 'duration': 6863,
  33. 'timestamp': 1369812016,
  34. 'upload_date': '20130529',
  35. },
  36. }, {
  37. 'url': 'https://screen.yahoo.com/community/community-sizzle-reel-203225340.html?format=embed',
  38. 'md5': '7993e572fac98e044588d0b5260f4352',
  39. 'info_dict': {
  40. 'id': '4fe78544-8d48-39d8-97cd-13f205d9fcdb',
  41. 'ext': 'mp4',
  42. 'title': "Yahoo Saves 'Community'",
  43. 'description': 'md5:4d4145af2fd3de00cbb6c1d664105053',
  44. 'duration': 170,
  45. 'timestamp': 1406838636,
  46. 'upload_date': '20140731',
  47. },
  48. }, {
  49. 'url': 'https://uk.screen.yahoo.com/editor-picks/cute-raccoon-freed-drain-using-091756545.html',
  50. 'md5': '71298482f7c64cbb7fa064e4553ff1c1',
  51. 'info_dict': {
  52. 'id': 'b3affa53-2e14-3590-852b-0e0db6cd1a58',
  53. 'ext': 'webm',
  54. 'title': 'Cute Raccoon Freed From Drain\u00a0Using Angle Grinder',
  55. 'description': 'md5:f66c890e1490f4910a9953c941dee944',
  56. 'duration': 97,
  57. 'timestamp': 1414489862,
  58. 'upload_date': '20141028',
  59. }
  60. }, {
  61. 'url': 'http://news.yahoo.com/video/china-moses-crazy-blues-104538833.html',
  62. 'md5': '88e209b417f173d86186bef6e4d1f160',
  63. 'info_dict': {
  64. 'id': 'f885cf7f-43d4-3450-9fac-46ac30ece521',
  65. 'ext': 'mp4',
  66. 'title': 'China Moses Is Crazy About the Blues',
  67. 'description': 'md5:9900ab8cd5808175c7b3fe55b979bed0',
  68. 'duration': 128,
  69. 'timestamp': 1385722202,
  70. 'upload_date': '20131129',
  71. }
  72. }, {
  73. 'url': 'https://www.yahoo.com/movies/v/true-story-trailer-173000497.html',
  74. 'md5': '2a9752f74cb898af5d1083ea9f661b58',
  75. 'info_dict': {
  76. 'id': '071c4013-ce30-3a93-a5b2-e0413cd4a9d1',
  77. 'ext': 'mp4',
  78. 'title': '\'True Story\' Trailer',
  79. 'description': 'True Story',
  80. 'duration': 150,
  81. 'timestamp': 1418919206,
  82. 'upload_date': '20141218',
  83. },
  84. }, {
  85. 'url': 'https://gma.yahoo.com/pizza-delivery-man-surprised-huge-tip-college-kids-195200785.html',
  86. 'only_matching': True,
  87. }, {
  88. 'note': 'NBC Sports embeds',
  89. 'url': 'http://sports.yahoo.com/blogs/ncaab-the-dagger/tyler-kalinoski-s-buzzer-beater-caps-davidson-s-comeback-win-185609842.html?guid=nbc_cbk_davidsonbuzzerbeater_150313',
  90. 'info_dict': {
  91. 'id': '9CsDKds0kvHI',
  92. 'ext': 'flv',
  93. 'description': 'md5:df390f70a9ba7c95ff1daace988f0d8d',
  94. 'title': 'Tyler Kalinoski hits buzzer-beater to lift Davidson',
  95. 'upload_date': '20150313',
  96. 'uploader': 'NBCU-SPORTS',
  97. 'timestamp': 1426270238,
  98. },
  99. }, {
  100. 'url': 'https://tw.news.yahoo.com/-100120367.html',
  101. 'only_matching': True,
  102. }, {
  103. # Query result is embedded in webpage, but explicit request to video API fails with geo restriction
  104. 'url': 'https://screen.yahoo.com/community/communitary-community-episode-1-ladders-154501237.html',
  105. 'md5': '4fbafb9c9b6f07aa8f870629f6671b35',
  106. 'info_dict': {
  107. 'id': '1f32853c-a271-3eef-8cb6-f6d6872cb504',
  108. 'ext': 'mp4',
  109. 'title': 'Communitary - Community Episode 1: Ladders',
  110. 'description': 'md5:8fc39608213295748e1e289807838c97',
  111. 'duration': 1646,
  112. 'timestamp': 1440436550,
  113. 'upload_date': '20150824',
  114. 'series': 'Communitary',
  115. 'season_number': 6,
  116. 'episode_number': 1,
  117. },
  118. }, {
  119. # ytwnews://cavideo/
  120. 'url': 'https://tw.video.yahoo.com/movie-tw/單車天使-中文版預-092316541.html',
  121. 'info_dict': {
  122. 'id': 'ba133ff2-0793-3510-b636-59dfe9ff6cff',
  123. 'ext': 'mp4',
  124. 'title': '單車天使 - 中文版預',
  125. 'description': '中文版預',
  126. 'timestamp': 1476696196,
  127. 'upload_date': '20161017',
  128. },
  129. 'params': {
  130. 'skip_download': True,
  131. },
  132. }, {
  133. # Contains both a Yahoo hosted video and multiple Youtube embeds
  134. 'url': 'https://www.yahoo.com/entertainment/gwen-stefani-reveals-the-pop-hit-she-passed-on-assigns-it-to-her-voice-contestant-instead-033045672.html',
  135. 'info_dict': {
  136. 'id': '46c5d95a-528f-3d03-b732-732fcadd51de',
  137. 'title': 'Gwen Stefani reveals the pop hit she passed on, assigns it to her \'Voice\' contestant instead',
  138. 'description': 'Gwen decided not to record this hit herself, but she decided it was the perfect fit for Kyndall Inskeep.',
  139. },
  140. 'playlist': [{
  141. 'info_dict': {
  142. 'id': '966d4262-4fd1-3aaa-b45b-049ca6e38ba6',
  143. 'ext': 'mp4',
  144. 'title': 'Gwen Stefani reveals she turned down one of Sia\'s best songs',
  145. 'description': 'On "The Voice" Tuesday, Gwen Stefani told Taylor Swift which Sia hit was almost hers.',
  146. 'timestamp': 1572406500,
  147. 'upload_date': '20191030',
  148. },
  149. }, {
  150. 'info_dict': {
  151. 'id': '352CFDOQrKg',
  152. 'ext': 'mp4',
  153. 'title': 'Kyndal Inskeep "Performs the Hell Out of" Sia\'s "Elastic Heart" - The Voice Knockouts 2019',
  154. 'description': 'md5:35b61e94c2ae214bc965ff4245f80d11',
  155. 'uploader': 'The Voice',
  156. 'uploader_id': 'NBCTheVoice',
  157. 'upload_date': '20191029',
  158. },
  159. }],
  160. 'params': {
  161. 'playlistend': 2,
  162. },
  163. 'expected_warnings': ['HTTP Error 404'],
  164. }, {
  165. 'url': 'https://malaysia.news.yahoo.com/video/bystanders-help-ontario-policeman-bust-190932818.html',
  166. 'only_matching': True,
  167. }, {
  168. 'url': 'https://es-us.noticias.yahoo.com/es-la-puerta-irrompible-que-110539379.html',
  169. 'only_matching': True,
  170. }, {
  171. 'url': 'https://www.yahoo.com/entertainment/v/longtime-cbs-news-60-minutes-032036500-cbs.html',
  172. 'only_matching': True,
  173. }]
  174. def _real_extract(self, url):
  175. url, country, display_id = re.match(self._VALID_URL, url).groups()
  176. if not country:
  177. country = 'us'
  178. else:
  179. country = country.split('-')[0]
  180. api_base = 'https://%s.yahoo.com/_td/api/resource/' % country
  181. for i, uuid in enumerate(['url=' + url, 'ymedia-alias=' + display_id]):
  182. content = self._download_json(
  183. api_base + 'content;getDetailView=true;uuids=["%s"]' % uuid,
  184. display_id, 'Downloading content JSON metadata', fatal=i == 1)
  185. if content:
  186. item = content['items'][0]
  187. break
  188. if item.get('type') != 'video':
  189. entries = []
  190. cover = item.get('cover') or {}
  191. if cover.get('type') == 'yvideo':
  192. cover_url = cover.get('url')
  193. if cover_url:
  194. entries.append(self.url_result(
  195. cover_url, 'Yahoo', cover.get('uuid')))
  196. for e in item.get('body', []):
  197. if e.get('type') == 'videoIframe':
  198. iframe_url = e.get('url')
  199. if not iframe_url:
  200. continue
  201. entries.append(self.url_result(iframe_url))
  202. return self.playlist_result(
  203. entries, item.get('uuid'),
  204. item.get('title'), item.get('summary'))
  205. video_id = item['uuid']
  206. video = self._download_json(
  207. api_base + 'VideoService.videos;view=full;video_ids=["%s"]' % video_id,
  208. video_id, 'Downloading video JSON metadata')[0]
  209. title = video['title']
  210. if country == 'malaysia':
  211. country = 'my'
  212. is_live = video.get('live_state') == 'live'
  213. fmts = ('m3u8',) if is_live else ('webm', 'mp4')
  214. urls = []
  215. formats = []
  216. subtitles = {}
  217. for fmt in fmts:
  218. media_obj = self._download_json(
  219. 'https://video-api.yql.yahoo.com/v1/video/sapi/streams/' + video_id,
  220. video_id, 'Downloading %s JSON metadata' % fmt,
  221. headers=self.geo_verification_headers(), query={
  222. 'format': fmt,
  223. 'region': country.upper(),
  224. })['query']['results']['mediaObj'][0]
  225. msg = media_obj.get('status', {}).get('msg')
  226. for s in media_obj.get('streams', []):
  227. host = s.get('host')
  228. path = s.get('path')
  229. if not host or not path:
  230. continue
  231. s_url = host + path
  232. if s.get('format') == 'm3u8':
  233. formats.extend(self._extract_m3u8_formats(
  234. s_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
  235. continue
  236. tbr = int_or_none(s.get('bitrate'))
  237. formats.append({
  238. 'url': s_url,
  239. 'format_id': fmt + ('-%d' % tbr if tbr else ''),
  240. 'width': int_or_none(s.get('width')),
  241. 'height': int_or_none(s.get('height')),
  242. 'tbr': tbr,
  243. 'fps': int_or_none(s.get('framerate')),
  244. })
  245. for cc in media_obj.get('closedcaptions', []):
  246. cc_url = cc.get('url')
  247. if not cc_url or cc_url in urls:
  248. continue
  249. urls.append(cc_url)
  250. subtitles.setdefault(cc.get('lang') or 'en-US', []).append({
  251. 'url': cc_url,
  252. 'ext': mimetype2ext(cc.get('content_type')),
  253. })
  254. streaming_url = video.get('streaming_url')
  255. if streaming_url and not is_live:
  256. formats.extend(self._extract_m3u8_formats(
  257. streaming_url, video_id, 'mp4',
  258. 'm3u8_native', m3u8_id='hls', fatal=False))
  259. if not formats and msg == 'geo restricted':
  260. self.raise_geo_restricted()
  261. self._sort_formats(formats)
  262. thumbnails = []
  263. for thumb in video.get('thumbnails', []):
  264. thumb_url = thumb.get('url')
  265. if not thumb_url:
  266. continue
  267. thumbnails.append({
  268. 'id': thumb.get('tag'),
  269. 'url': thumb.get('url'),
  270. 'width': int_or_none(thumb.get('width')),
  271. 'height': int_or_none(thumb.get('height')),
  272. })
  273. series_info = video.get('series_info') or {}
  274. return {
  275. 'id': video_id,
  276. 'title': self._live_title(title) if is_live else title,
  277. 'formats': formats,
  278. 'display_id': display_id,
  279. 'thumbnails': thumbnails,
  280. 'description': clean_html(video.get('description')),
  281. 'timestamp': parse_iso8601(video.get('publish_time')),
  282. 'subtitles': subtitles,
  283. 'duration': int_or_none(video.get('duration')),
  284. 'view_count': int_or_none(video.get('view_count')),
  285. 'is_live': is_live,
  286. 'series': video.get('show_name'),
  287. 'season_number': int_or_none(series_info.get('season_number')),
  288. 'episode_number': int_or_none(series_info.get('episode_number')),
  289. }
  290. class YahooSearchIE(SearchInfoExtractor):
  291. IE_DESC = 'Yahoo screen search'
  292. _MAX_RESULTS = 1000
  293. IE_NAME = 'screen.yahoo:search'
  294. _SEARCH_KEY = 'yvsearch'
  295. def _get_n_results(self, query, n):
  296. """Get a specified number of results for a query"""
  297. entries = []
  298. for pagenum in itertools.count(0):
  299. result_url = 'http://video.search.yahoo.com/search/?p=%s&fr=screen&o=js&gs=0&b=%d' % (compat_urllib_parse.quote_plus(query), pagenum * 30)
  300. info = self._download_json(result_url, query,
  301. note='Downloading results page ' + str(pagenum + 1))
  302. m = info['m']
  303. results = info['results']
  304. for (i, r) in enumerate(results):
  305. if (pagenum * 30) + i >= n:
  306. break
  307. mobj = re.search(r'(?P<url>screen\.yahoo\.com/.*?-\d*?\.html)"', r)
  308. e = self.url_result('http://' + mobj.group('url'), 'Yahoo')
  309. entries.append(e)
  310. if (pagenum * 30 + i >= n) or (m['last'] >= (m['total'] - 1)):
  311. break
  312. return {
  313. '_type': 'playlist',
  314. 'id': query,
  315. 'entries': entries,
  316. }
  317. class YahooGyaOPlayerIE(InfoExtractor):
  318. IE_NAME = 'yahoo:gyao:player'
  319. _VALID_URL = r'https?://(?:gyao\.yahoo\.co\.jp/(?:player|episode/[^/]+)|streaming\.yahoo\.co\.jp/c/y)/(?P<id>\d+/v\d+/v\d+|[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})'
  320. _TESTS = [{
  321. 'url': 'https://gyao.yahoo.co.jp/player/00998/v00818/v0000000000000008564/',
  322. 'info_dict': {
  323. 'id': '5993125228001',
  324. 'ext': 'mp4',
  325. 'title': 'フューリー 【字幕版】',
  326. 'description': 'md5:21e691c798a15330eda4db17a8fe45a5',
  327. 'uploader_id': '4235717419001',
  328. 'upload_date': '20190124',
  329. 'timestamp': 1548294365,
  330. },
  331. 'params': {
  332. # m3u8 download
  333. 'skip_download': True,
  334. },
  335. }, {
  336. 'url': 'https://streaming.yahoo.co.jp/c/y/01034/v00133/v0000000000000000706/',
  337. 'only_matching': True,
  338. }, {
  339. 'url': 'https://gyao.yahoo.co.jp/episode/%E3%81%8D%E3%81%AE%E3%81%86%E4%BD%95%E9%A3%9F%E3%81%B9%E3%81%9F%EF%BC%9F%20%E7%AC%AC2%E8%A9%B1%202019%2F4%2F12%E6%94%BE%E9%80%81%E5%88%86/5cb02352-b725-409e-9f8d-88f947a9f682',
  340. 'only_matching': True,
  341. }]
  342. _GEO_BYPASS = False
  343. def _real_extract(self, url):
  344. video_id = self._match_id(url).replace('/', ':')
  345. headers = self.geo_verification_headers()
  346. headers['Accept'] = 'application/json'
  347. resp = self._download_json(
  348. 'https://gyao.yahoo.co.jp/apis/playback/graphql', video_id, query={
  349. 'appId': 'dj00aiZpPUNJeDh2cU1RazU3UCZzPWNvbnN1bWVyc2VjcmV0Jng9NTk-',
  350. 'query': '''{
  351. content(parameter: {contentId: "%s", logicaAgent: PC_WEB}) {
  352. video {
  353. delivery {
  354. id
  355. }
  356. title
  357. }
  358. }
  359. }''' % video_id,
  360. }, headers=headers)
  361. content = resp['data']['content']
  362. if not content:
  363. msg = resp['errors'][0]['message']
  364. if msg == 'not in japan':
  365. self.raise_geo_restricted(countries=['JP'])
  366. raise ExtractorError(msg)
  367. video = content['video']
  368. return {
  369. '_type': 'url_transparent',
  370. 'id': video_id,
  371. 'title': video['title'],
  372. 'url': smuggle_url(
  373. 'http://players.brightcove.net/4235717419001/SyG5P0gjb_default/index.html?videoId=' + video['delivery']['id'],
  374. {'geo_countries': ['JP']}),
  375. 'ie_key': BrightcoveNewIE.ie_key(),
  376. }
  377. class YahooGyaOIE(InfoExtractor):
  378. IE_NAME = 'yahoo:gyao'
  379. _VALID_URL = r'https?://(?:gyao\.yahoo\.co\.jp/(?:p|title(?:/[^/]+)?)|streaming\.yahoo\.co\.jp/p/y)/(?P<id>\d+/v\d+|[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})'
  380. _TESTS = [{
  381. 'url': 'https://gyao.yahoo.co.jp/p/00449/v03102/',
  382. 'info_dict': {
  383. 'id': '00449:v03102',
  384. },
  385. 'playlist_count': 2,
  386. }, {
  387. 'url': 'https://streaming.yahoo.co.jp/p/y/01034/v00133/',
  388. 'only_matching': True,
  389. }, {
  390. 'url': 'https://gyao.yahoo.co.jp/title/%E3%81%97%E3%82%83%E3%81%B9%E3%81%8F%E3%82%8A007/5b025a49-b2e5-4dc7-945c-09c6634afacf',
  391. 'only_matching': True,
  392. }, {
  393. 'url': 'https://gyao.yahoo.co.jp/title/5b025a49-b2e5-4dc7-945c-09c6634afacf',
  394. 'only_matching': True,
  395. }]
  396. def _real_extract(self, url):
  397. program_id = self._match_id(url).replace('/', ':')
  398. videos = self._download_json(
  399. 'https://gyao.yahoo.co.jp/api/programs/%s/videos' % program_id, program_id)['videos']
  400. entries = []
  401. for video in videos:
  402. video_id = video.get('id')
  403. if not video_id:
  404. continue
  405. entries.append(self.url_result(
  406. 'https://gyao.yahoo.co.jp/player/%s/' % video_id.replace(':', '/'),
  407. YahooGyaOPlayerIE.ie_key(), video_id))
  408. return self.playlist_result(entries, program_id)
  409. class YahooJapanNewsIE(InfoExtractor):
  410. IE_NAME = 'yahoo:japannews'
  411. IE_DESC = 'Yahoo! Japan News'
  412. _VALID_URL = r'https?://(?P<host>(?:news|headlines)\.yahoo\.co\.jp)[^\d]*(?P<id>\d[\d-]*\d)?'
  413. _GEO_COUNTRIES = ['JP']
  414. _TESTS = [{
  415. 'url': 'https://headlines.yahoo.co.jp/videonews/ann?a=20190716-00000071-ann-int',
  416. 'info_dict': {
  417. 'id': '1736242',
  418. 'ext': 'mp4',
  419. 'title': 'ムン大統領が対日批判を強化“現金化”効果は?(テレビ朝日系(ANN)) - Yahoo!ニュース',
  420. 'description': '韓国の元徴用工らを巡る裁判の原告が弁護士が差し押さえた三菱重工業の資産を売却して - Yahoo!ニュース(テレビ朝日系(ANN))',
  421. 'thumbnail': r're:^https?://.*\.[a-zA-Z\d]{3,4}$',
  422. },
  423. 'params': {
  424. 'skip_download': True,
  425. },
  426. }, {
  427. # geo restricted
  428. 'url': 'https://headlines.yahoo.co.jp/hl?a=20190721-00000001-oxv-l04',
  429. 'only_matching': True,
  430. }, {
  431. 'url': 'https://headlines.yahoo.co.jp/videonews/',
  432. 'only_matching': True,
  433. }, {
  434. 'url': 'https://news.yahoo.co.jp',
  435. 'only_matching': True,
  436. }, {
  437. 'url': 'https://news.yahoo.co.jp/byline/hashimotojunji/20190628-00131977/',
  438. 'only_matching': True,
  439. }, {
  440. 'url': 'https://news.yahoo.co.jp/feature/1356',
  441. 'only_matching': True
  442. }]
  443. def _extract_formats(self, json_data, content_id):
  444. formats = []
  445. video_data = try_get(
  446. json_data,
  447. lambda x: x['ResultSet']['Result'][0]['VideoUrlSet']['VideoUrl'],
  448. list)
  449. for vid in video_data or []:
  450. delivery = vid.get('delivery')
  451. url = url_or_none(vid.get('Url'))
  452. if not delivery or not url:
  453. continue
  454. elif delivery == 'hls':
  455. formats.extend(
  456. self._extract_m3u8_formats(
  457. url, content_id, 'mp4', 'm3u8_native',
  458. m3u8_id='hls', fatal=False))
  459. else:
  460. formats.append({
  461. 'url': url,
  462. 'format_id': 'http-%s' % compat_str(vid.get('bitrate', '')),
  463. 'height': int_or_none(vid.get('height')),
  464. 'width': int_or_none(vid.get('width')),
  465. 'tbr': int_or_none(vid.get('bitrate')),
  466. })
  467. self._remove_duplicate_formats(formats)
  468. self._sort_formats(formats)
  469. return formats
  470. def _real_extract(self, url):
  471. mobj = re.match(self._VALID_URL, url)
  472. host = mobj.group('host')
  473. display_id = mobj.group('id') or host
  474. webpage = self._download_webpage(url, display_id)
  475. title = self._html_search_meta(
  476. ['og:title', 'twitter:title'], webpage, 'title', default=None
  477. ) or self._html_search_regex('<title>([^<]+)</title>', webpage, 'title')
  478. if display_id == host:
  479. # Headline page (w/ multiple BC playlists) ('news.yahoo.co.jp', 'headlines.yahoo.co.jp/videonews/', ...)
  480. stream_plists = re.findall(r'plist=(\d+)', webpage) or re.findall(r'plist["\']:\s*["\']([^"\']+)', webpage)
  481. entries = [
  482. self.url_result(
  483. smuggle_url(
  484. 'http://players.brightcove.net/5690807595001/HyZNerRl7_default/index.html?playlistId=%s' % plist_id,
  485. {'geo_countries': ['JP']}),
  486. ie='BrightcoveNew', video_id=plist_id)
  487. for plist_id in stream_plists]
  488. return self.playlist_result(entries, playlist_title=title)
  489. # Article page
  490. description = self._html_search_meta(
  491. ['og:description', 'description', 'twitter:description'],
  492. webpage, 'description', default=None)
  493. thumbnail = self._og_search_thumbnail(
  494. webpage, default=None) or self._html_search_meta(
  495. 'twitter:image', webpage, 'thumbnail', default=None)
  496. space_id = self._search_regex([
  497. r'<script[^>]+class=["\']yvpub-player["\'][^>]+spaceid=([^&"\']+)',
  498. r'YAHOO\.JP\.srch\.\w+link\.onLoad[^;]+spaceID["\' ]*:["\' ]+([^"\']+)',
  499. r'<!--\s+SpaceID=(\d+)'
  500. ], webpage, 'spaceid')
  501. content_id = self._search_regex(
  502. r'<script[^>]+class=["\']yvpub-player["\'][^>]+contentid=(?P<contentid>[^&"\']+)',
  503. webpage, 'contentid', group='contentid')
  504. json_data = self._download_json(
  505. 'https://feapi-yvpub.yahooapis.jp/v1/content/%s' % content_id,
  506. content_id,
  507. query={
  508. 'appid': 'dj0zaiZpPVZMTVFJR0FwZWpiMyZzPWNvbnN1bWVyc2VjcmV0Jng9YjU-',
  509. 'output': 'json',
  510. 'space_id': space_id,
  511. 'domain': host,
  512. 'ak': hashlib.md5('_'.join((space_id, host)).encode()).hexdigest(),
  513. 'device_type': '1100',
  514. })
  515. formats = self._extract_formats(json_data, content_id)
  516. return {
  517. 'id': content_id,
  518. 'title': title,
  519. 'description': description,
  520. 'thumbnail': thumbnail,
  521. 'formats': formats,
  522. }