From b4a8df0eba85ad98c79ebe44f4759113b8fe57db Mon Sep 17 00:00:00 2001 From: Rohan Wadhwa Date: Fri, 25 Apr 2025 20:14:26 -0400 Subject: [PATCH] playerfm Add extractor --- yt_dlp/extractor/_extractors.py | 1 + yt_dlp/extractor/playerfm.py | 64 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 yt_dlp/extractor/playerfm.py diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py index 047af92820..e0471a8c8e 100644 --- a/yt_dlp/extractor/_extractors.py +++ b/yt_dlp/extractor/_extractors.py @@ -1559,6 +1559,7 @@ PlatziCourseIE, PlatziIE, ) +from .playerfm import PlayerFmIE from .playplustv import PlayPlusTVIE from .playsuisse import PlaySuisseIE from .playtvak import PlaytvakIE diff --git a/yt_dlp/extractor/playerfm.py b/yt_dlp/extractor/playerfm.py new file mode 100644 index 0000000000..e6052af56d --- /dev/null +++ b/yt_dlp/extractor/playerfm.py @@ -0,0 +1,64 @@ + +from .common import ExtractorError, InfoExtractor +from ..utils import determine_ext, join_nonempty + + +class PlayerFmIE(InfoExtractor): + _VALID_URL = r'https?://(?:www.)?player.fm/(?:series)?/[a-z\d-]+/(?P[a-z\d-]+)' + _TESTS = [{ + 'url': 'https://player.fm/series/chapo-trap-house/movie-mindset-33-casino-feat-felix', + 'info_dict': { + 'id': 'movie-mindset-33-casino-feat-felix', + 'thumbnail': r're:^https://.*\.(jpg|png)', + 'title': 'Movie Mindset 33 - Casino feat. Felix', + 'creators': ['Chapo Trap House'], + 'description': 'The first episode of this season of Movie Mindset is free for all listeners as always. To listen to the rest of the season, subscribe at www.patreon.com/chapotraphouse When you love movies, you’ve got to watch them. There’s no other way…Movie Mindset Season 3 commences with our first ever single feature on the most referenced movie in Chapo Trap House history: Martin Scorsese’s masterpiece Casino. Will and Hesse are joined by Felix to take a kaleidoscopic and dizzying dive into the inferno of American greed that is Las Vegas. Anchored by a triumvirate of all career great performances from Robert De Niro, Sharon Stone and Joe Pesci in FULL PSYCHO MODE, Casino is by equal turns hilarious and stomach turning and stands alone as Scorsese’s grandest and most generous examination of evil and the tragic flaws that doom us all. Should you listen even if you haven’t seen this movie? Why take a chance? At least that the way we feel about it.', + 'duration': 6830, + 'ext': 'mp3', + }, + }, { + 'url': 'https://player.fm/series/nbc-nightly-news-with-lester-holt/thursday-april-24-2025', + 'info_dict': { + 'id': 'thursday-april-24-2025', + 'thumbnail': r're:^https://.*\.(jpg|png)', + 'title': 'Thursday, April 24, 2025', + 'creators': ['Lester Holt', 'NBC News'], + 'description': '

Trump urges Putin to \'STOP\' after deadly Russian strike on Ukraine; More than 90,000 people have paid their respects to Pope Francis; Miami shooting leaves three injured; and more on tonight’s broadcast.

', + 'duration': 1250, + 'ext': 'mp3', + }, + }, { + 'url': 'https://player.fm/series/soccer-101/ep-109-its-kicking-off-how-have-the-rules-for-kickoff-changed-what-are-the-best-approaches-to-getting-the-game-underway-and-how-could-we-improve-on-the-present-system', + 'info_dict': { + 'id': 'ep-109-its-kicking-off-how-have-the-rules-for-kickoff-changed-what-are-the-best-approaches-to-getting-the-game-underway-and-how-could-we-improve-on-the-present-system', + 'thumbnail': r're:^https://.*\.(jpg|png)', + 'title': '#109 It\'s kicking off! How have the rules for kickoff changed, what are the best approaches to getting the game underway, and how could we improve on the present system?', + 'creators': ['Soccer Roundup'], + 'description': '`

Ryan is joined by Joe and Taylor to answer the age old question (in your best Jerry Seinfeld impression), "What\'s the deal with kickoff?!" How does a game get underway, how have the rules regarding kickoff evolved since the mid-1800s, what are the different approaches to getting your tactics right from kickoff, how could we improve upon the current system, and much much more!

The Soccer 101 theme, and plenty of other excellent music, can be found right here: https://aerialist.bandcamp.com.

`', + 'duration': 1765, + 'ext': 'mp3', + }, + }] + + def _real_extract(self, url): + # podcast url is always after last backlash + video_id = self._match_id(url) + data = self._download_json(url + '.json', None) + + thumbnail = data['image']['url'] if 'image' in data else data['series']['image']['url'] + video_url = join_nonempty('https', self._search_regex(r'redirect.mp3/(.*)', data['url'], 'redirect'), delim='://') + if not video_url: + raise ExtractorError('URL to podcast not found', expected=True) + formats = [{ + 'url': video_url, + 'ext': determine_ext(video_url, default_ext=''), + }] + return { + 'id': video_id, + 'thumbnail': thumbnail, + 'title': data['title'], + 'creators': data['series']['author'].split(', '), + 'description': data['description'], + 'duration': data['duration'], + 'formats': formats, + }