1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-12-23 08:42:52 +08:00
youtube-dl/youtube_dl/extractor/filmweb.py

43 lines
1.4 KiB
Python
Raw Normal View History

2016-08-17 22:02:59 +08:00
from __future__ import unicode_literals
2017-12-27 02:41:08 +08:00
import re
2016-08-17 22:02:59 +08:00
2017-12-27 02:41:08 +08:00
from .common import InfoExtractor
2016-08-17 22:02:59 +08:00
2017-12-27 02:41:08 +08:00
class FilmwebIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?filmweb\.no/(?P<type>trailere|filmnytt)/article(?P<id>\d+)\.ece'
2016-08-17 22:02:59 +08:00
_TEST = {
'url': 'http://www.filmweb.no/trailere/article1264921.ece',
'md5': 'e353f47df98e557d67edaceda9dece89',
'info_dict': {
2017-12-27 02:41:08 +08:00
'id': '13033574',
2016-08-17 22:02:59 +08:00
'ext': 'mp4',
2017-12-27 02:41:08 +08:00
'title': 'Det som en gang var',
'upload_date': '20160316',
'timestamp': 1458140101,
'uploader_id': '12639966',
'uploader': 'Live Roaldset',
2016-08-17 22:02:59 +08:00
}
}
def _real_extract(self, url):
2017-12-27 02:41:08 +08:00
article_type, article_id = re.match(self._VALID_URL, url).groups()
if article_type == 'filmnytt':
webpage = self._download_webpage(url, article_id)
article_id = self._search_regex(r'data-videoid="(\d+)"', webpage, 'article id')
embed_code = self._download_json(
'https://www.filmweb.no/template_v2/ajax/json_trailerEmbed.jsp',
article_id, query={
'articleId': article_id,
})['embedCode']
iframe_url = self._proto_relative_url(self._search_regex(
r'<iframe[^>]+src="([^"]+)', embed_code, 'iframe url'))
2016-08-17 22:02:59 +08:00
return {
2017-12-27 02:41:08 +08:00
'_type': 'url_transparent',
2016-08-17 22:02:59 +08:00
'id': article_id,
2017-12-27 02:41:08 +08:00
'url': iframe_url,
'ie_key': 'TwentyThreeVideo',
2016-08-17 22:02:59 +08:00
}