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.

94 lines
3.3 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. determine_ext,
  6. str_to_int,
  7. )
  8. class ZippCastIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?zippcast\.com/(?:video/|videoview\.php\?.*\bvplay=)(?P<id>[0-9a-zA-Z]+)'
  10. _TESTS = [{
  11. # m3u8, hq direct link
  12. 'url': 'http://www.zippcast.com/video/c9cfd5c7e44dbc29c81',
  13. 'md5': '5ea0263b5606866c4d6cda0fc5e8c6b6',
  14. 'info_dict': {
  15. 'id': 'c9cfd5c7e44dbc29c81',
  16. 'ext': 'mp4',
  17. 'title': '[Vinesauce] Vinny - Digital Space Traveler',
  18. 'description': 'Muted on youtube, but now uploaded in it\'s original form.',
  19. 'thumbnail': 're:^https?://.*\.jpg$',
  20. 'uploader': 'vinesauce',
  21. 'view_count': int,
  22. 'categories': ['Entertainment'],
  23. 'tags': list,
  24. },
  25. }, {
  26. # f4m, lq ipod direct link
  27. 'url': 'http://www.zippcast.com/video/b79c0a233e9c6581775',
  28. 'only_matching': True,
  29. }, {
  30. 'url': 'http://www.zippcast.com/videoview.php?vplay=c9cfd5c7e44dbc29c81&auto=no',
  31. 'only_matching': True,
  32. }]
  33. def _real_extract(self, url):
  34. video_id = self._match_id(url)
  35. webpage = self._download_webpage(
  36. 'http://www.zippcast.com/video/%s' % video_id, video_id)
  37. formats = []
  38. video_url = self._search_regex(
  39. r'<source[^>]+src=(["\'])(?P<url>.+?)\1', webpage,
  40. 'video url', default=None, group='url')
  41. if video_url:
  42. formats.append({
  43. 'url': video_url,
  44. 'format_id': 'http',
  45. 'preference': 0, # direct link is almost always of worse quality
  46. })
  47. src_url = self._search_regex(
  48. r'src\s*:\s*(?:escape\()?(["\'])(?P<url>http://.+?)\1',
  49. webpage, 'src', default=None, group='url')
  50. ext = determine_ext(src_url)
  51. if ext == 'm3u8':
  52. formats.extend(self._extract_m3u8_formats(
  53. src_url, video_id, 'mp4', entry_protocol='m3u8_native',
  54. m3u8_id='hls', fatal=False))
  55. elif ext == 'f4m':
  56. formats.extend(self._extract_f4m_formats(
  57. src_url, video_id, f4m_id='hds', fatal=False))
  58. self._sort_formats(formats)
  59. title = self._og_search_title(webpage)
  60. description = self._og_search_description(webpage) or self._html_search_meta(
  61. 'description', webpage)
  62. uploader = self._search_regex(
  63. r'<a[^>]+href="https?://[^/]+/profile/[^>]+>([^<]+)</a>',
  64. webpage, 'uploader', fatal=False)
  65. thumbnail = self._og_search_thumbnail(webpage)
  66. view_count = str_to_int(self._search_regex(
  67. r'>([\d,.]+) views!', webpage, 'view count', fatal=False))
  68. categories = re.findall(
  69. r'<a[^>]+href="https?://[^/]+/categories/[^"]+">([^<]+),?<',
  70. webpage)
  71. tags = re.findall(
  72. r'<a[^>]+href="https?://[^/]+/search/tags/[^"]+">([^<]+),?<',
  73. webpage)
  74. return {
  75. 'id': video_id,
  76. 'title': title,
  77. 'description': description,
  78. 'thumbnail': thumbnail,
  79. 'uploader': uploader,
  80. 'view_count': view_count,
  81. 'categories': categories,
  82. 'tags': tags,
  83. 'formats': formats,
  84. }