]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/nuvid.py
[francetv] Restore support for jt videos
[yt-dlp.git] / youtube_dl / extractor / nuvid.py
CommitLineData
87724af7
PH
1from __future__ import unicode_literals
2
749fe60c 3import re
4
5from .common import InfoExtractor
1cc79574
PH
6from ..compat import (
7 compat_urllib_request,
8)
3048e82a
S
9from ..utils import (
10 parse_duration,
11 unified_strdate,
3048e82a 12)
749fe60c 13
87724af7 14
749fe60c 15class NuvidIE(InfoExtractor):
1cc79574 16 _VALID_URL = r'https?://(?:www|m)\.nuvid\.com/video/(?P<id>[0-9]+)'
749fe60c 17 _TEST = {
87724af7
PH
18 'url': 'http://m.nuvid.com/video/1310741/',
19 'md5': 'eab207b7ac4fccfb4e23c86201f11277',
20 'info_dict': {
21 'id': '1310741',
22 'ext': 'mp4',
3048e82a
S
23 'title': 'Horny babes show their awesome bodeis and',
24 'duration': 129,
25 'upload_date': '20140508',
26 'age_limit': 18,
749fe60c 27 }
28 }
29
30 def _real_extract(self, url):
1cc79574 31 video_id = self._match_id(url)
749fe60c 32
3048e82a 33 formats = []
87724af7 34
3048e82a
S
35 for dwnld_speed, format_id in [(0, '3gp'), (5, 'mp4')]:
36 request = compat_urllib_request.Request(
37 'http://m.nuvid.com/play/%s' % video_id)
38 request.add_header('Cookie', 'skip_download_page=1; dwnld_speed=%d; adv_show=1' % dwnld_speed)
39 webpage = self._download_webpage(
40 request, video_id, 'Downloading %s page' % format_id)
41 video_url = self._html_search_regex(
394df6d7 42 r'<a\s+href="([^"]+)"\s+class="b_link">', webpage, '%s video URL' % format_id, fatal=False)
3048e82a
S
43 if not video_url:
44 continue
45 formats.append({
46 'url': video_url,
47 'format_id': format_id,
48 })
87724af7 49
3048e82a
S
50 webpage = self._download_webpage(
51 'http://m.nuvid.com/video/%s' % video_id, video_id, 'Downloading video page')
52 title = self._html_search_regex(
394df6d7
S
53 [r'<span title="([^"]+)">',
54 r'<div class="thumb-holder video">\s*<h5[^>]*>([^<]+)</h5>'], webpage, 'title').strip()
55 thumbnails = [
56 {
57 'url': thumb_url,
58 } for thumb_url in re.findall(r'<img src="([^"]+)" alt="" />', webpage)
59 ]
60 thumbnail = thumbnails[0]['url'] if thumbnails else None
3048e82a 61 duration = parse_duration(self._html_search_regex(
394df6d7 62 r'<i class="fa fa-clock-o"></i>\s*(\d{2}:\d{2})', webpage, 'duration', fatal=False))
3048e82a 63 upload_date = unified_strdate(self._html_search_regex(
394df6d7 64 r'<i class="fa fa-user"></i>\s*(\d{4}-\d{2}-\d{2})', webpage, 'upload date', fatal=False))
87724af7
PH
65
66 return {
67 'id': video_id,
87724af7 68 'title': title,
394df6d7
S
69 'thumbnails': thumbnails,
70 'thumbnail': thumbnail,
3048e82a
S
71 'duration': duration,
72 'upload_date': upload_date,
87724af7 73 'age_limit': 18,
3048e82a 74 'formats': formats,
5f6a1245 75 }