From ca7e9e1cd1704b81562962f135464dbaefd22699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20El=20Amri?= Date: Sat, 20 Jul 2019 20:35:58 +0200 Subject: [PATCH] [twitch.py] Improved _VALID_URL --- youtube_dl/extractor/extractors.py | 2 +- youtube_dl/extractor/twitch.py | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 555fadfaf..2b26cb347 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1235,10 +1235,10 @@ from .twitch import ( TwitchChapterIE, TwitchVodIE, TwitchProfileIE, - TwitchAllVideosIE, TwitchUploadsIE, TwitchPastBroadcastsIE, TwitchHighlightsIE, + TwitchAllVideosIE, TwitchStreamIE, TwitchClipsIE, ) diff --git a/youtube_dl/extractor/twitch.py b/youtube_dl/extractor/twitch.py index bc8f32936..6a1015ce5 100644 --- a/youtube_dl/extractor/twitch.py +++ b/youtube_dl/extractor/twitch.py @@ -431,13 +431,17 @@ class TwitchProfileIE(TwitchPlaylistBaseIE): class TwitchVideosBaseIE(TwitchPlaylistBaseIE): - _VALID_URL_VIDEOS_BASE = r'%s/(?P[^/]+)/videos/?\?(?:.*?[&;])??filter=%%s' % TwitchBaseIE._VALID_URL_BASE + _VALID_URL_VIDEOS_BASE = r'%s/(?P[^/]+)/videos' % TwitchBaseIE._VALID_URL_BASE + _VALID_URL_VIDEOS_FILTERS = r'\?(?:.*?[&;])??filter=%s' _PLAYLIST_PATH = TwitchPlaylistBaseIE._PLAYLIST_PATH + '&broadcast_type=' class TwitchAllVideosIE(TwitchVideosBaseIE): IE_NAME = 'twitch:videos:all' - _VALID_URL = TwitchVideosBaseIE._VALID_URL_VIDEOS_BASE % 'all' + _VALID_URL = '%s(?:/?(?:%s)|[^/?]+?/?)?' % ( + TwitchVideosBaseIE._VALID_URL_VIDEOS_BASE, + TwitchVideosBaseIE._VALID_URL_VIDEOS_FILTERS % 'all' + ) _PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'archive,upload,highlight' _PLAYLIST_TYPE = 'all videos' @@ -448,12 +452,18 @@ class TwitchAllVideosIE(TwitchVideosBaseIE): 'title': 'Spamfish', }, 'playlist_mincount': 869, + }, { + 'url': 'https://m.twitch.tv/spamfish/videos/', + 'only_matching': True, }] class TwitchUploadsIE(TwitchVideosBaseIE): IE_NAME = 'twitch:videos:uploads' - _VALID_URL = TwitchVideosBaseIE._VALID_URL_VIDEOS_BASE % 'uploads' + _VALID_URL = '%s/?(?:%s)' % ( + TwitchVideosBaseIE._VALID_URL_VIDEOS_BASE, + TwitchVideosBaseIE._VALID_URL_VIDEOS_FILTERS % 'uploads' + ) _PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'upload' _PLAYLIST_TYPE = 'uploads' @@ -469,7 +479,10 @@ class TwitchUploadsIE(TwitchVideosBaseIE): class TwitchPastBroadcastsIE(TwitchVideosBaseIE): IE_NAME = 'twitch:videos:past-broadcasts' - _VALID_URL = TwitchVideosBaseIE._VALID_URL_VIDEOS_BASE % 'archives' + _VALID_URL = '%s/?(?:%s)' % ( + TwitchVideosBaseIE._VALID_URL_VIDEOS_BASE, + TwitchVideosBaseIE._VALID_URL_VIDEOS_FILTERS % 'archives' + ) _PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'archive' _PLAYLIST_TYPE = 'past broadcasts' @@ -485,7 +498,10 @@ class TwitchPastBroadcastsIE(TwitchVideosBaseIE): class TwitchHighlightsIE(TwitchVideosBaseIE): IE_NAME = 'twitch:videos:highlights' - _VALID_URL = TwitchVideosBaseIE._VALID_URL_VIDEOS_BASE % 'highlights' + _VALID_URL = '%s/?(?:%s)' % ( + TwitchVideosBaseIE._VALID_URL_VIDEOS_BASE, + TwitchVideosBaseIE._VALID_URL_VIDEOS_FILTERS % 'highlights' + ) _PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'highlight' _PLAYLIST_TYPE = 'highlights'