[cleanup] Misc (#8968)
[yt-dlp.git] / yt_dlp / extractor / jable.py
blob71fed49ea08c6620112803541c4d7dbc5df79a07
1 import re
3 from .common import InfoExtractor
4 from ..utils import (
5 InAdvancePagedList,
6 int_or_none,
7 orderedSet,
8 unified_strdate,
12 class JableIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?jable\.tv/videos/(?P<id>[\w-]+)'
14 _TESTS = [{
15 'url': 'https://jable.tv/videos/pppd-812/',
16 'md5': 'f1537283a9bc073c31ff86ca35d9b2a6',
17 'info_dict': {
18 'id': 'pppd-812',
19 'ext': 'mp4',
20 'title': 'PPPD-812 只要表現好巨乳女教師吉根柚莉愛就獎勵學生們在白虎穴內射出精液',
21 'description': 'md5:5b6d4199a854f62c5e56e26ccad19967',
22 'thumbnail': r're:^https?://.*\.jpg$',
23 'age_limit': 18,
24 'like_count': int,
25 'view_count': int,
27 }, {
28 'url': 'https://jable.tv/videos/apak-220/',
29 'md5': '71f9239d69ced58ab74a816908847cc1',
30 'info_dict': {
31 'id': 'apak-220',
32 'ext': 'mp4',
33 'title': 'md5:5c3861b7cf80112a6e2b70bccf170824',
34 'description': '',
35 'thumbnail': r're:^https?://.*\.jpg$',
36 'age_limit': 18,
37 'like_count': int,
38 'view_count': int,
39 'upload_date': '20220319',
43 def _real_extract(self, url):
44 video_id = self._match_id(url)
45 webpage = self._download_webpage(url, video_id)
46 formats = self._extract_m3u8_formats(
47 self._search_regex(r'var\s+hlsUrl\s*=\s*\'([^\']+)', webpage, 'hls_url'), video_id, 'mp4', m3u8_id='hls')
49 return {
50 'id': video_id,
51 'title': self._og_search_title(webpage),
52 'description': self._og_search_description(webpage, default=''),
53 'thumbnail': self._og_search_thumbnail(webpage, default=None),
54 'formats': formats,
55 'age_limit': 18,
56 'upload_date': unified_strdate(self._search_regex(
57 r'class="inactive-color">\D+\s+(\d{4}-\d+-\d+)', webpage, 'upload_date', default=None)),
58 'view_count': int_or_none(self._search_regex(
59 r'#icon-eye"></use></svg>\n*<span class="mr-3">([\d ]+)',
60 webpage, 'view_count', default='').replace(' ', '')),
61 'like_count': int_or_none(self._search_regex(
62 r'#icon-heart"></use></svg><span class="count">(\d+)', webpage, 'link_count', default=None)),
66 class JablePlaylistIE(InfoExtractor):
67 _VALID_URL = r'https?://(?:www\.)?jable\.tv/(?:categories|models|tags)/(?P<id>[\w-]+)'
68 _TESTS = [{
69 'url': 'https://jable.tv/models/kaede-karen/',
70 'info_dict': {
71 'id': 'kaede-karen',
72 'title': '楓カレン',
74 'playlist_count': 34,
75 }, {
76 'url': 'https://jable.tv/categories/roleplay/',
77 'only_matching': True,
78 }, {
79 'url': 'https://jable.tv/tags/girl/',
80 'only_matching': True,
83 def _real_extract(self, url):
84 playlist_id = self._match_id(url)
85 webpage = self._download_webpage(url, playlist_id)
87 def page_func(page_num):
88 return [
89 self.url_result(player_url, JableIE)
90 for player_url in orderedSet(re.findall(
91 r'href="(https://jable.tv/videos/[\w-]+/?)"',
92 self._download_webpage(url, playlist_id, query={
93 'mode': 'async',
94 'from': page_num + 1,
95 'function': 'get_block',
96 'block_id': 'list_videos_common_videos_list',
97 }, note=f'Downloading page {page_num + 1}')))]
99 return self.playlist_result(
100 InAdvancePagedList(page_func, int_or_none(self._search_regex(
101 r'from:(\d+)">[^<]+\s*&raquo;', webpage, 'last page number', default=1)), 24),
102 playlist_id, self._search_regex(
103 r'<h2 class="h3-md mb-1">([^<]+)', webpage, 'playlist title', default=None))