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.

73 lines
2.6 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\s+href="([^"]+)"\s+class="b_link">', 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'<span title="([^"]+)">',
  45. r'<div class="thumb-holder video">\s*<h5[^>]*>([^<]+)</h5>'], webpage, 'title').strip()
  46. thumbnails = [
  47. {
  48. 'url': thumb_url,
  49. } for thumb_url in re.findall(r'<img src="([^"]+)" alt="" />', webpage)
  50. ]
  51. thumbnail = thumbnails[0]['url'] if thumbnails else None
  52. duration = parse_duration(self._html_search_regex(
  53. r'<i class="fa fa-clock-o"></i>\s*(\d{2}:\d{2})', webpage, 'duration', fatal=False))
  54. upload_date = unified_strdate(self._html_search_regex(
  55. r'<i class="fa fa-user"></i>\s*(\d{4}-\d{2}-\d{2})', webpage, 'upload date', fatal=False))
  56. return {
  57. 'id': video_id,
  58. 'title': title,
  59. 'thumbnails': thumbnails,
  60. 'thumbnail': thumbnail,
  61. 'duration': duration,
  62. 'upload_date': upload_date,
  63. 'age_limit': 18,
  64. 'formats': formats,
  65. }