2 from __future__ import unicode_literals
7 from .common import InfoExtractor
10 class AftonbladetIE(InfoExtractor):
11 _VALID_URL = r'^http://tv\.aftonbladet\.se/webbtv.+?(?P<video_id>article[0-9]+)\.ab(?:$|[?#])'
13 'url': 'http://tv.aftonbladet.se/webbtv/nyheter/vetenskap/rymden/article36015.ab',
17 'title': 'Vulkanutbrott i rymden - nu släpper NASA bilderna',
18 'description': 'Jupiters måne mest aktiv av alla himlakroppar',
19 'upload_date': '20140306',
23 def _real_extract(self, url):
24 mobj = re.search(self._VALID_URL, url)
26 video_id = mobj.group('video_id')
27 webpage = self._download_webpage(url, video_id)
29 # find internal video meta data
30 META_URL = 'http://aftonbladet-play.drlib.aptoma.no/video/%s.json'
31 internal_meta_id = self._html_search_regex(
32 r'data-aptomaId="([\w\d]+)"', webpage, 'internal_meta_id')
33 internal_meta_url = META_URL % internal_meta_id
34 internal_meta_json = self._download_json(
35 internal_meta_url, video_id, 'Downloading video meta data')
37 # find internal video formats
38 FORMATS_URL = 'http://aftonbladet-play.videodata.drvideo.aptoma.no/actions/video/?id=%s'
39 internal_video_id = internal_meta_json['videoId']
40 internal_formats_url = FORMATS_URL % internal_video_id
41 internal_formats_json = self._download_json(
42 internal_formats_url, video_id, 'Downloading video formats')
45 for fmt in internal_formats_json['formats']['http']['pseudostreaming']['mp4']:
48 'url': 'http://%s:%d/%s/%s' % (p['address'], p['port'], p['path'], p['filename']),
50 'width': fmt['width'],
51 'height': fmt['height'],
52 'tbr': fmt['bitrate'],
55 self._sort_formats(formats)
57 timestamp = datetime.datetime.fromtimestamp(internal_meta_json['timePublished'])
58 upload_date = timestamp.strftime('%Y%m%d')
62 'title': internal_meta_json['title'],
64 'thumbnail': internal_meta_json['imageUrl'],
65 'description': internal_meta_json['shortPreamble'],
66 'upload_date': upload_date,
67 'duration': internal_meta_json['duration'],
68 'view_count': internal_meta_json['views'],