[twitch] Add support for mobile URLs (closes #16146)

pull/8/head
Sergey M․ 7 years ago
parent f7f9757efc
commit fce7962691
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

@ -28,7 +28,7 @@ from ..utils import (
class TwitchBaseIE(InfoExtractor): class TwitchBaseIE(InfoExtractor):
_VALID_URL_BASE = r'https?://(?:(?:www|go)\.)?twitch\.tv' _VALID_URL_BASE = r'https?://(?:(?:www|go|m)\.)?twitch\.tv'
_API_BASE = 'https://api.twitch.tv' _API_BASE = 'https://api.twitch.tv'
_USHER_BASE = 'https://usher.ttvnw.net' _USHER_BASE = 'https://usher.ttvnw.net'
@ -226,7 +226,7 @@ class TwitchVodIE(TwitchItemBaseIE):
_VALID_URL = r'''(?x) _VALID_URL = r'''(?x)
https?:// https?://
(?: (?:
(?:(?:www|go)\.)?twitch\.tv/(?:[^/]+/v|videos)/| (?:(?:www|go|m)\.)?twitch\.tv/(?:[^/]+/v|videos)/|
player\.twitch\.tv/\?.*?\bvideo=v player\.twitch\.tv/\?.*?\bvideo=v
) )
(?P<id>\d+) (?P<id>\d+)
@ -279,6 +279,9 @@ class TwitchVodIE(TwitchItemBaseIE):
}, { }, {
'url': 'https://www.twitch.tv/videos/6528877', 'url': 'https://www.twitch.tv/videos/6528877',
'only_matching': True, 'only_matching': True,
}, {
'url': 'https://m.twitch.tv/beagsandjam/v/247478721',
'only_matching': True,
}] }]
def _real_extract(self, url): def _real_extract(self, url):
@ -390,14 +393,17 @@ class TwitchProfileIE(TwitchPlaylistBaseIE):
_VALID_URL = r'%s/(?P<id>[^/]+)/profile/?(?:\#.*)?$' % TwitchBaseIE._VALID_URL_BASE _VALID_URL = r'%s/(?P<id>[^/]+)/profile/?(?:\#.*)?$' % TwitchBaseIE._VALID_URL_BASE
_PLAYLIST_TYPE = 'profile' _PLAYLIST_TYPE = 'profile'
_TEST = { _TESTS = [{
'url': 'http://www.twitch.tv/vanillatv/profile', 'url': 'http://www.twitch.tv/vanillatv/profile',
'info_dict': { 'info_dict': {
'id': 'vanillatv', 'id': 'vanillatv',
'title': 'VanillaTV', 'title': 'VanillaTV',
}, },
'playlist_mincount': 412, 'playlist_mincount': 412,
} }, {
'url': 'http://m.twitch.tv/vanillatv/profile',
'only_matching': True,
}]
class TwitchVideosBaseIE(TwitchPlaylistBaseIE): class TwitchVideosBaseIE(TwitchPlaylistBaseIE):
@ -411,14 +417,17 @@ class TwitchAllVideosIE(TwitchVideosBaseIE):
_PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'archive,upload,highlight' _PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'archive,upload,highlight'
_PLAYLIST_TYPE = 'all videos' _PLAYLIST_TYPE = 'all videos'
_TEST = { _TESTS = [{
'url': 'https://www.twitch.tv/spamfish/videos/all', 'url': 'https://www.twitch.tv/spamfish/videos/all',
'info_dict': { 'info_dict': {
'id': 'spamfish', 'id': 'spamfish',
'title': 'Spamfish', 'title': 'Spamfish',
}, },
'playlist_mincount': 869, 'playlist_mincount': 869,
} }, {
'url': 'https://m.twitch.tv/spamfish/videos/all',
'only_matching': True,
}]
class TwitchUploadsIE(TwitchVideosBaseIE): class TwitchUploadsIE(TwitchVideosBaseIE):
@ -427,14 +436,17 @@ class TwitchUploadsIE(TwitchVideosBaseIE):
_PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'upload' _PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'upload'
_PLAYLIST_TYPE = 'uploads' _PLAYLIST_TYPE = 'uploads'
_TEST = { _TESTS = [{
'url': 'https://www.twitch.tv/spamfish/videos/uploads', 'url': 'https://www.twitch.tv/spamfish/videos/uploads',
'info_dict': { 'info_dict': {
'id': 'spamfish', 'id': 'spamfish',
'title': 'Spamfish', 'title': 'Spamfish',
}, },
'playlist_mincount': 0, 'playlist_mincount': 0,
} }, {
'url': 'https://m.twitch.tv/spamfish/videos/uploads',
'only_matching': True,
}]
class TwitchPastBroadcastsIE(TwitchVideosBaseIE): class TwitchPastBroadcastsIE(TwitchVideosBaseIE):
@ -443,14 +455,17 @@ class TwitchPastBroadcastsIE(TwitchVideosBaseIE):
_PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'archive' _PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'archive'
_PLAYLIST_TYPE = 'past broadcasts' _PLAYLIST_TYPE = 'past broadcasts'
_TEST = { _TESTS = [{
'url': 'https://www.twitch.tv/spamfish/videos/past-broadcasts', 'url': 'https://www.twitch.tv/spamfish/videos/past-broadcasts',
'info_dict': { 'info_dict': {
'id': 'spamfish', 'id': 'spamfish',
'title': 'Spamfish', 'title': 'Spamfish',
}, },
'playlist_mincount': 0, 'playlist_mincount': 0,
} }, {
'url': 'https://m.twitch.tv/spamfish/videos/past-broadcasts',
'only_matching': True,
}]
class TwitchHighlightsIE(TwitchVideosBaseIE): class TwitchHighlightsIE(TwitchVideosBaseIE):
@ -459,14 +474,17 @@ class TwitchHighlightsIE(TwitchVideosBaseIE):
_PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'highlight' _PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'highlight'
_PLAYLIST_TYPE = 'highlights' _PLAYLIST_TYPE = 'highlights'
_TEST = { _TESTS = [{
'url': 'https://www.twitch.tv/spamfish/videos/highlights', 'url': 'https://www.twitch.tv/spamfish/videos/highlights',
'info_dict': { 'info_dict': {
'id': 'spamfish', 'id': 'spamfish',
'title': 'Spamfish', 'title': 'Spamfish',
}, },
'playlist_mincount': 805, 'playlist_mincount': 805,
} }, {
'url': 'https://m.twitch.tv/spamfish/videos/highlights',
'only_matching': True,
}]
class TwitchStreamIE(TwitchBaseIE): class TwitchStreamIE(TwitchBaseIE):
@ -474,7 +492,7 @@ class TwitchStreamIE(TwitchBaseIE):
_VALID_URL = r'''(?x) _VALID_URL = r'''(?x)
https?:// https?://
(?: (?:
(?:(?:www|go)\.)?twitch\.tv/| (?:(?:www|go|m)\.)?twitch\.tv/|
player\.twitch\.tv/\?.*?\bchannel= player\.twitch\.tv/\?.*?\bchannel=
) )
(?P<id>[^/#?]+) (?P<id>[^/#?]+)
@ -508,6 +526,9 @@ class TwitchStreamIE(TwitchBaseIE):
}, { }, {
'url': 'https://go.twitch.tv/food', 'url': 'https://go.twitch.tv/food',
'only_matching': True, 'only_matching': True,
}, {
'url': 'https://m.twitch.tv/food',
'only_matching': True,
}] }]
@classmethod @classmethod

Loading…
Cancel
Save