Compare commits

..

2 Commits

Author SHA1 Message Date
Moritz Barsnick
c3ff8bbcd6 [ie/LinkedIn] add test for subtitles
Note that the extractr is somewhat broken, so the valus of this test will
have to be adapted when the extractor is fixed.
2024-01-24 22:11:08 +01:00
Moritz Barsnick
cab73e9ab0 [ie/LinkedIn] fix according to review comments 2024-01-24 21:57:06 +01:00

View File

@ -13,6 +13,7 @@ from ..utils import (
strip_or_none,
mimetype2ext,
try_get,
url_or_none,
urlencode_postdata,
urljoin,
)
@ -93,6 +94,15 @@ class LinkedInIE(LinkedInBaseIE):
'description': 'md5:be125430bab1c574f16aeb186a4d5b19',
'creator': 'Mishal K.'
},
}, {
'url': 'https://www.linkedin.com/posts/the-mathworks_2_what-is-mathworks-cloud-center-activity-7151241570371948544-4Gu7',
'info_dict': {
'id': '2',
'ext': 'mp4',
'title': 'MathWorks on LinkedIn: What Is MathWorks Cloud Center?',
'thumbnail': 'https://media.licdn.com/dms/image/D5610AQFKo9M0zqY2_g/ads-video-thumbnail_720_1280/0/1704988806715?e=2147483647&v=beta&t=0vg-ksOY2KrL_QFlNacCv5Tmuk0tum9FJ_4dlJ56Gyw',
'subtitles': 'mincount:1'
},
}]
def _real_extract(self, url):
@ -104,17 +114,17 @@ class LinkedInIE(LinkedInBaseIE):
like_count = int_or_none(get_element_by_class('social-counts-reactions__social-counts-numRections', webpage))
creator = strip_or_none(clean_html(get_element_by_class('comment__actor-name', webpage)))
video_json = extract_attributes(self._search_regex(r'(<video[^>]+>)', webpage, 'video'))
sources = self._parse_json(video_json['data-sources'], video_id)
video_attrs = extract_attributes(self._search_regex(r'(<video[^>]+>)', webpage, 'video'))
sources = self._parse_json(video_attrs['data-sources'], video_id)
formats = [{
'url': source['src'],
'ext': mimetype2ext(source.get('type')),
'tbr': float_or_none(source.get('data-bitrate'), scale=1000),
} for source in sources]
subtitles = {}
sub_url = video_json.get('data-captions-url')
if sub_url:
subtitles.setdefault('en', []).append({'url': sub_url, 'ext': 'vtt'})
subtitles = {'en': [{
'url': video_attrs['data-captions-url'],
'ext': 'vtt',
}]} if url_or_none(video_attrs.get('data-captions-url')) else {}
return {
'id': video_id,