2 from __future__ import unicode_literals
6 from .common import InfoExtractor
16 class AftenpostenIE(InfoExtractor):
17 _VALID_URL = r'https?://(?:www\.)?aftenposten\.no/webtv/(?:#!/)?video/(?P<id>\d+)'
20 'url': 'http://www.aftenposten.no/webtv/#!/video/21039/trailer-sweatshop-i-can-t-take-any-more',
21 'md5': 'fd828cd29774a729bf4d4425fe192972',
25 'title': 'TRAILER: "Sweatshop" - I canĀ“t take any more',
26 'description': 'md5:21891f2b0dd7ec2f78d84a50e54f8238',
27 'timestamp': 1416927969,
28 'upload_date': '20141125',
32 def _real_extract(self, url):
33 video_id = self._match_id(url)
35 data = self._download_xml(
36 'http://frontend.xstream.dk/ap/feed/video/?platform=web&id=%s' % video_id, video_id)
39 'atom': 'http://www.w3.org/2005/Atom',
40 'xt': 'http://xstream.dk/',
41 'media': 'http://search.yahoo.com/mrss/',
44 entry = data.find(xpath_with_ns('./atom:entry', NS_MAP))
47 entry, xpath_with_ns('./atom:title', NS_MAP), 'title')
48 description = xpath_text(
49 entry, xpath_with_ns('./atom:summary', NS_MAP), 'description')
50 timestamp = parse_iso8601(xpath_text(
51 entry, xpath_with_ns('./atom:published', NS_MAP), 'upload date'))
54 media_group = entry.find(xpath_with_ns('./media:group', NS_MAP))
55 for media_content in media_group.findall(xpath_with_ns('./media:content', NS_MAP)):
56 media_url = media_content.get('url')
59 tbr = int_or_none(media_content.get('bitrate'))
60 mobj = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', media_url)
63 'url': mobj.group('url'),
64 'play_path': 'mp4:%s' % mobj.group('playpath'),
65 'app': mobj.group('app'),
68 'format_id': 'rtmp-%d' % tbr,
75 self._sort_formats(formats)
77 link = find_xpath_attr(
78 entry, xpath_with_ns('./atom:link', NS_MAP), 'rel', 'original')
81 'url': link.get('href'),
82 'format_id': link.get('rel'),
86 'url': splash.get('url'),
87 'width': int_or_none(splash.get('width')),
88 'height': int_or_none(splash.get('height')),
89 } for splash in media_group.findall(xpath_with_ns('./xt:splash', NS_MAP))]
94 'description': description,
95 'timestamp': timestamp,
97 'thumbnails': thumbnails,