]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/jable.py
[extractor/FranceCulture] Fix extractor (#3874)
[yt-dlp.git] / yt_dlp / extractor / jable.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5 InAdvancePagedList,
6 int_or_none,
7 orderedSet,
8 unified_strdate,
9 )
10
11
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,
26 },
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',
40 },
41 }]
42
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')
48 self._sort_formats(formats)
49
50 return {
51 'id': video_id,
52 'title': self._og_search_title(webpage),
53 'description': self._og_search_description(webpage, default=''),
54 'thumbnail': self._og_search_thumbnail(webpage, default=None),
55 'formats': formats,
56 'age_limit': 18,
57 'upload_date': unified_strdate(self._search_regex(
58 r'class="inactive-color">\D+\s+(\d{4}-\d+-\d+)', webpage, 'upload_date', default=None)),
59 'view_count': int_or_none(self._search_regex(
60 r'#icon-eye"></use></svg>\n*<span class="mr-3">([\d ]+)',
61 webpage, 'view_count', default='').replace(' ', '')),
62 'like_count': int_or_none(self._search_regex(
63 r'#icon-heart"></use></svg><span class="count">(\d+)', webpage, 'link_count', default=None)),
64 }
65
66
67 class JablePlaylistIE(InfoExtractor):
68 _VALID_URL = r'https?://(?:www\.)?jable.tv/(?:categories|models|tags)/(?P<id>[\w-]+)'
69 _TESTS = [{
70 'url': 'https://jable.tv/models/kaede-karen/',
71 'info_dict': {
72 'id': 'kaede-karen',
73 'title': '楓カレン',
74 },
75 'playlist_count': 34,
76 }, {
77 'url': 'https://jable.tv/categories/roleplay/',
78 'only_matching': True,
79 }, {
80 'url': 'https://jable.tv/tags/girl/',
81 'only_matching': True,
82 }]
83
84 def _real_extract(self, url):
85 playlist_id = self._match_id(url)
86 webpage = self._download_webpage(url, playlist_id)
87
88 def page_func(page_num):
89 return [
90 self.url_result(player_url, JableIE)
91 for player_url in orderedSet(re.findall(
92 r'href="(https://jable.tv/videos/[\w-]+/?)"',
93 self._download_webpage(url, playlist_id, query={
94 'mode': 'async',
95 'from': page_num + 1,
96 'function': 'get_block',
97 'block_id': 'list_videos_common_videos_list',
98 }, note=f'Downloading page {page_num + 1}')))]
99
100 return self.playlist_result(
101 InAdvancePagedList(page_func, int_or_none(self._search_regex(
102 r'from:(\d+)">[^<]+\s*&raquo;', webpage, 'last page number', default=1)), 24),
103 playlist_id, self._search_regex(
104 r'<h2 class="h3-md mb-1">([^<]+)', webpage, 'playlist title', default=None))