[ie/soundcloud] Various fixes (#11820)
[yt-dlp.git] / yt_dlp / extractor / erocast.py
blobbd22137bee52dcdd8ca5cb32a8d813aedae9f5c6
1 from .common import InfoExtractor
2 from ..utils import (
3 int_or_none,
4 parse_iso8601,
5 str_or_none,
6 traverse_obj,
7 url_or_none,
11 class ErocastIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?erocast\.me/track/(?P<id>[0-9]+)'
13 _TESTS = [{
14 'url': 'https://erocast.me/track/9787/f',
15 'md5': 'af63b91f5f231096aba54dd682abea3b',
16 'info_dict': {
17 'id': '9787',
18 'title': '[F4M] Your roommate, who is definitely not possessed by an alien, suddenly wants to fuck you',
19 'url': 'https://erocast.s3.us-east-2.wasabisys.com/1220419/track.m3u8',
20 'ext': 'm4a',
21 'age_limit': 18,
22 'release_timestamp': 1696178652,
23 'release_date': '20231001',
24 'modified_timestamp': int,
25 'modified_date': str,
26 'description': 'ExtraTerrestrial Tuesday!',
27 'uploader': 'clarissaisshy',
28 'uploader_id': '8113',
29 'uploader_url': 'https://erocast.me/clarissaisshy',
30 'thumbnail': 'https://erocast.s3.us-east-2.wasabisys.com/1220418/conversions/1696179247-lg.jpg',
31 'duration': 2307,
32 'view_count': int,
33 'comment_count': int,
34 'webpage_url': 'https://erocast.me/track/9787/f4m-your-roommate-who-is-definitely-not-possessed-by-an-alien-suddenly-wants-to-fuck-you',
38 def _real_extract(self, url):
39 video_id = self._match_id(url)
40 webpage = self._download_webpage(url, video_id)
41 data = self._search_json(
42 rf'<script>\s*var song_data_{video_id}\s*=', webpage, 'data', video_id, end_pattern=r'</script>')
44 return {
45 'id': video_id,
46 'formats': self._extract_m3u8_formats(
47 data.get('file_url') or data['stream_url'], video_id, 'm4a', m3u8_id='hls'),
48 'age_limit': 18,
49 **traverse_obj(data, {
50 'title': ('title', {str}),
51 'description': ('description', {str}),
52 'release_timestamp': ('created_at', {parse_iso8601}),
53 'modified_timestamp': ('updated_at', {parse_iso8601}),
54 'uploader': ('user', 'name', {str}),
55 'uploader_id': ('user', 'id', {str_or_none}),
56 'uploader_url': ('user', 'permalink_url', {url_or_none}),
57 'thumbnail': ('artwork_url', {url_or_none}),
58 'duration': ('duration', {int_or_none}),
59 'view_count': ('plays', {int_or_none}),
60 'comment_count': ('comment_count', {int_or_none}),
61 'webpage_url': ('permalink_url', {url_or_none}),
62 }),