mirror of
				https://github.com/ytdl-org/youtube-dl.git
				synced 2025-10-29 09:26:20 -07:00 
			
		
		
		
	[anvato] remove NFLTokenGenerator
until a better solution is introduced that: - works with lazy_extractors - allows for 3rd party token generators
This commit is contained in:
		| @@ -9,7 +9,6 @@ import re | |||||||
| import time | import time | ||||||
|  |  | ||||||
| from .common import InfoExtractor | from .common import InfoExtractor | ||||||
| # from .anvato_token_generator import NFLTokenGenerator |  | ||||||
| from ..aes import aes_encrypt | from ..aes import aes_encrypt | ||||||
| from ..compat import compat_str | from ..compat import compat_str | ||||||
| from ..utils import ( | from ..utils import ( | ||||||
| @@ -204,10 +203,6 @@ class AnvatoIE(InfoExtractor): | |||||||
|         'telemundo': 'anvato_mcp_telemundo_web_prod_c5278d51ad46fda4b6ca3d0ea44a7846a054f582' |         'telemundo': 'anvato_mcp_telemundo_web_prod_c5278d51ad46fda4b6ca3d0ea44a7846a054f582' | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     _TOKEN_GENERATORS = { |  | ||||||
|         # 'GXvEgwyJeWem8KCYXfeoHWknwP48Mboj': NFLTokenGenerator, |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     _API_KEY = '3hwbSuqqT690uxjNYBktSQpa5ZrpYYR0Iofx7NcJHyA' |     _API_KEY = '3hwbSuqqT690uxjNYBktSQpa5ZrpYYR0Iofx7NcJHyA' | ||||||
|  |  | ||||||
|     _ANVP_RE = r'<script[^>]+\bdata-anvp\s*=\s*(["\'])(?P<anvp>(?:(?!\1).)+)\1' |     _ANVP_RE = r'<script[^>]+\bdata-anvp\s*=\s*(["\'])(?P<anvp>(?:(?!\1).)+)\1' | ||||||
| @@ -267,12 +262,9 @@ class AnvatoIE(InfoExtractor): | |||||||
|             'anvrid': anvrid, |             'anvrid': anvrid, | ||||||
|             'anvts': server_time, |             'anvts': server_time, | ||||||
|         } |         } | ||||||
|         if access_key in self._TOKEN_GENERATORS: |         api['anvstk'] = md5_text('%s|%s|%d|%s' % ( | ||||||
|             api['anvstk2'] = self._TOKEN_GENERATORS[access_key].generate(self, access_key, video_id) |             access_key, anvrid, server_time, | ||||||
|         else: |             self._ANVACK_TABLE.get(access_key, self._API_KEY))) | ||||||
|             api['anvstk'] = md5_text('%s|%s|%d|%s' % ( |  | ||||||
|                 access_key, anvrid, server_time, |  | ||||||
|                 self._ANVACK_TABLE.get(access_key, self._API_KEY))) |  | ||||||
|  |  | ||||||
|         return self._download_json( |         return self._download_json( | ||||||
|             video_data_url, video_id, transform_source=strip_jsonp, |             video_data_url, video_id, transform_source=strip_jsonp, | ||||||
|   | |||||||
| @@ -1,7 +0,0 @@ | |||||||
| from __future__ import unicode_literals |  | ||||||
|  |  | ||||||
| from .nfl import NFLTokenGenerator |  | ||||||
|  |  | ||||||
| __all__ = [ |  | ||||||
|     'NFLTokenGenerator', |  | ||||||
| ] |  | ||||||
| @@ -1,6 +0,0 @@ | |||||||
| from __future__ import unicode_literals |  | ||||||
|  |  | ||||||
|  |  | ||||||
| class TokenGenerator: |  | ||||||
|     def generate(self, anvack, mcp_id): |  | ||||||
|         raise NotImplementedError('This method must be implemented by subclasses') |  | ||||||
| @@ -1,30 +0,0 @@ | |||||||
| from __future__ import unicode_literals |  | ||||||
|  |  | ||||||
| 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'] |  | ||||||
		Reference in New Issue
	
	Block a user