]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/extremetube.py
Change the ie_name of YoutubeSearchDateIE
[yt-dlp.git] / youtube_dl / extractor / extremetube.py
CommitLineData
32a35e44 1import os
2import re
3
4from .common import InfoExtractor
5from ..utils import (
6 compat_urllib_parse_urlparse,
7 compat_urllib_request,
8 compat_urllib_parse,
9)
10
11class ExtremeTubeIE(InfoExtractor):
12 _VALID_URL = r'^(?:https?://)?(?:www\.)?(?P<url>extremetube\.com/video/.+?(?P<videoid>[0-9]+))(?:[/?&]|$)'
13 _TEST = {
14 u'url': u'http://www.extremetube.com/video/music-video-14-british-euro-brit-european-cumshots-swallow-652431',
15 u'file': u'652431.mp4',
16 u'md5': u'1fb9228f5e3332ec8c057d6ac36f33e0',
17 u'info_dict': {
18 u"title": u"Music Video 14 british euro brit european cumshots swallow",
19 u"uploader": u"unknown",
20 u"age_limit": 18,
21 }
22 }
23
24 def _real_extract(self, url):
25 mobj = re.match(self._VALID_URL, url)
26 video_id = mobj.group('videoid')
27 url = 'http://www.' + mobj.group('url')
28
29 req = compat_urllib_request.Request(url)
30 req.add_header('Cookie', 'age_verified=1')
31 webpage = self._download_webpage(req, video_id)
32
33 video_title = self._html_search_regex(r'<h1 [^>]*?title="([^"]+)"[^>]*>\1<', webpage, u'title')
86ad94bb 34 uploader = self._html_search_regex(r'>Posted by:(?=<)(?:\s|<[^>]*>)*(.+?)\|', webpage, u'uploader', fatal=False)
32a35e44 35 video_url = compat_urllib_parse.unquote(self._html_search_regex(r'video_url=(.+?)&amp;', webpage, u'video_url'))
a56f9de1
JMF
36 path = compat_urllib_parse_urlparse(video_url).path
37 extension = os.path.splitext(path)[1][1:]
32a35e44 38 format = path.split('/')[5].split('_')[:2]
a56f9de1 39 format = "-".join(format)
32a35e44 40
32a35e44 41 return {
42 'id': video_id,
43 'title': video_title,
44 'uploader': uploader,
45 'url': video_url,
46 'ext': extension,
47 'format': format,
48 'format_id': format,
86ad94bb 49 'age_limit': 18,
32a35e44 50 }