Make more request changes

This commit is contained in:
Kyle 2019-07-21 16:08:47 +09:00
parent 5da61feddf
commit 446ebd6fc3

View File

@ -565,7 +565,7 @@ class YahooGyaOIE(InfoExtractor):
class YahooJapanNewsIE(InfoExtractor): class YahooJapanNewsIE(InfoExtractor):
IE_NAME = 'yahoo:japannews' IE_NAME = 'yahoo:japannews'
IE_DESC = 'Yahoo! Japan News' IE_DESC = 'Yahoo! Japan News'
_VALID_URL = r'https?://(?P<host>(?:news|headlines)\.yahoo\.co\.jp)(/[^\d]*(?P<id>\d[\d-]*\d))?' _VALID_URL = r'https?://(?P<host>(?:news|headlines)\.yahoo\.co\.jp)[^\d]*(?P<id>\d[\d-]*\d)?'
_TESTS = [{ _TESTS = [{
'url': 'https://headlines.yahoo.co.jp/videonews/ann?a=20190716-00000071-ann-int', 'url': 'https://headlines.yahoo.co.jp/videonews/ann?a=20190716-00000071-ann-int',
'info_dict': { 'info_dict': {
@ -610,10 +610,8 @@ class YahooJapanNewsIE(InfoExtractor):
formats.append({ formats.append({
'url': url, 'url': url,
'format_id': 'http-%s' % compat_str(vid.get('bitrate', '')), 'format_id': 'http-%s' % compat_str(vid.get('bitrate', '')),
'ext': determine_ext(url),
'height': int_or_none(vid.get('height')), 'height': int_or_none(vid.get('height')),
'width': int_or_none(vid.get('width')), 'width': int_or_none(vid.get('width'))
'btr': int_or_none(vid.get('bitrate'))
}) })
self._remove_duplicate_formats(formats) self._remove_duplicate_formats(formats)
self._sort_formats(formats) self._sort_formats(formats)
@ -630,18 +628,6 @@ class YahooJapanNewsIE(InfoExtractor):
title = self._html_search_meta( title = self._html_search_meta(
['og:title', 'twitter:title'], webpage, 'title', default=None ['og:title', 'twitter:title'], webpage, 'title', default=None
) or self._html_search_regex('<title>([^<]+)</title>', webpage, 'title') ) or self._html_search_regex('<title>([^<]+)</title>', webpage, 'title')
description = self._html_search_meta([
'og:description', 'description', 'twitter:description'
], webpage, 'description', default=None)
thumbnail = self._og_search_thumbnail(
webpage, default=None
) or self._html_search_meta('twitter:image', webpage, 'thumbnail', default=None)
space_id = self._search_regex([
r'<script[^>]+class=["\']yvpub-player["\'][^>]+spaceid=([^&"\']+)',
r'YAHOO\.JP\.srch\.\w+link\.onLoad[^;]+spaceID["\' ]*:["\' ]+([^"\']+)',
r'<!--\s+SpaceID=(\d+)'
], webpage, 'spaceid')
formats = []
if display_id == host: if display_id == host:
# Headline page (w/ multiple BC playlists) # Headline page (w/ multiple BC playlists)
@ -682,25 +668,31 @@ class YahooJapanNewsIE(InfoExtractor):
continue continue
entries.append(bc_url % (account, player, embed, plist_id)) entries.append(bc_url % (account, player, embed, plist_id))
return self.playlist_from_matches(entries, space_id, title, ie='BrightcoveNew') return self.playlist_from_matches(entries, playlist_title=title, ie='BrightcoveNew')
# Article page # Article page
description = self._html_search_meta([
'og:description', 'description', 'twitter:description'
], webpage, 'description', default=None)
thumbnail = self._og_search_thumbnail(
webpage, default=None
) or self._html_search_meta('twitter:image', webpage, 'thumbnail', default=None)
space_id = self._search_regex([
r'<script[^>]+class=["\']yvpub-player["\'][^>]+spaceid=([^&"\']+)',
r'YAHOO\.JP\.srch\.\w+link\.onLoad[^;]+spaceID["\' ]*:["\' ]+([^"\']+)',
r'<!--\s+SpaceID=(\d+)'
], webpage, 'spaceid')
app_id = 'dj0zaiZpPVZMTVFJR0FwZWpiMyZzPWNvbnN1bWVyc2VjcmV0Jng9YjU-' app_id = 'dj0zaiZpPVZMTVFJR0FwZWpiMyZzPWNvbnN1bWVyc2VjcmV0Jng9YjU-'
content_id = self._search_regex( content_id = self._search_regex(
r'<script[^>]+class=(["\'])yvpub-player\1[^>]+contentid=(?P<contentid>[^&"\']+)', r'<script[^>]+class=["\']yvpub-player["\'][^>]+contentid=(?P<contentid>[^&"\']+)',
webpage, 'contentid', group='contentid', default=space_id) webpage, 'contentid', group='contentid')
# md5 hash of space_id + '_headlines.yahoo.co.jp' # md5 hash of space_id + '_headlines.yahoo.co.jp'
ak = hashlib.md5('_'.join((space_id, host)).encode()).hexdigest() ak = hashlib.md5('_'.join((space_id, host)).encode()).hexdigest()
json_data = self._download_json( json_data = self._download_json(
'https://feapi-yvpub.yahooapis.jp/v1/content/%s' % content_id, 'https://feapi-yvpub.yahooapis.jp/v1/content/%s' % content_id,
content_id, content_id,
headers={
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Origin': 'https://s.yimg.jp',
'Host': 'feapi-yvpub.yahooapis.jp',
'Referer': 'https://s.yimg.jp/images/yvpub/player/vamos/pc/latest/player.html',
},
query={ query={
'appid': app_id, 'appid': app_id,
'output': 'json', 'output': 'json',