mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-25 20:41:21 -05:00
SpiffyTitles: Fix Twitch handler.
This commit is contained in:
parent
9345cc6335
commit
32c8053d13
@ -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
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user