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.

70 lines
2.2 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..compat import (
  5. compat_urllib_parse_urlparse,
  6. )
  7. from ..utils import (
  8. ExtractorError,
  9. parse_duration,
  10. remove_end,
  11. )
  12. class VuClipIE(InfoExtractor):
  13. _VALID_URL = r'https?://(?:m\.)?vuclip\.com/w\?.*?cid=(?P<id>[0-9]+)'
  14. _TEST = {
  15. 'url': 'http://m.vuclip.com/w?cid=1129900602&bu=8589892792&frm=w&z=34801&op=0&oc=843169247&section=recommend',
  16. 'info_dict': {
  17. 'id': '1129900602',
  18. 'ext': '3gp',
  19. 'title': 'Top 10 TV Convicts',
  20. 'duration': 733,
  21. }
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, video_id)
  26. ad_m = re.search(
  27. r'''value="No.*?" onClick="location.href='([^"']+)'"''', webpage)
  28. if ad_m:
  29. urlr = compat_urllib_parse_urlparse(url)
  30. adfree_url = urlr.scheme + '://' + urlr.netloc + ad_m.group(1)
  31. webpage = self._download_webpage(
  32. adfree_url, video_id, note='Download post-ad page')
  33. error_msg = self._html_search_regex(
  34. r'<p class="message">(.*?)</p>', webpage, 'error message',
  35. default=None)
  36. if error_msg:
  37. raise ExtractorError(
  38. '%s said: %s' % (self.IE_NAME, error_msg), expected=True)
  39. # These clowns alternate between two page types
  40. video_url = self._search_regex(
  41. r'<a[^>]+href="([^"]+)"[^>]*><img[^>]+src="[^"]*/play\.gif',
  42. webpage, 'video URL', default=None)
  43. if video_url:
  44. formats = [{
  45. 'url': video_url,
  46. }]
  47. else:
  48. formats = self._parse_html5_media_entries(url, webpage, video_id)[0]['formats']
  49. title = remove_end(self._html_search_regex(
  50. r'<title>(.*?)-\s*Vuclip</title>', webpage, 'title').strip(), ' - Video')
  51. duration = parse_duration(self._html_search_regex(
  52. r'[(>]([0-9]+:[0-9]+)(?:<span|\))', webpage, 'duration', fatal=False))
  53. return {
  54. 'id': video_id,
  55. 'formats': formats,
  56. 'title': title,
  57. 'duration': duration,
  58. }