diff --git a/SpiffyTitles/README.md b/SpiffyTitles/README.md index f2caf35..95c3af4 100644 --- a/SpiffyTitles/README.md +++ b/SpiffyTitles/README.md @@ -178,8 +178,11 @@ poster | Poster URL ### Twitch handler Queries the [Twitch API](https://dev.twitch.tv/) to get additional information about [Twitch](http://twitch.tv) links -`twitch.clientID` - Set your Twitch Client_ID here. Obtain at https://dev.twitch.tv/dashboard/apps/create (free) -(You can use http://localhost for the OAuth Redirect URL, you just need to generate a Client_ID) +Visit https://twitchtokengenerator.com/ and scroll down until you see the 'Generate Token' button. Click the button and authorize the app on Twitch. Set the Client ID and Access Token using the values generated by Twitch Token Generator. + +`twitch.clientID` - Set your Twitch Client_ID here. + +`twitch.accessToken` - Set your Twitch Access Token here. `twitch.enabled` - Whether to show additional information about [Twitch](http://twitch.tv) links diff --git a/SpiffyTitles/config.py b/SpiffyTitles/config.py index cd37ca1..7ec1180 100644 --- a/SpiffyTitles/config.py +++ b/SpiffyTitles/config.py @@ -520,13 +520,19 @@ conf.registerChannelValue( ), ) -# Twitch API Key +# Twitch API Keys conf.registerGlobalValue( SpiffyTitles.twitch, "clientID", registry.String("", _("""Twitch API Client_ID"""), private=True), ) +conf.registerGlobalValue( + SpiffyTitles.twitch, + "accessToken", + registry.String("", _("""Twitch API Access Token"""), private=True), +) + # Twitch Logo conf.registerChannelValue( SpiffyTitles.twitch, diff --git a/SpiffyTitles/plugin.py b/SpiffyTitles/plugin.py index d8a7414..f318a66 100644 --- a/SpiffyTitles/plugin.py +++ b/SpiffyTitles/plugin.py @@ -963,6 +963,10 @@ class SpiffyTitles(callbacks.Plugin): if not twitch_client_id: log.error("SpiffyTitles: Please set your Twitch client ID") return self.handler_default(url, channel) + access_token = self.registryValue("twitch.accessToken") + if not access_token: + log.error("SpiffyTitles: Please set your Twitch Access Token") + return self.handler_default(url, channel) url = url.split("?")[0] self.log.debug("SpiffyTitles: calling twitch handler for %s" % (url)) patterns = { @@ -992,7 +996,8 @@ class SpiffyTitles(callbacks.Plugin): if not match: self.log.debug("SpiffyTitles: twitch - no title found.") return self.handler_default(url, channel) - headers = {"Client-ID": twitch_client_id} + bearer = "Bearer {}".format(access_token.strip()) + headers = {"Client-ID": twitch_client_id, "Authorization": bearer} self.log.debug("SpiffyTitles: twitch - requesting %s" % (data_url)) try: request = requests.get(data_url, timeout=self.timeout, headers=headers)