mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-24 21:56:53 +01:00
86e5f3ed2e
Using https://github.com/asottile/pyupgrade 1. `__future__` imports and `coding: utf-8` were removed 2. Files were rewritten with `pyupgrade --py36-plus --keep-percent-format` 3. f-strings were cherry-picked from `pyupgrade --py36-plus` Extractors are left untouched (except removing header) to avoid unnecessary merge conflicts
29 lines
970 B
Python
29 lines
970 B
Python
import json
|
|
|
|
from .common import TokenGenerator
|
|
|
|
|
|
class NFLTokenGenerator(TokenGenerator):
|
|
_AUTHORIZATION = None
|
|
|
|
def generate(ie, anvack, mcp_id):
|
|
if not NFLTokenGenerator._AUTHORIZATION:
|
|
reroute = ie._download_json(
|
|
'https://api.nfl.com/v1/reroute', mcp_id,
|
|
data=b'grant_type=client_credentials',
|
|
headers={'X-Domain-Id': 100})
|
|
NFLTokenGenerator._AUTHORIZATION = '%s %s' % (reroute.get('token_type') or 'Bearer', reroute['access_token'])
|
|
return ie._download_json(
|
|
'https://api.nfl.com/v3/shield/', mcp_id, data=json.dumps({
|
|
'query': '''{
|
|
viewer {
|
|
mediaToken(anvack: "%s", id: %s) {
|
|
token
|
|
}
|
|
}
|
|
}''' % (anvack, mcp_id),
|
|
}).encode(), headers={
|
|
'Authorization': NFLTokenGenerator._AUTHORIZATION,
|
|
'Content-Type': 'application/json',
|
|
})['data']['viewer']['mediaToken']['token']
|