[twitch.py] Improved _VALID_URL

This commit is contained in:
Léo El Amri 2019-07-20 20:35:58 +02:00
parent a7d44de6da
commit ca7e9e1cd1
2 changed files with 22 additions and 6 deletions

View File

@ -1235,10 +1235,10 @@ from .twitch import (
TwitchChapterIE,
TwitchVodIE,
TwitchProfileIE,
TwitchAllVideosIE,
TwitchUploadsIE,
TwitchPastBroadcastsIE,
TwitchHighlightsIE,
TwitchAllVideosIE,
TwitchStreamIE,
TwitchClipsIE,
)

View File

@ -431,13 +431,17 @@ class TwitchProfileIE(TwitchPlaylistBaseIE):
class TwitchVideosBaseIE(TwitchPlaylistBaseIE):
_VALID_URL_VIDEOS_BASE = r'%s/(?P<id>[^/]+)/videos/?\?(?:.*?[&;])??filter=%%s' % TwitchBaseIE._VALID_URL_BASE
_VALID_URL_VIDEOS_BASE = r'%s/(?P<id>[^/]+)/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'