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.

75 lines
2.6 KiB

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