[bilibili] Show georestriction error
[youtube-dl] / youtube_dl / extractor / twitch.py
index 92b6dc1b820eef8e6a7a0b42bd48bfc5d2422e38..948c8ce39e6eb4de1fd4c3746af71f2d8d67a7a7 100644 (file)
@@ -346,6 +346,12 @@ class TwitchStreamIE(TwitchBaseIE):
                 'http://www.twitch.tv/%s/profile' % channel_id,
                 'TwitchProfile', channel_id)
 
+        # Channel name may be typed if different case than the original channel name
+        # (e.g. http://www.twitch.tv/TWITCHPLAYSPOKEMON) that will lead to constructing
+        # an invalid m3u8 URL. Working around by use of original channel name from stream
+        # JSON and fallback to lowercase if it's not available.
+        channel_id = stream.get('channel', {}).get('name') or channel_id.lower()
+
         access_token = self._download_json(
             '%s/api/channels/%s/access_token' % (self._API_BASE, channel_id), channel_id,
             'Downloading channel access token')