summaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/xxxymovies.py
blob: 5c8f17eb2fa1c3bb12924ca189699181eb2b598e (plain)
    1 from __future__ import unicode_literals
    2 
    3 import re
    4 
    5 from .common import InfoExtractor
    6 from ..utils import (
    7     parse_duration,
    8     int_or_none,
    9 )
   10 
   11 
   12 class XXXYMoviesIE(InfoExtractor):
   13     _VALID_URL = r'https?://(?:www\.)?xxxymovies\.com/videos/(?P<id>\d+)/(?P<display_id>[^/]+)'
   14     _TEST = {
   15         'url': 'http://xxxymovies.com/videos/138669/ecstatic-orgasm-sofcore/',
   16         'md5': '810b1bdbbffff89dd13bdb369fe7be4b',
   17         'info_dict': {
   18             'id': '138669',
   19             'display_id': 'ecstatic-orgasm-sofcore',
   20             'ext': 'mp4',
   21             'title': 'Ecstatic Orgasm Sofcore',
   22             'duration': 931,
   23             'categories': list,
   24             'view_count': int,
   25             'like_count': int,
   26             'dislike_count': int,
   27             'age_limit': 18,
   28         }
   29     }
   30 
   31     def _real_extract(self, url):
   32         mobj = re.match(self._VALID_URL, url)
   33         video_id = mobj.group('id')
   34         display_id = mobj.group('display_id')
   35 
   36         webpage = self._download_webpage(url, display_id)
   37 
   38         video_url = self._search_regex(
   39             r"video_url\s*:\s*'([^']+)'", webpage, 'video URL')
   40 
   41         title = self._html_search_regex(
   42             [r'<div class="block_header">\s*<h1>([^<]+)</h1>',
   43              r'<title>(.*?)\s*-\s*XXXYMovies\.com</title>'],
   44             webpage, 'title')
   45 
   46         thumbnail = self._search_regex(
   47             r"preview_url\s*:\s*'([^']+)'",
   48             webpage, 'thumbnail', fatal=False)
   49 
   50         categories = self._html_search_meta(
   51             'keywords', webpage, 'categories', default='').split(',')
   52 
   53         duration = parse_duration(self._search_regex(
   54             r'<span>Duration:</span>\s*(\d+:\d+)',
   55             webpage, 'duration', fatal=False))
   56 
   57         view_count = int_or_none(self._html_search_regex(
   58             r'<div class="video_views">\s*(\d+)',
   59             webpage, 'view count', fatal=False))
   60         like_count = int_or_none(self._search_regex(
   61             r'>\s*Likes? <b>\((\d+)\)',
   62             webpage, 'like count', fatal=False))
   63         dislike_count = int_or_none(self._search_regex(
   64             r'>\s*Dislike <b>\((\d+)\)</b>',
   65             webpage, 'dislike count', fatal=False))
   66 
   67         age_limit = self._rta_search(webpage)
   68 
   69         return {
   70             'id': video_id,
   71             'display_id': display_id,
   72             'url': video_url,
   73             'title': title,
   74             'thumbnail': thumbnail,
   75             'categories': categories,
   76             'duration': duration,
   77             'view_count': view_count,
   78             'like_count': like_count,
   79             'dislike_count': dislike_count,
   80             'age_limit': age_limit,
   81         }

Generated by cgit