Some of the streams I watch have their past broadcasts behind a subscriber paywall, that requires you're oauth token to be sent to the api. The following changes will enable to you play these streams, if you have your user's oauth token. I'm not a python coder, so this might not be to optimal way to solve it, but it works:
.kodi/userdata/addon_data/plugin.video.twitch/settings.xml add
Code:
<setting id="oauth_token" value="YOUR_OAUTH_TOKEN_HERE" />
.kodi/addons/plugin.video.twitch/resources/lib/utils.py add
Code:
def getOauthToken():
oauthtoken = PLUGIN.get_setting('oauth_token', unicode)
if not oauthtoken:
PLUGIN.open_settings()
oauthtoken = PLUGIN.get_setting('oauth_token', unicode)
return oauthtoken
between return username (line 23) and def getVideoQuality(quality=''): (linje 26?)
Result
Code:
def getUserName():
username = PLUGIN.get_setting('username', unicode).lower()
if not username:
PLUGIN.open_settings()
username = PLUGIN.get_setting('username', unicode).lower()
return username
def getOauthToken():
oauthtoken = PLUGIN.get_setting('oauth_token', unicode)
if not oauthtoken:
PLUGIN.open_settings()
oauthtoken = PLUGIN.get_setting('oauth_token', unicode)
return oauthtoken
def getVideoQuality(quality=''):
In .kodi/addons/plugin.video.twitch/resources/lib/routes.py, add
Code:
oauthtoken = utils.getOauthToken()
after videoQuality = utils.getVideoQuality(quality) on line 198 (in the playVideo method)
Change this line, it's a few lines further down
Code:
# from
simplePlaylist = TWITCHTV.getVideoPlaylist(_id, videoQuality)
# to
simplePlaylist = TWITCHTV.getVideoPlaylist(_id, videoQuality, oauthtoken)
In .kodi/addons/plugin.video.twitch/resources/lib/twitch/api.py update getVideoPlaylist method
Code:
# from
def getVideoPlaylist(self, _id, maxQuality):
playlist = [(), ()]
if _id.startswith(('a', 'c')):
playlist = self.__getVideoPlaylistChunkedArchived(_id, maxQuality)
elif _id.startswith('v'):
playlist = self.__getVideoPlaylistVod(_id, maxQuality)
return playlist
# to
def getVideoPlaylist(self, _id, maxQuality, oauthtoken):
playlist = [(), ()]
if _id.startswith(('a', 'c')):
playlist = self.__getVideoPlaylistChunkedArchived(_id, maxQuality, oauthtoken)
elif _id.startswith('v'):
playlist = self.__getVideoPlaylistVod(_id, maxQuality, oauthtoken)
return playlist
and the __getVideoPlaylistVod method
Code:
# from
def __getVideoPlaylistVod(self, _id, maxQuality):
playlist = [('', ())]
vodid = _id[1:]
url = Urls.VOD_TOKEN.format(vodid)
access_token = self.scraper.getJson(url)
# to
def __getVideoPlaylistVod(self, _id, maxQuality, oauthtoken):
playlist = [('', ())]
vodid = _id[1:]
url = Urls.VOD_TOKEN.format(vodid) + '?oauth_token=' + oauthtoken
access_token = self.scraper.getJson(url)
and the __getVideoPlaylistChunkedArchived method
Code:
# from
def __getVideoPlaylistChunkedArchived(self, _id, maxQuality):
vidChunks = self.__getChunkedVideo(_id)
# to
def __getVideoPlaylistChunkedArchived(self, _id, maxQuality, oauthtoken):
vidChunks = self.__getChunkedVideo(_id, oauthtoken)
and the __getChunkedVideo method
Code:
# from
def __getChunkedVideo(self, _id):
# twitch site queries chunked playlists also with token
# not necessary yet but might change (similar to vod playlists)
url = Urls.VIDEO_PLAYLIST.format(_id)
# to
def __getChunkedVideo(self, _id, oauthtoken):
# twitch site queries chunked playlists also with token
# not necessary yet but might change (similar to vod playlists)
url = Urls.VIDEO_PLAYLIST.format(_id) + '?oauth_token=' + oauthtoken
Here is one online service to get your twitch oauth token:
https://twitchapps.com/tmi/