Compare commits

..

2 Commits

Author SHA1 Message Date
Kyraminol Endyeran
df359266c2 [ie/vvvvid] fix with suggested changes 2023-11-19 17:59:42 +01:00
Kyraminol Endyeran
46ea59c5e6 [ie/vvvvid] remove conditional user agent override, set headers as cached_property 2023-11-19 17:13:14 +01:00

View File

@ -1,3 +1,4 @@
import functools
import re import re
from .common import InfoExtractor from .common import InfoExtractor
@ -113,21 +114,15 @@ class VVVVIDIE(InfoExtractor):
'only_matching': True 'only_matching': True
}] }]
_conn_id = None _conn_id = None
_default_user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.50 Safari/537.37'
_blocked_user_agents_regex = r'^Mozilla/5\.0 \(Windows NT 10\.0; Win64; x64\) AppleWebKit/537\.36 \(KHTML, like Gecko\) Chrome/[\d.]+ Safari/537\.36$'
_headers = {}
def _get_headers(self): @functools.cached_property
geo_verification_headers = self.geo_verification_headers() def _headers(self):
http_headers = self.get_param('http_headers', {}) return {
headers = {**http_headers, **geo_verification_headers} **self.geo_verification_headers(),
user_agent = headers.get('User-Agent', None) 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.50 Safari/537.37',
if not user_agent or re.match(self._blocked_user_agents_regex, user_agent): }
headers['User-Agent'] = self._default_user_agent
return headers
def _real_initialize(self, *args, **kwargs): def _real_initialize(self):
self._headers = self._get_headers()
self._conn_id = self._download_json( self._conn_id = self._download_json(
'https://www.vvvvid.it/user/login', 'https://www.vvvvid.it/user/login',
None, headers=self._headers)['data']['conn_id'] None, headers=self._headers)['data']['conn_id']