Cleaned up token retrieval in case of geo block

This commit is contained in:
Jesenko Mehmedbasic 2020-12-22 15:13:26 +01:00
parent 17a9592f29
commit c63cbdb443

View File

@ -56,29 +56,33 @@ class TwentyThreeVideoIE(InfoExtractor):
photo_id, photo_id,
query = new_query, query = new_query,
transform_source=lambda s: self._search_regex(r'(?s)({.+})', s, 'photolist_2') transform_source=lambda s: self._search_regex(r'(?s)({.+})', s, 'photolist_2')
)["photolist_2"]["photos"] )["photolist_2"]
for photo in photolist_result: if "photos" in photolist_result:
if photo['photo_id'] == photo_id: for photo in photolist_result['photos']:
return photo['protection_method'] == 'geoblocking' if photo['photo_id'] == photo_id:
return photo['protection_method'] == 'geoblocking'
return false return False
video_query = { 'format': 'json' } def get_video_query():
if(is_geo_blocked()): if is_geo_blocked():
token = self._download_json( token = self._download_json(
base_url + '/api/protection/verify', base_url + '/api/protection/verify',
photo_id, photo_id,
query={ 'protection_method': 'geoblocking', 'object_id': photo_id, 'object_type': 'photo', 'format': 'json', 'callback': 'visualplatform_1' }, query={ 'protection_method': 'geoblocking', 'object_id': photo_id, 'object_type': 'photo', 'format': 'json', 'callback': 'visualplatform_1' },
transform_source=lambda s: self._search_regex(r'(?s)({.+})', s, 'protectedtoken'))['protectedtoken']['protected_token'] transform_source=lambda s: self._search_regex(r'(?s)({.+})', s, 'protectedtoken'))['protectedtoken']['protected_token']
video_query = { 'format': 'json', token: token}
return { 'format': 'json', 'token': token}
else:
return { 'format': 'json' }
video_query = get_video_query()
photo_data = self._download_json( photo_data = self._download_json(
base_url + '/api/photo/list?' + query, photo_id, query={ base_url + '/api/photo/list?' + query, photo_id,
'format': 'json', 'token': token query = video_query,
}, transform_source=lambda s: self._search_regex(r'(?s)({.+})', s, 'photo data'))['photo'] transform_source=lambda s: self._search_regex(r'(?s)({.+})', s, 'photo data'))['photo']
title = photo_data['title'] title = photo_data['title']
formats = [] formats = []