Compare commits

...

6 Commits

Author SHA1 Message Date
Tristan Charpentier
ebedb7f01e
Update yt_dlp/extractor/rinsefm.py
Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
2023-12-15 14:53:02 -05:00
Tristan Charpentier
abf6550b65 [RinseFM] Cleanup for lint 2023-12-15 14:37:56 -05:00
Tristan Charpentier
b97478b8e8 [RinseFM] Remove unused info var 2023-12-15 14:35:39 -05:00
Tristan Charpentier
fb975fce8a [RinseFM] Use built-in date parse and inline metadata 2023-12-15 14:34:27 -05:00
Tristan Charpentier
48c04b4ee3 [RinseFM] Remove unused imports 2023-12-15 14:07:22 -05:00
Tristan Charpentier
48c38b3d0f [RinseFM] Use built-in nextjs helper method 2023-12-15 14:05:26 -05:00

View File

@ -1,12 +1,9 @@
import re
import json
from datetime import datetime, timezone
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import format_field, parse_iso8601
class RinseFMIE(InfoExtractor): class RinseFMIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?rinse\.fm/episodes/(?P<id>.+)' _VALID_URL = r'https?://(?:www\.)?rinse\.fm/episodes/(?P<id>[^/?#]+)'
_TESTS = [{ _TESTS = [{
'url': 'https://rinse.fm/episodes/cameo-blush-01-09-2023-2300/', 'url': 'https://rinse.fm/episodes/cameo-blush-01-09-2023-2300/',
'md5': '9284abbd785e6b86e67d1cdca6224feb', 'md5': '9284abbd785e6b86e67d1cdca6224feb',
@ -15,6 +12,8 @@ class RinseFMIE(InfoExtractor):
'ext': 'mp3', 'ext': 'mp3',
'title': 'Cameo Blush - 01/09/2023 - 23:00', 'title': 'Cameo Blush - 01/09/2023 - 23:00',
'thumbnail': r're:^https?://.*\.JPG$', 'thumbnail': r're:^https?://.*\.JPG$',
'release_timestamp': 1693522800,
'release_date': '20230831'
} }
}] }]
@ -22,24 +21,13 @@ class RinseFMIE(InfoExtractor):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
response = re.findall(r'<script[^>]*id\s*=\s*[\'"]__NEXT_DATA__[\'"][^>]*>(.*?)<\/script>', webpage, re.DOTALL) entry = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['entry']
info = json.loads(response[0])
entry = info['props']['pageProps']['entry']
track_id = entry['id']
title = entry['title']
date_obj = datetime.fromisoformat(entry['episodeDate'])
unix_timestamp = int(date_obj.replace(tzinfo=timezone.utc).timestamp())
url = entry['fileUrl']
thumbnail = "https://rinse.imgix.net/media/" + entry['featuredImage'][0]['filename']
return { return {
'id': track_id, 'id': entry['id'],
'title': title, 'title': entry.get('title'),
'url': url, 'url': entry['fileUrl'],
'release_timestamp': unix_timestamp, 'vcodec': 'none',
'thumbnail': thumbnail 'release_timestamp': parse_iso8601(entry.get('episodeDate')),
'thumbnail': format_field(
entry, [('featuredImage', 0, 'filename')], 'https://rinse.imgix.net/media/%s', default=None),
} }