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.

66 lines
2.1 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_urllib_parse_urlparse,
  6. parse_duration,
  7. qualities,
  8. )
  9. class VuClipIE(InfoExtractor):
  10. _VALID_URL = r'http://(?:m\.)?vuclip\.com/w\?.*?cid=(?P<id>[0-9]+)'
  11. _TEST = {
  12. 'url': 'http://m.vuclip.com/w?cid=843902317&fid=63532&z=1007&nvar&frm=index.html&bu=4757321434',
  13. 'md5': '92ac9d1ccefec4f0bb474661ab144fcf',
  14. 'info_dict': {
  15. 'id': '843902317',
  16. 'ext': '3gp',
  17. 'title': 'Movie Trailer: Noah',
  18. 'duration': 139,
  19. }
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. video_id = mobj.group('id')
  24. webpage = self._download_webpage(url, video_id)
  25. ad_m = re.search(
  26. r'''value="No.*?" onClick="location.href='([^"']+)'"''', webpage)
  27. if ad_m:
  28. urlr = compat_urllib_parse_urlparse(url)
  29. adfree_url = urlr.scheme + '://' + urlr.netloc + ad_m.group(1)
  30. webpage = self._download_webpage(
  31. adfree_url, video_id, note='Download post-ad page')
  32. links_code = self._search_regex(
  33. r'(?s)<div class="social align_c".*?>(.*?)<hr\s*/?>', webpage,
  34. 'links')
  35. title = self._html_search_regex(
  36. r'<title>(.*?)-\s*Vuclip</title>', webpage, 'title').strip()
  37. quality_order = qualities(['Reg', 'Hi'])
  38. formats = []
  39. for url, q in re.findall(
  40. r'<a href="(?P<url>[^"]+)".*?>(?P<q>[^<]+)</a>', links_code):
  41. format_id = compat_urllib_parse_urlparse(url).scheme + '-' + q
  42. formats.append({
  43. 'format_id': format_id,
  44. 'url': url,
  45. 'quality': quality_order(q),
  46. })
  47. self._sort_formats(formats)
  48. duration = parse_duration(self._search_regex(
  49. r'\(([0-9:]+)\)</span></h1>', webpage, 'duration', fatal=False))
  50. return {
  51. 'id': video_id,
  52. 'formats': formats,
  53. 'title': title,
  54. 'duration': duration,
  55. }