From 76144ccf0f4483e5e162080a2e6cbabcb24dda57 Mon Sep 17 00:00:00 2001 From: dirkf Date: Sat, 26 Feb 2022 13:03:51 +0000 Subject: [PATCH] [Filmarkivet] Add extractor for Filmarkivet.se https://github.com/yt-dlp/yt-dlp/issues/2885 --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/filmark.py | 54 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 youtube_dl/extractor/filmark.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 50b7cb4a0..5d10b91f3 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -372,6 +372,7 @@ from .filmon import ( FilmOnIE, FilmOnChannelIE, ) +from .filmark import FilmarkIE from .filmweb import FilmwebIE from .firsttv import FirstTVIE from .fivemin import FiveMinIE diff --git a/youtube_dl/extractor/filmark.py b/youtube_dl/extractor/filmark.py new file mode 100644 index 000000000..2eca90b52 --- /dev/null +++ b/youtube_dl/extractor/filmark.py @@ -0,0 +1,54 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import ( + merge_dicts, + parse_iso8601, +) + + +class FilmarkIE(InfoExtractor): + IE_NAME = 'Filmarkivet.se' + _VALID_URL = r'https?://www\.filmarkivet\.se/movies/(?P[\w-]+)' + _TESTS = [{ + 'url': 'https://www.filmarkivet.se/movies/paris-d-moll/', + 'md5': 'df02cadc719dcc63d43288366f037754', + 'info_dict': { + 'id': 'paris-d-moll', + 'ext': 'mp4', + 'upload_date': '20200602', + 'title': 'Paris d-moll', + 'description': 'md5:319e37ea5542293db37e1e13072fe330', + 'timestamp': 1591092663, + } + }, + ] + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + title = ( + self._html_search_regex(r']*>\s*([^<]*)', fatal=False) + or self._og_search_title(webpage, fatal=False) + or self._html_search_meta('twitter:title', webpage, default='')) + title = re.split(r'(\s*-)?\s*[Ff]ilmarkivet', title, 1)[0] or self._generic_title(url) + + ld_json_info = self._search_json_ld(webpage, video_id, default={}) + + jwp_info = self._extract_jwplayer_data(webpage, video_id, require_title=False) + + description = ( + self._og_search_description(webpage) + or self._html_search_meta('twitter:description', webpage, default=None)) + timestamp = parse_iso8601(self._og_search_property('updated_time', webpage, default=None)) + + return merge_dicts( + jwp_info, ld_json_info, { + 'title': title, + 'description': description, + 'timestamp': timestamp, + })