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.

95 lines
3.1 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..compat import compat_urllib_parse_urlencode
  5. from ..utils import (
  6. ExtractorError,
  7. unescapeHTML
  8. )
  9. class EroProfileIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?eroprofile\.com/m/videos/view/(?P<id>[^/]+)'
  11. _LOGIN_URL = 'http://www.eroprofile.com/auth/auth.php?'
  12. _NETRC_MACHINE = 'eroprofile'
  13. _TESTS = [{
  14. 'url': 'http://www.eroprofile.com/m/videos/view/sexy-babe-softcore',
  15. 'md5': 'c26f351332edf23e1ea28ce9ec9de32f',
  16. 'info_dict': {
  17. 'id': '3733775',
  18. 'display_id': 'sexy-babe-softcore',
  19. 'ext': 'm4v',
  20. 'title': 'sexy babe softcore',
  21. 'thumbnail': r're:https?://.*\.jpg',
  22. 'age_limit': 18,
  23. }
  24. }, {
  25. 'url': 'http://www.eroprofile.com/m/videos/view/Try-It-On-Pee_cut_2-wmv-4shared-com-file-sharing-download-movie-file',
  26. 'md5': '1baa9602ede46ce904c431f5418d8916',
  27. 'info_dict': {
  28. 'id': '1133519',
  29. 'ext': 'm4v',
  30. 'title': 'Try It On Pee_cut_2.wmv - 4shared.com - file sharing - download movie file',
  31. 'thumbnail': r're:https?://.*\.jpg',
  32. 'age_limit': 18,
  33. },
  34. 'skip': 'Requires login',
  35. }]
  36. def _login(self):
  37. (username, password) = self._get_login_info()
  38. if username is None:
  39. return
  40. query = compat_urllib_parse_urlencode({
  41. 'username': username,
  42. 'password': password,
  43. 'url': 'http://www.eroprofile.com/',
  44. })
  45. login_url = self._LOGIN_URL + query
  46. login_page = self._download_webpage(login_url, None, False)
  47. m = re.search(r'Your username or password was incorrect\.', login_page)
  48. if m:
  49. raise ExtractorError(
  50. 'Wrong username and/or password.', expected=True)
  51. self.report_login()
  52. redirect_url = self._search_regex(
  53. r'<script[^>]+?src="([^"]+)"', login_page, 'login redirect url')
  54. self._download_webpage(redirect_url, None, False)
  55. def _real_initialize(self):
  56. self._login()
  57. def _real_extract(self, url):
  58. display_id = self._match_id(url)
  59. webpage = self._download_webpage(url, display_id)
  60. m = re.search(r'You must be logged in to view this video\.', webpage)
  61. if m:
  62. self.raise_login_required('This video requires login')
  63. video_id = self._search_regex(
  64. [r"glbUpdViews\s*\('\d*','(\d+)'", r'p/report/video/(\d+)'],
  65. webpage, 'video id', default=None)
  66. video_url = unescapeHTML(self._search_regex(
  67. r'<source src="([^"]+)', webpage, 'video url'))
  68. title = self._html_search_regex(
  69. r'Title:</th><td>([^<]+)</td>', webpage, 'title')
  70. thumbnail = self._search_regex(
  71. r'onclick="showVideoPlayer\(\)"><img src="([^"]+)',
  72. webpage, 'thumbnail', fatal=False)
  73. return {
  74. 'id': video_id,
  75. 'display_id': display_id,
  76. 'url': video_url,
  77. 'title': title,
  78. 'thumbnail': thumbnail,
  79. 'age_limit': 18,
  80. }