logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

internetvideoarchive.py (2415B)


  1. from __future__ import unicode_literals
  2. import json
  3. import re
  4. from .common import InfoExtractor
  5. from ..compat import (
  6. compat_parse_qs,
  7. compat_urlparse,
  8. )
  9. class InternetVideoArchiveIE(InfoExtractor):
  10. _VALID_URL = r'https?://video\.internetvideoarchive\.net/(?:player|flash/players)/.*?\?.*?publishedid.*?'
  11. _TEST = {
  12. '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',
  13. 'info_dict': {
  14. 'id': '194487',
  15. 'ext': 'mp4',
  16. 'title': 'Kick-Ass 2',
  17. 'description': 'md5:c189d5b7280400630a1d3dd17eaa8d8a',
  18. },
  19. 'params': {
  20. # m3u8 download
  21. 'skip_download': True,
  22. },
  23. }
  24. @staticmethod
  25. def _build_json_url(query):
  26. return 'http://video.internetvideoarchive.net/player/6/configuration.ashx?' + query
  27. def _real_extract(self, url):
  28. query = compat_parse_qs(compat_urlparse.urlparse(url).query)
  29. video_id = query['publishedid'][0]
  30. data = self._download_json(
  31. 'https://video.internetvideoarchive.net/videojs7/videojs7.ivasettings.ashx',
  32. video_id, data=json.dumps({
  33. 'customerid': query['customerid'][0],
  34. 'publishedid': video_id,
  35. }).encode())
  36. title = data['Title']
  37. formats = self._extract_m3u8_formats(
  38. data['VideoUrl'], video_id, 'mp4',
  39. 'm3u8_native', m3u8_id='hls', fatal=False)
  40. file_url = formats[0]['url']
  41. if '.ism/' in file_url:
  42. replace_url = lambda x: re.sub(r'\.ism/[^?]+', '.ism/' + x, file_url)
  43. formats.extend(self._extract_f4m_formats(
  44. replace_url('.f4m'), video_id, f4m_id='hds', fatal=False))
  45. formats.extend(self._extract_mpd_formats(
  46. replace_url('.mpd'), video_id, mpd_id='dash', fatal=False))
  47. formats.extend(self._extract_ism_formats(
  48. replace_url('Manifest'), video_id, ism_id='mss', fatal=False))
  49. self._sort_formats(formats)
  50. return {
  51. 'id': video_id,
  52. 'title': title,
  53. 'formats': formats,
  54. 'thumbnail': data.get('PosterUrl'),
  55. 'description': data.get('Description'),
  56. }