youtube-dl

Another place where youtube-dl lives on
git clone git://git.oshgnacknak.de/youtube-dl.git
Log | Files | Refs | README | LICENSE

eroprofile.py (3056B)


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