logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

eroprofile.py (3056B)


  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. merge_dicts,
  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. 'skip': 'Video not found',
  25. }, {
  26. 'url': 'http://www.eroprofile.com/m/videos/view/Try-It-On-Pee_cut_2-wmv-4shared-com-file-sharing-download-movie-file',
  27. 'md5': '1baa9602ede46ce904c431f5418d8916',
  28. 'info_dict': {
  29. 'id': '1133519',
  30. 'ext': 'm4v',
  31. 'title': 'Try It On Pee_cut_2.wmv - 4shared.com - file sharing - download movie file',
  32. 'thumbnail': r're:https?://.*\.jpg',
  33. 'age_limit': 18,
  34. },
  35. 'skip': 'Requires login',
  36. }]
  37. def _login(self):
  38. (username, password) = self._get_login_info()
  39. if username is None:
  40. return
  41. query = compat_urllib_parse_urlencode({
  42. 'username': username,
  43. 'password': password,
  44. 'url': 'http://www.eroprofile.com/',
  45. })
  46. login_url = self._LOGIN_URL + query
  47. login_page = self._download_webpage(login_url, None, False)
  48. m = re.search(r'Your username or password was incorrect\.', login_page)
  49. if m:
  50. raise ExtractorError(
  51. 'Wrong username and/or password.', expected=True)
  52. self.report_login()
  53. redirect_url = self._search_regex(
  54. r'<script[^>]+?src="([^"]+)"', login_page, 'login redirect url')
  55. self._download_webpage(redirect_url, None, False)
  56. def _real_initialize(self):
  57. self._login()
  58. def _real_extract(self, url):
  59. display_id = self._match_id(url)
  60. webpage = self._download_webpage(url, display_id)
  61. m = re.search(r'You must be logged in to view this video\.', webpage)
  62. if m:
  63. self.raise_login_required('This video requires login')
  64. video_id = self._search_regex(
  65. [r"glbUpdViews\s*\('\d*','(\d+)'", r'p/report/video/(\d+)'],
  66. webpage, 'video id', default=None)
  67. title = self._html_search_regex(
  68. (r'Title:</th><td>([^<]+)</td>', r'<h1[^>]*>(.+?)</h1>'),
  69. webpage, 'title')
  70. info = self._parse_html5_media_entries(url, webpage, video_id)[0]
  71. return merge_dicts(info, {
  72. 'id': video_id,
  73. 'display_id': display_id,
  74. 'title': title,
  75. 'age_limit': 18,
  76. })