]>
Commit | Line | Data |
---|---|---|
185a7e25 MTP |
1 | from __future__ import unicode_literals |
2 | ||
7cf97daf S |
3 | import re |
4 | ||
185a7e25 MTP |
5 | from .common import InfoExtractor |
6 | from ..utils import( | |
7cf97daf S |
7 | unified_strdate, |
8 | str_to_int, | |
185a7e25 MTP |
9 | ) |
10 | ||
7cf97daf | 11 | |
185a7e25 MTP |
12 | class RadioJavanIE(InfoExtractor): |
13 | _VALID_URL = r'https?://(?:www\.)?radiojavan\.com/videos/video/(?P<id>[^/]+)/?' | |
14 | _TEST = { | |
15 | 'url': 'http://www.radiojavan.com/videos/video/chaartaar-ashoobam', | |
16 | 'md5': 'e85208ffa3ca8b83534fca9fe19af95b', | |
17 | 'info_dict': { | |
18 | 'id': 'chaartaar-ashoobam', | |
19 | 'ext': 'mp4', | |
20 | 'title': 'Chaartaar - Ashoobam', | |
185a7e25 | 21 | 'thumbnail': 're:^https?://.*\.jpe?g$', |
7cf97daf S |
22 | 'upload_date': '20150215', |
23 | 'view_count': int, | |
24 | 'like_count': int, | |
25 | 'dislike_count': int, | |
185a7e25 MTP |
26 | } |
27 | } | |
28 | ||
29 | def _real_extract(self, url): | |
7cf97daf | 30 | video_id = self._match_id(url) |
185a7e25 | 31 | |
7cf97daf | 32 | webpage = self._download_webpage(url, video_id) |
185a7e25 | 33 | |
7cf97daf S |
34 | formats = [{ |
35 | 'url': 'https://media.rdjavan.com/media/music_video/%s' % video_path, | |
36 | 'format_id': '%sp' % height, | |
4e8cc1e9 | 37 | 'height': int(height), |
7cf97daf | 38 | } for height, video_path in re.findall(r"RJ\.video(\d+)p\s*=\s*'/?([^']+)'", webpage)] |
185a7e25 MTP |
39 | |
40 | title = self._og_search_title(webpage) | |
41 | thumbnail = self._og_search_thumbnail(webpage) | |
185a7e25 | 42 | |
7cf97daf S |
43 | upload_date = unified_strdate(self._search_regex( |
44 | r'class="date_added">Date added: ([^<]+)<', | |
45 | webpage, 'upload date', fatal=False)) | |
185a7e25 | 46 | |
7cf97daf S |
47 | view_count = str_to_int(self._search_regex( |
48 | r'class="views">Plays: ([\d,]+)', | |
49 | webpage, 'view count', fatal=False)) | |
50 | like_count = str_to_int(self._search_regex( | |
51 | r'class="rating">([\d,]+) likes', | |
52 | webpage, 'like count', fatal=False)) | |
53 | dislike_count = str_to_int(self._search_regex( | |
54 | r'class="rating">([\d,]+) dislikes', | |
55 | webpage, 'dislike count', fatal=False)) | |
185a7e25 MTP |
56 | |
57 | return { | |
7cf97daf | 58 | 'id': video_id, |
185a7e25 | 59 | 'title': title, |
185a7e25 | 60 | 'thumbnail': thumbnail, |
7cf97daf S |
61 | 'upload_date': upload_date, |
62 | 'view_count': view_count, | |
63 | 'like_count': like_count, | |
64 | 'dislike_count': dislike_count, | |
65 | 'formats': formats, | |
66 | } |