logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

nfl.py (1011B)


  1. from __future__ import unicode_literals
  2. import json
  3. from .common import TokenGenerator
  4. class NFLTokenGenerator(TokenGenerator):
  5. _AUTHORIZATION = None
  6. def generate(ie, anvack, mcp_id):
  7. if not NFLTokenGenerator._AUTHORIZATION:
  8. reroute = ie._download_json(
  9. 'https://api.nfl.com/v1/reroute', mcp_id,
  10. data=b'grant_type=client_credentials',
  11. headers={'X-Domain-Id': 100})
  12. NFLTokenGenerator._AUTHORIZATION = '%s %s' % (reroute.get('token_type') or 'Bearer', reroute['access_token'])
  13. return ie._download_json(
  14. 'https://api.nfl.com/v3/shield/', mcp_id, data=json.dumps({
  15. 'query': '''{
  16. viewer {
  17. mediaToken(anvack: "%s", id: %s) {
  18. token
  19. }
  20. }
  21. }''' % (anvack, mcp_id),
  22. }).encode(), headers={
  23. 'Authorization': NFLTokenGenerator._AUTHORIZATION,
  24. 'Content-Type': 'application/json',
  25. })['data']['viewer']['mediaToken']['token']