]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/pornoxo.py
[dailymotion] Error spelling
[youtube-dl] / youtube_dl / extractor / pornoxo.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import (
7     str_to_int,
8 )
9
10
11 class PornoXOIE(InfoExtractor):
12     _VALID_URL = r'https?://(?:www\.)?pornoxo\.com/videos/(?P<id>\d+)/(?P<display_id>[^/]+)\.html'
13     _TEST = {
14         'url': 'http://www.pornoxo.com/videos/7564/striptease-from-sexy-secretary.html',
15         'md5': '582f28ecbaa9e6e24cb90f50f524ce87',
16         'info_dict': {
17             'id': '7564',
18             'ext': 'flv',
19             'title': 'Striptease From Sexy Secretary!',
20             'description': 'Striptease From Sexy Secretary!',
21             'categories': list,  # NSFW
22             'thumbnail': 're:https?://.*\.jpg$',
23             'age_limit': 18,
24         }
25     }
26
27     def _real_extract(self, url):
28         mobj = re.match(self._VALID_URL, url)
29         video_id = mobj.group('id')
30
31         webpage = self._download_webpage(url, video_id)
32
33         video_url = self._html_search_regex(
34             r'\'file\'\s*:\s*"([^"]+)"', webpage, 'video_url')
35
36         title = self._html_search_regex(
37             r'<title>([^<]+)\s*-\s*PornoXO', webpage, 'title')
38
39         description = self._html_search_regex(
40             r'<meta name="description" content="([^"]+)\s*featuring',
41             webpage, 'description', fatal=False)
42
43         thumbnail = self._html_search_regex(
44             r'\'image\'\s*:\s*"([^"]+)"', webpage, 'thumbnail', fatal=False)
45
46         view_count = str_to_int(self._html_search_regex(
47             r'[vV]iews:\s*([0-9,]+)', webpage, 'view count', fatal=False))
48
49         categories_str = self._html_search_regex(
50             r'<meta name="description" content=".*featuring\s*([^"]+)"',
51             webpage, 'categories', fatal=False)
52         categories = (
53             None if categories_str is None
54             else categories_str.split(','))
55
56         return {
57             'id': video_id,
58             'url': video_url,
59             'title': title,
60             'description': description,
61             'thumbnail': thumbnail,
62             'categories': categories,
63             'view_count': view_count,
64             'age_limit': 18,
65         }