]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/radiojavan.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / radiojavan.py
CommitLineData
7cf97daf
S
1import re
2
185a7e25 3from .common import InfoExtractor
6c83e583 4from ..utils import (
93284ff2 5 parse_resolution,
7cf97daf 6 str_to_int,
93284ff2 7 unified_strdate,
0a9a8118 8 urlencode_postdata,
93284ff2 9 urljoin,
185a7e25
MTP
10)
11
7cf97daf 12
185a7e25 13class RadioJavanIE(InfoExtractor):
df773c3d 14 _WORKING = False
185a7e25
MTP
15 _VALID_URL = r'https?://(?:www\.)?radiojavan\.com/videos/video/(?P<id>[^/]+)/?'
16 _TEST = {
17 'url': 'http://www.radiojavan.com/videos/video/chaartaar-ashoobam',
18 'md5': 'e85208ffa3ca8b83534fca9fe19af95b',
19 'info_dict': {
20 'id': 'chaartaar-ashoobam',
21 'ext': 'mp4',
22 'title': 'Chaartaar - Ashoobam',
ec85ded8 23 'thumbnail': r're:^https?://.*\.jpe?g$',
7cf97daf
S
24 'upload_date': '20150215',
25 'view_count': int,
26 'like_count': int,
27 'dislike_count': int,
add96eb9 28 },
185a7e25
MTP
29 }
30
31 def _real_extract(self, url):
7cf97daf 32 video_id = self._match_id(url)
185a7e25 33
0a9a8118 34 download_host = self._download_json(
93284ff2 35 'https://www.radiojavan.com/videos/video_host', video_id,
0a9a8118
H
36 data=urlencode_postdata({'id': video_id}),
37 headers={
38 'Content-Type': 'application/x-www-form-urlencoded',
39 'Referer': url,
93284ff2
S
40 }).get('host', 'https://host1.rjmusicmedia.com')
41
42 webpage = self._download_webpage(url, video_id)
43
44 formats = []
45 for format_id, _, video_path in re.findall(
46 r'RJ\.video(?P<format_id>\d+[pPkK])\s*=\s*(["\'])(?P<url>(?:(?!\2).)+)\2',
47 webpage):
48 f = parse_resolution(format_id)
49 f.update({
50 'url': urljoin(download_host, video_path),
51 'format_id': format_id,
52 })
53 formats.append(f)
185a7e25
MTP
54
55 title = self._og_search_title(webpage)
56 thumbnail = self._og_search_thumbnail(webpage)
185a7e25 57
7cf97daf
S
58 upload_date = unified_strdate(self._search_regex(
59 r'class="date_added">Date added: ([^<]+)<',
60 webpage, 'upload date', fatal=False))
185a7e25 61
7cf97daf
S
62 view_count = str_to_int(self._search_regex(
63 r'class="views">Plays: ([\d,]+)',
64 webpage, 'view count', fatal=False))
65 like_count = str_to_int(self._search_regex(
66 r'class="rating">([\d,]+) likes',
67 webpage, 'like count', fatal=False))
68 dislike_count = str_to_int(self._search_regex(
69 r'class="rating">([\d,]+) dislikes',
70 webpage, 'dislike count', fatal=False))
185a7e25
MTP
71
72 return {
7cf97daf 73 'id': video_id,
185a7e25 74 'title': title,
185a7e25 75 'thumbnail': thumbnail,
7cf97daf
S
76 'upload_date': upload_date,
77 'view_count': view_count,
78 'like_count': like_count,
79 'dislike_count': dislike_count,
80 'formats': formats,
81 }