logo

youtube-dl

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

meta.py (2623B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from .pladform import PladformIE
  5. from ..utils import (
  6. unescapeHTML,
  7. int_or_none,
  8. ExtractorError,
  9. )
  10. class METAIE(InfoExtractor):
  11. _VALID_URL = r'https?://video\.meta\.ua/(?:iframe/)?(?P<id>[0-9]+)'
  12. _TESTS = [{
  13. 'url': 'http://video.meta.ua/5502115.video',
  14. 'md5': '71b6f3ee274bef16f1ab410f7f56b476',
  15. 'info_dict': {
  16. 'id': '5502115',
  17. 'ext': 'mp4',
  18. 'title': 'Sony Xperia Z camera test [HQ]',
  19. 'description': 'Xperia Z shoots video in FullHD HDR.',
  20. 'uploader_id': 'nomobile',
  21. 'uploader': 'CHЁZA.TV',
  22. 'upload_date': '20130211',
  23. },
  24. 'add_ie': ['Youtube'],
  25. }, {
  26. 'url': 'http://video.meta.ua/iframe/5502115',
  27. 'only_matching': True,
  28. }, {
  29. # pladform embed
  30. 'url': 'http://video.meta.ua/7121015.video',
  31. 'only_matching': True,
  32. }]
  33. def _real_extract(self, url):
  34. video_id = self._match_id(url)
  35. webpage = self._download_webpage(url, video_id)
  36. st_html5 = self._search_regex(
  37. r"st_html5\s*=\s*'#([^']+)'", webpage, 'uppod html5 st', default=None)
  38. if st_html5:
  39. # uppod st decryption algorithm is reverse engineered from function un(s) at uppod.js
  40. json_str = ''
  41. for i in range(0, len(st_html5), 3):
  42. json_str += '&#x0%s;' % st_html5[i:i + 3]
  43. uppod_data = self._parse_json(unescapeHTML(json_str), video_id)
  44. error = uppod_data.get('customnotfound')
  45. if error:
  46. raise ExtractorError('%s said: %s' % (self.IE_NAME, error), expected=True)
  47. video_url = uppod_data['file']
  48. info = {
  49. 'id': video_id,
  50. 'url': video_url,
  51. 'title': uppod_data.get('comment') or self._og_search_title(webpage),
  52. 'description': self._og_search_description(webpage, default=None),
  53. 'thumbnail': uppod_data.get('poster') or self._og_search_thumbnail(webpage),
  54. 'duration': int_or_none(self._og_search_property(
  55. 'video:duration', webpage, default=None)),
  56. }
  57. if 'youtube.com/' in video_url:
  58. info.update({
  59. '_type': 'url_transparent',
  60. 'ie_key': 'Youtube',
  61. })
  62. return info
  63. pladform_url = PladformIE._extract_url(webpage)
  64. if pladform_url:
  65. return self.url_result(pladform_url)