Merge pull request #193 from blackjack4494/NICK_MTV

[MTV/Nick] universal mgid extractor + fix nick.de feed
This commit is contained in:
Tom-Oliver Heidel 2020-10-17 10:26:57 +02:00 committed by GitHub
commit 963eaf53fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 16 deletions

View File

@ -306,7 +306,11 @@ def _extract_mgid(self, webpage, url, data_zone=None):
window_data = self._parse_json(self._search_regex( window_data = self._parse_json(self._search_regex(
r'(?s)window.__DATA__ = (?P<json>{.+});', webpage, r'(?s)window.__DATA__ = (?P<json>{.+});', webpage,
'JSON Window Data', default=None, fatal=False, group='json'), title, fatal=False) 'JSON Window Data', default=None, fatal=False, group='json'), title, fatal=False)
mgid = window_data['children'][4]['children'][0]['props']['media']['video']['config']['uri'] main_container = None
for i in range(len(window_data['children'])):
if window_data['children'][i]['type'] == 'MainContainer':
main_container = window_data['children'][i]
mgid = main_container['children'][0]['props']['media']['video']['config']['uri']
except (KeyError, IndexError, TypeError): except (KeyError, IndexError, TypeError):
pass pass

View File

@ -176,21 +176,11 @@ class NickDeIE(MTVServicesInfoExtractor):
'only_matching': True, 'only_matching': True,
}] }]
def _extract_mrss_url(self, webpage, host): def _get_feed_url(self, uri, url=None):
return update_url_query(self._search_regex( video_id = self._id_from_uri(uri)
r'data-mrss=(["\'])(?P<url>http.+?)\1', webpage, 'mrss url', group='url'), config = self._download_json(
{'siteKey': host}) 'http://media.mtvnservices.com/pmt/e1/access/index.html?uri=%s&configtype=edge&ref=%s' % (uri, url), video_id)
return self._remove_template_parameter(config['feedWithQueryParams'])
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
host = mobj.group('host')
webpage = self._download_webpage(url, video_id)
mrss_url = self._extract_mrss_url(webpage, host)
return self._get_videos_info_from_url(mrss_url, video_id)
class NickNightIE(NickDeIE): class NickNightIE(NickDeIE):