]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/pornoxo.py
Add support for PornoXO
[yt-dlp.git] / youtube_dl / extractor / pornoxo.py
CommitLineData
3d9fae1e
PH
1from __future__ import unicode_literals
2
3import re
4
5from .common import InfoExtractor
6from ..utils import (
7 parse_duration,
8 str_to_int,
9)
10
11class 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'Views:\s*(\d+)', 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
57 return {
58 'id': video_id,
59 'url': video_url,
60 'title': title,
61 'description': description,
62 'thumbnail': thumbnail,
63 'categories': categories,
64 'view_count': view_count,
65 'age_limit': 18,
66 }