2 import xml.etree.ElementTree
4 from .common import InfoExtractor
12 class InternetVideoArchiveIE(InfoExtractor):
13 _VALID_URL = r'https?://video\.internetvideoarchive\.net/flash/players/.*?\?.*?publishedid.*?'
16 u'url': u'http://video.internetvideoarchive.net/flash/players/flashconfiguration.aspx?customerid=69249&publishedid=452693&playerid=247',
17 u'file': u'452693.mp4',
20 u'description': u'In SKYFALL, Bond\'s loyalty to M is tested as her past comes back to haunt her. As MI6 comes under attack, 007 must track down and destroy the threat, no matter how personal the cost.',
26 def _build_url(query):
27 return 'http://video.internetvideoarchive.net/flash/players/flashconfiguration.aspx?' + query
29 def _real_extract(self, url):
30 query = compat_urlparse.urlparse(url).query
31 query_dic = compat_urlparse.parse_qs(query)
32 video_id = query_dic['publishedid'][0]
33 url = self._build_url(query)
35 flashconfiguration_xml = self._download_webpage(url, video_id,
36 u'Downloading flash configuration')
37 flashconfiguration = xml.etree.ElementTree.fromstring(flashconfiguration_xml.encode('utf-8'))
38 file_url = flashconfiguration.find('file').text
39 file_url = file_url.replace('/playlist.aspx', '/mrssplaylist.aspx')
40 info_xml = self._download_webpage(file_url, video_id,
41 u'Downloading video info')
42 info = xml.etree.ElementTree.fromstring(info_xml.encode('utf-8'))
43 item = info.find('channel/item')
46 return xpath_with_ns(p,
47 {'media': 'http://search.yahoo.com/mrss/',
48 'jwplayer': 'http://developer.longtailvideo.com/trac/wiki/FlashFormats'})
50 for content in item.findall(_bp('media:group/media:content')):
55 'ext': determine_ext(f_url),
56 'width': int(attr['width']),
57 'bitrate': int(attr['bitrate']),
59 formats = sorted(formats, key=lambda f: f['bitrate'])
63 'title': item.find('title').text,
65 'thumbnail': item.find(_bp('media:thumbnail')).attrib['url'],
66 'description': item.find('description').text,
67 'duration': int(attr['duration']),
69 # TODO: Remove when #980 has been merged
70 info.update(formats[-1])