1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-23 00:54:31 +01:00

[usanetwork] Fix extraction (closes #22105)

This commit is contained in:
Sergey M․ 2019-08-26 03:35:09 +07:00
parent 393cc31d5e
commit 183a18c4e7
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -1,11 +1,9 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .adobepass import AdobePassIE from .adobepass import AdobePassIE
from ..utils import ( from ..utils import (
extract_attributes, NO_DEFAULT,
smuggle_url, smuggle_url,
update_url_query, update_url_query,
) )
@ -31,22 +29,22 @@ class USANetworkIE(AdobePassIE):
display_id = self._match_id(url) display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id) webpage = self._download_webpage(url, display_id)
player_params = extract_attributes(self._search_regex( def _x(name, default=NO_DEFAULT):
r'(<div[^>]+data-usa-tve-player-container[^>]*>)', webpage, 'player params')) return self._search_regex(
video_id = player_params['data-mpx-guid'] r'data-%s\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1' % name,
title = player_params['data-episode-title'] webpage, name, default=default, group='value')
account_pid, path = re.search( video_id = _x('mpx-guid')
r'data-src="(?:https?)?//player\.theplatform\.com/p/([^/]+)/.*?/(media/guid/\d+/\d+)', title = _x('episode-title')
webpage).groups() mpx_account_id = _x('mpx-account-id', '2304992029')
query = { query = {
'mbr': 'true', 'mbr': 'true',
} }
if player_params.get('data-is-full-episode') == '1': if _x('is-full-episode', None) == '1':
query['manifest'] = 'm3u' query['manifest'] = 'm3u'
if player_params.get('data-entitlement') == 'auth': if _x('is-entitlement', None) == '1':
adobe_pass = {} adobe_pass = {}
drupal_settings = self._search_regex( drupal_settings = self._search_regex(
r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);', r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);',
@ -57,7 +55,7 @@ class USANetworkIE(AdobePassIE):
adobe_pass = drupal_settings.get('adobePass', {}) adobe_pass = drupal_settings.get('adobePass', {})
resource = self._get_mvpd_resource( resource = self._get_mvpd_resource(
adobe_pass.get('adobePassResourceId', 'usa'), adobe_pass.get('adobePassResourceId', 'usa'),
title, video_id, player_params.get('data-episode-rating', 'TV-14')) title, video_id, _x('episode-rating', 'TV-14'))
query['auth'] = self._extract_mvpd_auth( query['auth'] = self._extract_mvpd_auth(
url, video_id, adobe_pass.get('adobePassRequestorId', 'usa'), resource) url, video_id, adobe_pass.get('adobePassRequestorId', 'usa'), resource)
@ -65,11 +63,11 @@ class USANetworkIE(AdobePassIE):
info.update({ info.update({
'_type': 'url_transparent', '_type': 'url_transparent',
'url': smuggle_url(update_url_query( 'url': smuggle_url(update_url_query(
'http://link.theplatform.com/s/%s/%s' % (account_pid, path), 'http://link.theplatform.com/s/HNK2IC/media/guid/%s/%s' % (mpx_account_id, video_id),
query), {'force_smil_url': True}), query), {'force_smil_url': True}),
'id': video_id, 'id': video_id,
'title': title, 'title': title,
'series': player_params.get('data-show-title'), 'series': _x('show-title', None),
'episode': title, 'episode': title,
'ie_key': 'ThePlatform', 'ie_key': 'ThePlatform',
}) })