mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-28 22:41:08 -05:00
SpiffyTitles: Fix Twitch handler.
This commit is contained in:
parent
9345cc6335
commit
32c8053d13
@ -178,8 +178,11 @@ poster | Poster URL
|
|||||||
### Twitch handler
|
### Twitch handler
|
||||||
Queries the [Twitch API](https://dev.twitch.tv/) to get additional information about [Twitch](http://twitch.tv) links
|
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)
|
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.
|
||||||
(You can use http://localhost for the OAuth Redirect URL, you just need to generate a Client_ID)
|
|
||||||
|
`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
|
`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(
|
conf.registerGlobalValue(
|
||||||
SpiffyTitles.twitch,
|
SpiffyTitles.twitch,
|
||||||
"clientID",
|
"clientID",
|
||||||
registry.String("", _("""Twitch API Client_ID"""), private=True),
|
registry.String("", _("""Twitch API Client_ID"""), private=True),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
conf.registerGlobalValue(
|
||||||
|
SpiffyTitles.twitch,
|
||||||
|
"accessToken",
|
||||||
|
registry.String("", _("""Twitch API Access Token"""), private=True),
|
||||||
|
)
|
||||||
|
|
||||||
# Twitch Logo
|
# Twitch Logo
|
||||||
conf.registerChannelValue(
|
conf.registerChannelValue(
|
||||||
SpiffyTitles.twitch,
|
SpiffyTitles.twitch,
|
||||||
|
@ -963,6 +963,10 @@ class SpiffyTitles(callbacks.Plugin):
|
|||||||
if not twitch_client_id:
|
if not twitch_client_id:
|
||||||
log.error("SpiffyTitles: Please set your Twitch client ID")
|
log.error("SpiffyTitles: Please set your Twitch client ID")
|
||||||
return self.handler_default(url, channel)
|
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]
|
url = url.split("?")[0]
|
||||||
self.log.debug("SpiffyTitles: calling twitch handler for %s" % (url))
|
self.log.debug("SpiffyTitles: calling twitch handler for %s" % (url))
|
||||||
patterns = {
|
patterns = {
|
||||||
@ -992,7 +996,8 @@ class SpiffyTitles(callbacks.Plugin):
|
|||||||
if not match:
|
if not match:
|
||||||
self.log.debug("SpiffyTitles: twitch - no title found.")
|
self.log.debug("SpiffyTitles: twitch - no title found.")
|
||||||
return self.handler_default(url, channel)
|
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))
|
self.log.debug("SpiffyTitles: twitch - requesting %s" % (data_url))
|
||||||
try:
|
try:
|
||||||
request = requests.get(data_url, timeout=self.timeout, headers=headers)
|
request = requests.get(data_url, timeout=self.timeout, headers=headers)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user