[fox] fix extraction for free videos(#19060)

This commit is contained in:
Remita Amine 2019-01-28 22:39:08 +01:00
parent a81daba231
commit 41c2c254d3

View File

@ -1,10 +1,11 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
# import json import json
# import uuid import uuid
from .adobepass import AdobePassIE from .adobepass import AdobePassIE
from ..compat import compat_str
from ..utils import ( from ..utils import (
int_or_none, int_or_none,
parse_age_limit, parse_age_limit,
@ -47,38 +48,31 @@ class FOXIE(AdobePassIE):
'url': 'https://www.nationalgeographic.com/tv/watch/f690e05ebbe23ab79747becd0cc223d1/', 'url': 'https://www.nationalgeographic.com/tv/watch/f690e05ebbe23ab79747becd0cc223d1/',
'only_matching': True, 'only_matching': True,
}] }]
# _access_token = None _access_token = None
# def _call_api(self, path, video_id, data=None): def _call_api(self, path, video_id, data=None):
# headers = { headers = {
# 'X-Api-Key': '238bb0a0c2aba67922c48709ce0c06fd', 'X-Api-Key': '238bb0a0c2aba67922c48709ce0c06fd',
# } }
# if self._access_token: if self._access_token:
# headers['Authorization'] = 'Bearer ' + self._access_token headers['Authorization'] = 'Bearer ' + self._access_token
# return self._download_json( return self._download_json(
# 'https://api2.fox.com/v2.0/' + path, video_id, data=data, headers=headers) 'https://api2.fox.com/v2.0/' + path,
video_id, data=data, headers=headers)
# def _real_initialize(self): def _real_initialize(self):
# self._access_token = self._call_api( self._access_token = self._call_api(
# 'login', None, json.dumps({ 'login', None, json.dumps({
# 'deviceId': compat_str(uuid.uuid4()), 'deviceId': compat_str(uuid.uuid4()),
# }).encode())['accessToken'] }).encode())['accessToken']
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
video = self._download_json( video = self._call_api('vodplayer/' + video_id, video_id)
'https://api.fox.com/fbc-content/v1_5/video/%s' % video_id,
video_id, headers={
'apikey': 'abdcbed02c124d393b39e818a4312055',
'Content-Type': 'application/json',
'Referer': url,
})
# video = self._call_api('vodplayer/' + video_id, video_id)
title = video['name'] title = video['name']
release_url = video['videoRelease']['url'] release_url = video['url']
# release_url = video['url']
data = try_get( data = try_get(
video, lambda x: x['trackingData']['properties'], dict) or {} video, lambda x: x['trackingData']['properties'], dict) or {}