mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-05-12 16:47:31 +00:00
[infomaniak] Follow project convention and helpers
This commit is contained in:
parent
c9e1317927
commit
25e5bcfb1d
@ -2,12 +2,26 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
import json
|
from ..utils import traverse_obj, int_or_none, url_or_none
|
||||||
|
|
||||||
|
|
||||||
class InfomaniakVOD2IE(InfoExtractor):
|
class InfomaniakVOD2IE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://player\.vod2\.infomaniak\.com/embed/(?P<id>[^/?#&]+)'
|
_VALID_URL = r'https?://player\.vod2\.infomaniak\.com/embed/(?P<id>[^/?#&]+)'
|
||||||
_TEST = {
|
_TESTS = [
|
||||||
|
# m3u8 test
|
||||||
|
{
|
||||||
|
'url': 'https://player.vod2.infomaniak.com/embed/1jhvl2uqg6ywp',
|
||||||
|
'md5': 'b45c718f1d59869aac4caa82f4a7c386',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '1jhvl2uqg6ywp',
|
||||||
|
'ext': 'm3u8',
|
||||||
|
'title': 'Conférence à Dyo, octobre 2022',
|
||||||
|
'thumbnail': 'https://res.vod2.infomaniak.com/1/vod/thumbnail/1jhvl2uqg6xjc.jpg',
|
||||||
|
'duration': 8012,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
# mp4 test
|
||||||
|
{
|
||||||
'url': 'https://player.vod2.infomaniak.com/embed/1jhvl2uq7kr4y',
|
'url': 'https://player.vod2.infomaniak.com/embed/1jhvl2uq7kr4y',
|
||||||
'md5': 'd06fb3fc5a8d7cb4d6e4a0f4e7c5a76a',
|
'md5': 'd06fb3fc5a8d7cb4d6e4a0f4e7c5a76a',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -18,21 +32,20 @@ class InfomaniakVOD2IE(InfoExtractor):
|
|||||||
'duration': 221,
|
'duration': 221,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
# no useful data in given url, formatted url below reveals json data
|
# no useful data in given url, formatted url below reveals json data
|
||||||
data_url = "https://res.vod2.infomaniak.com/{}/vod/share/{}".format(video_id[0], video_id)
|
data_url = 'https://res.vod2.infomaniak.com/{0}/vod/share/{1}'.format(video_id[0], video_id)
|
||||||
webpage = self._download_webpage(data_url, video_id)
|
webpage = self._download_json(data_url, video_id)['data']['media'][0]
|
||||||
|
|
||||||
data = json.loads(webpage)['data']['media'][0]
|
url = webpage['source']['url']
|
||||||
|
title = webpage['title']
|
||||||
|
thumbnail = traverse_obj(webpage, ('image', 'url'), expected_type=url_or_none)
|
||||||
|
duration = traverse_obj(webpage, 'duration', expected_type=int_or_none)
|
||||||
|
|
||||||
url = data['source']['url']
|
video_mimetype = traverse_obj(webpage, ('source', 'mimetype'), expected_type=lambda x: x.strip() or None)
|
||||||
title = data['title']
|
|
||||||
thumbnail = data.get('image').get('url')
|
|
||||||
duration = data.get('duration')
|
|
||||||
|
|
||||||
video_mimetype = data.get('source').get('mimetype')
|
|
||||||
|
|
||||||
info_dict = {
|
info_dict = {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
@ -44,7 +57,8 @@ class InfomaniakVOD2IE(InfoExtractor):
|
|||||||
|
|
||||||
# if file is m3u8
|
# if file is m3u8
|
||||||
if video_mimetype == 'application/x-mpegurl':
|
if video_mimetype == 'application/x-mpegurl':
|
||||||
info_dict['protocol'] = 'm3u8_native'
|
info_dict['formats'] = self._extract_m3u8_formats(
|
||||||
info_dict['manifest_url'] = url
|
info_dict.pop('url'), video_id, ext='m3u8', entry_protocol='m3u8_native', m3u8_id='hls')
|
||||||
|
self._sort_formats(info_dict['formats'])
|
||||||
|
|
||||||
return info_dict
|
return info_dict
|
||||||
|
Loading…
x
Reference in New Issue
Block a user