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.

93 lines
3.2 KiB

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