mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.6 KiB
Python
81 lines
2.6 KiB
Python
10 years ago
|
import re
|
||
|
|
||
10 years ago
|
from .common import InfoExtractor
|
||
9 years ago
|
from ..utils import (
|
||
6 years ago
|
parse_resolution,
|
||
10 years ago
|
str_to_int,
|
||
6 years ago
|
unified_strdate,
|
||
6 years ago
|
urlencode_postdata,
|
||
6 years ago
|
urljoin,
|
||
10 years ago
|
)
|
||
|
|
||
10 years ago
|
|
||
10 years ago
|
class RadioJavanIE(InfoExtractor):
|
||
|
_VALID_URL = r'https?://(?:www\.)?radiojavan\.com/videos/video/(?P<id>[^/]+)/?'
|
||
|
_TEST = {
|
||
|
'url': 'http://www.radiojavan.com/videos/video/chaartaar-ashoobam',
|
||
|
'md5': 'e85208ffa3ca8b83534fca9fe19af95b',
|
||
|
'info_dict': {
|
||
|
'id': 'chaartaar-ashoobam',
|
||
|
'ext': 'mp4',
|
||
|
'title': 'Chaartaar - Ashoobam',
|
||
8 years ago
|
'thumbnail': r're:^https?://.*\.jpe?g$',
|
||
10 years ago
|
'upload_date': '20150215',
|
||
|
'view_count': int,
|
||
|
'like_count': int,
|
||
|
'dislike_count': int,
|
||
10 years ago
|
}
|
||
|
}
|
||
|
|
||
|
def _real_extract(self, url):
|
||
10 years ago
|
video_id = self._match_id(url)
|
||
10 years ago
|
|
||
6 years ago
|
download_host = self._download_json(
|
||
6 years ago
|
'https://www.radiojavan.com/videos/video_host', video_id,
|
||
6 years ago
|
data=urlencode_postdata({'id': video_id}),
|
||
|
headers={
|
||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||
|
'Referer': url,
|
||
6 years ago
|
}).get('host', 'https://host1.rjmusicmedia.com')
|
||
|
|
||
|
webpage = self._download_webpage(url, video_id)
|
||
|
|
||
|
formats = []
|
||
|
for format_id, _, video_path in re.findall(
|
||
|
r'RJ\.video(?P<format_id>\d+[pPkK])\s*=\s*(["\'])(?P<url>(?:(?!\2).)+)\2',
|
||
|
webpage):
|
||
|
f = parse_resolution(format_id)
|
||
|
f.update({
|
||
|
'url': urljoin(download_host, video_path),
|
||
|
'format_id': format_id,
|
||
|
})
|
||
|
formats.append(f)
|
||
10 years ago
|
|
||
|
title = self._og_search_title(webpage)
|
||
|
thumbnail = self._og_search_thumbnail(webpage)
|
||
|
|
||
10 years ago
|
upload_date = unified_strdate(self._search_regex(
|
||
|
r'class="date_added">Date added: ([^<]+)<',
|
||
|
webpage, 'upload date', fatal=False))
|
||
10 years ago
|
|
||
10 years ago
|
view_count = str_to_int(self._search_regex(
|
||
|
r'class="views">Plays: ([\d,]+)',
|
||
|
webpage, 'view count', fatal=False))
|
||
|
like_count = str_to_int(self._search_regex(
|
||
|
r'class="rating">([\d,]+) likes',
|
||
|
webpage, 'like count', fatal=False))
|
||
|
dislike_count = str_to_int(self._search_regex(
|
||
|
r'class="rating">([\d,]+) dislikes',
|
||
|
webpage, 'dislike count', fatal=False))
|
||
10 years ago
|
|
||
|
return {
|
||
10 years ago
|
'id': video_id,
|
||
10 years ago
|
'title': title,
|
||
|
'thumbnail': thumbnail,
|
||
10 years ago
|
'upload_date': upload_date,
|
||
|
'view_count': view_count,
|
||
|
'like_count': like_count,
|
||
|
'dislike_count': dislike_count,
|
||
|
'formats': formats,
|
||
|
}
|