]>
Commit | Line | Data |
---|---|---|
9e1e67fc PH |
1 | from __future__ import unicode_literals |
2 | ||
83e49259 RA |
3 | import json |
4 | import re | |
5 | ||
d7e66d39 | 6 | from .common import InfoExtractor |
4dfbf869 | 7 | from ..utils import parse_qs |
d7e66d39 JMF |
8 | |
9 | ||
10 | class InternetVideoArchiveIE(InfoExtractor): | |
c05025fd | 11 | _VALID_URL = r'https?://video\.internetvideoarchive\.net/(?:player|flash/players)/.*?\?.*?publishedid.*?' |
d7e66d39 JMF |
12 | |
13 | _TEST = { | |
c05025fd | 14 | 'url': 'http://video.internetvideoarchive.net/player/6/configuration.ashx?customerid=69249&publishedid=194487&reporttag=vdbetatitle&playerid=641&autolist=0&domain=www.videodetective.com&maxrate=high&minrate=low&socialplayer=false', |
9e1e67fc | 15 | 'info_dict': { |
c05025fd | 16 | 'id': '194487', |
9e1e67fc | 17 | 'ext': 'mp4', |
83e49259 | 18 | 'title': 'Kick-Ass 2', |
c05025fd YCH |
19 | 'description': 'md5:c189d5b7280400630a1d3dd17eaa8d8a', |
20 | }, | |
21 | 'params': { | |
22 | # m3u8 download | |
23 | 'skip_download': True, | |
d7e66d39 JMF |
24 | }, |
25 | } | |
26 | ||
27 | @staticmethod | |
c05025fd YCH |
28 | def _build_json_url(query): |
29 | return 'http://video.internetvideoarchive.net/player/6/configuration.ashx?' + query | |
d7e66d39 JMF |
30 | |
31 | def _real_extract(self, url): | |
4dfbf869 | 32 | query = parse_qs(url) |
83e49259 RA |
33 | video_id = query['publishedid'][0] |
34 | data = self._download_json( | |
35 | 'https://video.internetvideoarchive.net/videojs7/videojs7.ivasettings.ashx', | |
36 | video_id, data=json.dumps({ | |
37 | 'customerid': query['customerid'][0], | |
38 | 'publishedid': video_id, | |
39 | }).encode()) | |
40 | title = data['Title'] | |
41 | formats = self._extract_m3u8_formats( | |
42 | data['VideoUrl'], video_id, 'mp4', | |
43 | 'm3u8_native', m3u8_id='hls', fatal=False) | |
44 | file_url = formats[0]['url'] | |
45 | if '.ism/' in file_url: | |
46 | replace_url = lambda x: re.sub(r'\.ism/[^?]+', '.ism/' + x, file_url) | |
47 | formats.extend(self._extract_f4m_formats( | |
48 | replace_url('.f4m'), video_id, f4m_id='hds', fatal=False)) | |
49 | formats.extend(self._extract_mpd_formats( | |
50 | replace_url('.mpd'), video_id, mpd_id='dash', fatal=False)) | |
51 | formats.extend(self._extract_ism_formats( | |
52 | replace_url('Manifest'), video_id, ism_id='mss', fatal=False)) | |
53 | self._sort_formats(formats) | |
d7e66d39 | 54 | |
cbbd9a9c | 55 | return { |
d7e66d39 | 56 | 'id': video_id, |
c05025fd | 57 | 'title': title, |
d7e66d39 | 58 | 'formats': formats, |
83e49259 RA |
59 | 'thumbnail': data.get('PosterUrl'), |
60 | 'description': data.get('Description'), | |
d7e66d39 | 61 | } |