From 9ce126b52ef9c00d27393cc113a2a1c62f8cb91b Mon Sep 17 00:00:00 2001 From: Mozi <29089388+pzhlkj6612@users.noreply.github.com> Date: Wed, 29 Jan 2025 05:37:47 +0000 Subject: [PATCH] fix regex; fix tests --- yt_dlp/extractor/espn.py | 57 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/yt_dlp/extractor/espn.py b/yt_dlp/extractor/espn.py index 031c78a296..faaa62be9a 100644 --- a/yt_dlp/extractor/espn.py +++ b/yt_dlp/extractor/espn.py @@ -184,20 +184,71 @@ def extract_source(source_url, source_id=None): class ESPNArticleIE(InfoExtractor): - _VALID_URL = r'https?://(?:espn\.go|(?:www\.)?espn)\.com/(?:[^/]+/)*(?P[^/]+)' + _VALID_URL = r'https?://(?:espn\.go|(?:www\.)?espn)\.com(?:/[^/]+)*(?:[?/]gameId[/=]|/id/)(?P\d+)' _TESTS = [{ 'url': 'https://www.espn.com/college-football/game/_/gameId/401520427', 'info_dict': { 'id': '401520427', 'title': 'Alabama 27-24 Auburn (Nov 25, 2023) Final Score - ESPN', 'description': 'Game summary of the Alabama Crimson Tide vs. Auburn Tigers NCAAF game, final score 27-24, from November 25, 2023 on ESPN.', + }, + 'playlist_count': 0, + }, { + 'url': 'https://www.espn.com/college-football/game/_/gameId/401015019/charlotte-mtsu', + 'info_dict': { + 'id': '401015019', + 'title': 'Middle Tennessee 21-13 Charlotte (Oct 20, 2018) Final Score - ESPN', + 'description': 'Game summary of the Middle Tennessee Blue Raiders vs. Charlotte 49ers NCAAF game, final score 21-13, from October 20, 2018 on ESPN.', 'entries': [{ - 'id': '38979520', + 'id': '25035207', }, { - 'id': '38981707', + 'id': '25035930', + }, { + 'id': '25035232', + }, { + 'id': '25034741', + }], + }, + 'playlist_count': 4, + }, { + 'url': 'https://www.espn.com/college-football/game/_/gameId/401015037/charlotte-marshall', + 'info_dict': { + 'id': '401015037', + 'title': 'Marshall 30-13 Charlotte (Nov 10, 2018) Final Score - ESPN', + 'description': 'Game summary of the Marshall Thundering Herd vs. Charlotte 49ers NCAAF game, final score 30-13, from November 10, 2018 on ESPN.', + 'entries': [{ + 'id': '25236419', + }, { + 'id': '25235710', }], }, 'playlist_count': 2, + }, { + 'url': 'https://www.espn.com/college-football/game/_/gameId/401015044', + 'info_dict': { + 'id': '401015044', + 'title': 'Florida International 42-35 Charlotte (Nov 17, 2018) Final Score - ESPN', + 'description': 'Game summary of the Florida International Panthers vs. Charlotte 49ers NCAAF game, final score 42-35, from November 17, 2018 on ESPN.', + 'entries': [{ + 'id': '25304950', + }, { + 'id': '25304741', + }, { + 'id': '25304716', + }], + }, + 'playlist_count': 3, + }, { + 'url': 'https://www.espn.com/nba/recap?gameId=400793781', + 'info_dict': { + 'id': '400793781', + 'title': 'Wizards 104-98 Hawks (May 3, 2015) Game Recap - ESPN', + 'description': 'Expert recap and game analysis of the Washington Wizards vs. Atlanta Hawks NBA game from May 3, 2015 on ESPN.', + 'entries': [{ + 'id': '12812586', + }], + }, + 'playlist_count': 1, }, { 'url': 'http://espn.go.com/nba/recap?gameId=400793786', 'only_matching': True,