]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/filmweb.py
debian/control: Set 'Rules-Requires-Root: no'.
[youtubedl] / youtube_dl / extractor / filmweb.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class FilmwebIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?filmweb\.no/(?P<type>trailere|filmnytt)/article(?P<id>\d+)\.ece'
10 _TEST = {
11 'url': 'http://www.filmweb.no/trailere/article1264921.ece',
12 'md5': 'e353f47df98e557d67edaceda9dece89',
13 'info_dict': {
14 'id': '13033574',
15 'ext': 'mp4',
16 'title': 'Det som en gang var',
17 'upload_date': '20160316',
18 'timestamp': 1458140101,
19 'uploader_id': '12639966',
20 'uploader': 'Live Roaldset',
21 }
22 }
23
24 def _real_extract(self, url):
25 article_type, article_id = re.match(self._VALID_URL, url).groups()
26 if article_type == 'filmnytt':
27 webpage = self._download_webpage(url, article_id)
28 article_id = self._search_regex(r'data-videoid="(\d+)"', webpage, 'article id')
29 embed_code = self._download_json(
30 'https://www.filmweb.no/template_v2/ajax/json_trailerEmbed.jsp',
31 article_id, query={
32 'articleId': article_id,
33 })['embedCode']
34 iframe_url = self._proto_relative_url(self._search_regex(
35 r'<iframe[^>]+src="([^"]+)', embed_code, 'iframe url'))
36
37 return {
38 '_type': 'url_transparent',
39 'id': article_id,
40 'url': iframe_url,
41 'ie_key': 'TwentyThreeVideo',
42 }