Fix clips (#108)

This commit is contained in:
Michaël Arnauts 2022-10-16 15:32:56 +02:00 committed by GitHub
parent 6d1c08e9c7
commit 9f4bba446a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -309,7 +309,7 @@ class ContentApi:
result = regex_video_data.search(page)
if result:
video_id = json.loads(unescape(result.group(1)))['id']
video_json_data = self._get_url('%s/api/video/%s' % (self.SITE_URL, video_id))
video_json_data = self._get_url('%s/web/v1/videos/short-form/%s' % (self.API_GOPLAY, video_id))
video_json = json.loads(video_json_data)
return dict(video=video_json)
@ -336,7 +336,7 @@ class ContentApi:
if 'video' in data and data['video']:
# We have found detailed episode information
episode = self._parse_episode_data(data['video'])
episode = self._parse_clip_data(data['video'])
return episode
if 'program' in data and 'episode' in data and data['program'] and data['episode']:
@ -696,6 +696,19 @@ class ContentApi:
)
return episode
@staticmethod
def _parse_clip_data(data):
""" Parse the Clip JSON.
:type data: dict
:rtype Episode
"""
episode = Episode(
uuid=data.get('videoUuid'),
program_title=data.get('title'),
title=data.get('title'),
)
return episode
def _get_url(self, url, params=None, authentication=None):
""" Makes a GET request for the specified URL.
:type url: str

View File

@ -55,7 +55,7 @@ class TestApi(unittest.TestCase):
self.assertIsInstance(program.episodes[0], Episode)
def test_clips(self):
for program in ['gert-late-night']:
for program in ['de-tafel-van-vier']:
program = self._api.get_program(program, extract_clips=True, cache=CACHE_PREVENT)
self.assertIsInstance(program.clips, list)