[BehindKink] Replace test
[youtube-dl] / youtube_dl / extractor / behindkink.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import url_basename
8
9
10 class BehindKinkIE(InfoExtractor):
11     _VALID_URL = r'http://(?:www\.)?behindkink\.com/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/(?P<id>[^/#?_]+)'
12     _TEST = {
13         'url': 'http://www.behindkink.com/2014/12/05/what-are-you-passionate-about-marley-blaze/',
14         'md5': '507b57d8fdcd75a41a9a7bdb7989c762',
15         'info_dict': {
16             'id': '37127',
17             'ext': 'mp4',
18             'title': 'What are you passionate about – Marley Blaze',
19             'description': 'Getting a better understanding of the talent that comes through the doors of the Armory is one of our missions at Behind Kink. Asking the question what are you passionate about helps us get a littl...',
20             'upload_date': '20141205',
21             'thumbnail': 'http://www.behindkink.com/wp-content/uploads/2014/12/blaze-1.jpg',
22             'age_limit': 18,
23         }
24     }
25
26     def _real_extract(self, url):
27         mobj = re.match(self._VALID_URL, url)
28         display_id = mobj.group('id')
29         year = mobj.group('year')
30         month = mobj.group('month')
31         day = mobj.group('day')
32         upload_date = year + month + day
33
34         webpage = self._download_webpage(url, display_id)
35
36         video_url = self._search_regex(
37             r'<source src="(.*?)" type="video/mp4" />', webpage, 'video URL')
38
39         video_id = url_basename(video_url)
40         video_id = video_id.split('_')[0]
41
42         return {
43             'id': video_id,
44             'url': video_url,
45             'ext': 'mp4',
46             'title': self._og_search_title(webpage),
47             'display_id': display_id,
48             'thumbnail': self._og_search_thumbnail(webpage),
49             'description': self._og_search_description(webpage),
50             'upload_date': upload_date,
51             'age_limit': 18,
52         }