mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-12-02 20:52:55 +01:00
Cleaned up token retrieval in case of geo block
This commit is contained in:
parent
17a9592f29
commit
c63cbdb443
@ -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 photo['photo_id'] == photo_id:
|
|
||||||
return photo['protection_method'] == 'geoblocking'
|
|
||||||
|
|
||||||
return false
|
|
||||||
|
|
||||||
video_query = { 'format': 'json' }
|
|
||||||
if(is_geo_blocked()):
|
|
||||||
token = self._download_json(
|
|
||||||
base_url + '/api/protection/verify',
|
|
||||||
photo_id,
|
|
||||||
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']
|
|
||||||
|
|
||||||
video_query = { 'format': 'json', token: token}
|
|
||||||
|
|
||||||
|
|
||||||
|
if "photos" in photolist_result:
|
||||||
|
for photo in photolist_result['photos']:
|
||||||
|
if photo['photo_id'] == photo_id:
|
||||||
|
return photo['protection_method'] == 'geoblocking'
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
def get_video_query():
|
||||||
|
if is_geo_blocked():
|
||||||
|
token = self._download_json(
|
||||||
|
base_url + '/api/protection/verify',
|
||||||
|
photo_id,
|
||||||
|
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']
|
||||||
|
|
||||||
|
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 = []
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user