You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.9 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class ZypeIE(InfoExtractor):
  6. _VALID_URL = r'https?://player\.zype\.com/embed/(?P<id>[\da-fA-F]+)\.js\?.*?api_key=[^&]+'
  7. _TEST = {
  8. 'url': 'https://player.zype.com/embed/5b400b834b32992a310622b9.js?api_key=jZ9GUhRmxcPvX7M3SlfejB6Hle9jyHTdk2jVxG7wOHPLODgncEKVdPYBhuz9iWXQ&autoplay=false&controls=true&da=false',
  9. 'md5': 'eaee31d474c76a955bdaba02a505c595',
  10. 'info_dict': {
  11. 'id': '5b400b834b32992a310622b9',
  12. 'ext': 'mp4',
  13. 'title': 'Smoky Barbecue Favorites',
  14. 'thumbnail': r're:^https?://.*\.jpe?g',
  15. },
  16. }
  17. @staticmethod
  18. def _extract_urls(webpage):
  19. return [
  20. mobj.group('url')
  21. for mobj in re.finditer(
  22. r'<script[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//player\.zype\.com/embed/[\da-fA-F]+\.js\?.*?api_key=.+?)\1',
  23. webpage)]
  24. def _real_extract(self, url):
  25. video_id = self._match_id(url)
  26. webpage = self._download_webpage(url, video_id)
  27. title = self._search_regex(
  28. r'video_title\s*[:=]\s*(["\'])(?P<value>(?:(?!\1).)+)\1', webpage,
  29. 'title', group='value')
  30. m3u8_url = self._search_regex(
  31. r'(["\'])(?P<url>(?:(?!\1).)+\.m3u8(?:(?!\1).)*)\1', webpage,
  32. 'm3u8 url', group='url')
  33. formats = self._extract_m3u8_formats(
  34. m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native',
  35. m3u8_id='hls')
  36. self._sort_formats(formats)
  37. thumbnail = self._search_regex(
  38. r'poster\s*[:=]\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'thumbnail',
  39. default=False, group='url')
  40. return {
  41. 'id': video_id,
  42. 'title': title,
  43. 'thumbnail': thumbnail,
  44. 'formats': formats,
  45. }