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.

68 lines
2.5 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_duration,
  6. unified_strdate,
  7. compat_urllib_request,
  8. )
  9. class NuvidIE(InfoExtractor):
  10. _VALID_URL = r'^https?://(?:www|m)\.nuvid\.com/video/(?P<id>[0-9]+)'
  11. _TEST = {
  12. 'url': 'http://m.nuvid.com/video/1310741/',
  13. 'md5': 'eab207b7ac4fccfb4e23c86201f11277',
  14. 'info_dict': {
  15. 'id': '1310741',
  16. 'ext': 'mp4',
  17. 'title': 'Horny babes show their awesome bodeis and',
  18. 'duration': 129,
  19. 'upload_date': '20140508',
  20. 'age_limit': 18,
  21. }
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. video_id = mobj.group('id')
  26. formats = []
  27. for dwnld_speed, format_id in [(0, '3gp'), (5, 'mp4')]:
  28. request = compat_urllib_request.Request(
  29. 'http://m.nuvid.com/play/%s' % video_id)
  30. request.add_header('Cookie', 'skip_download_page=1; dwnld_speed=%d; adv_show=1' % dwnld_speed)
  31. webpage = self._download_webpage(
  32. request, video_id, 'Downloading %s page' % format_id)
  33. video_url = self._html_search_regex(
  34. r'<a href="([^"]+)"\s*>Continue to watch video', webpage, '%s video URL' % format_id, fatal=False)
  35. if not video_url:
  36. continue
  37. formats.append({
  38. 'url': video_url,
  39. 'format_id': format_id,
  40. })
  41. webpage = self._download_webpage(
  42. 'http://m.nuvid.com/video/%s' % video_id, video_id, 'Downloading video page')
  43. title = self._html_search_regex(
  44. r'<div class="title">\s+<h2[^>]*>([^<]+)</h2>', webpage, 'title').strip()
  45. thumbnail = self._html_search_regex(
  46. r'href="(/thumbs/[^"]+)"[^>]*data-link_type="thumbs"',
  47. webpage, 'thumbnail URL', fatal=False)
  48. duration = parse_duration(self._html_search_regex(
  49. r'Length:\s*<span>(\d{2}:\d{2})</span>',webpage, 'duration', fatal=False))
  50. upload_date = unified_strdate(self._html_search_regex(
  51. r'Added:\s*<span>(\d{4}-\d{2}-\d{2})</span>', webpage, 'upload date', fatal=False))
  52. return {
  53. 'id': video_id,
  54. 'title': title,
  55. 'thumbnail': 'http://m.nuvid.com%s' % thumbnail,
  56. 'duration': duration,
  57. 'upload_date': upload_date,
  58. 'age_limit': 18,
  59. 'formats': formats,
  60. }