]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/filmweb.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / filmweb.py
1 from .common import InfoExtractor
2
3
4 class FilmwebIE(InfoExtractor):
5 _VALID_URL = r'https?://(?:www\.)?filmweb\.no/(?P<type>trailere|filmnytt)/article(?P<id>\d+)\.ece'
6 _TEST = {
7 'url': 'http://www.filmweb.no/trailere/article1264921.ece',
8 'md5': 'e353f47df98e557d67edaceda9dece89',
9 'info_dict': {
10 'id': '13033574',
11 'ext': 'mp4',
12 'title': 'Det som en gang var',
13 'upload_date': '20160316',
14 'timestamp': 1458140101,
15 'uploader_id': '12639966',
16 'uploader': 'Live Roaldset',
17 },
18 }
19
20 def _real_extract(self, url):
21 article_type, article_id = self._match_valid_url(url).groups()
22 if article_type == 'filmnytt':
23 webpage = self._download_webpage(url, article_id)
24 article_id = self._search_regex(r'data-videoid="(\d+)"', webpage, 'article id')
25 embed_code = self._download_json(
26 'https://www.filmweb.no/template_v2/ajax/json_trailerEmbed.jsp',
27 article_id, query={
28 'articleId': article_id,
29 })['embedCode']
30 iframe_url = self._proto_relative_url(self._search_regex(
31 r'<iframe[^>]+src="([^"]+)', embed_code, 'iframe url'))
32
33 return {
34 '_type': 'url_transparent',
35 'id': article_id,
36 'url': iframe_url,
37 'ie_key': 'TwentyThreeVideo',
38 }