yahoo.py 22 KB

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