Skip to content

Commit

Permalink
Merge pull request #522 from anxdpanic/pr-1
Browse files Browse the repository at this point in the history
2.5.2
  • Loading branch information
anxdpanic authored Aug 15, 2020
2 parents 2938061 + 58e24c5 commit fd650e9
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Twitch on Kodi
==================

![Build Status](https://img.shields.io/travis/MrSprigster/Twitch-on-Kodi/master.svg)
![Build Status](https://img.shields.io/travis/anxdpanic/Twitch-on-Kodi/master.svg)
![License](https://img.shields.io/badge/license-GPL--3.0--only-success.svg)
![Kodi Version](https://img.shields.io/badge/kodi-isengard%2B-success.svg)
![Contributors](https://img.shields.io/github/contributors/MrSprigster/Twitch-on-Kodi.svg)
Expand All @@ -13,7 +13,7 @@ LOGIN

1. Go to __Settings - Login - Get OAuth token__ and visit the url you are prompted with
_The prompted url is case-sensitive, if your skin's text is all UPPERCASE you will need to switch to Estuary/Confluence to see the proper url_
2. Login/Sign-up and Authorize Twitch on Kodi
2. Login/Sign-up and Authorize TTV on Kodi
3. Input your new OAuth token in __Settings - Login__

FAQ
Expand Down
8 changes: 5 additions & 3 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.twitch" version="2.5.2~beta1" name="Twitch" provider-name="A Talented Community">
<addon id="plugin.video.twitch" version="2.5.2" name="Twitch" provider-name="anxdpanic, A Talented Community">
<requires>
<import addon="xbmc.python" version="2.20.0"/>
<import addon="script.module.six" version="1.11.0"/>
Expand All @@ -13,16 +13,18 @@
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<news>
[add] Add additional stream properties at playback
[fix] Get OAuth token on Kodi 19
[upd] Use new settings format on Kodi 19
[upd] Update material to reflect repository changes
</news>
<assets>
<icon>icon.png</icon>
<fanart>fanart.jpg</fanart>
</assets>
<source>https://github.com/MrSprigster/Twitch-on-Kodi</source>
<source>https://github.com/anxdpanic/Twitch-on-Kodi</source>
<license>GPL-3.0-only</license>
<forum>https://forum.kodi.tv/showthread.php?tid=134538</forum>
<forum>https://twitchaddon.page.link/forum</forum>
<summary lang="en_GB">Twitch video plugin</summary>
<description lang="en_GB">Watch your favorite gaming streams!</description>
<summary lang="da_DK">Twitch video plugin</summary>
Expand Down
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
2.5.2
[add] Add additional stream properties at playback
[fix] Get OAuth token on Kodi 19
[upd] Use new settings format on Kodi 19
[upd] Update material to reflect repository changes

2.5.1
[fix] encoding issue causing streams/videos/live notifications to be inaccessible with some languages
Expand Down
11 changes: 9 additions & 2 deletions resources/lib/twitch_addon/addon/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def valid_token(self, client_id, token, scopes): # client_id, token used for un
log_utils.log('Error: Current OAuth token is invalid.', log_utils.LOGERROR)
return False
else:
if token_check['token']['client_id'] == self.client_id:
if token_check['token']['client_id'] in (self.client_id, utils.get_client_id(default=True, old=True)):
if token_check['token']['authorization']:
token_scopes = token_check['token']['authorization']['scopes']
missing_scopes = [value for value in scopes if value not in token_scopes]
Expand All @@ -72,14 +72,21 @@ def valid_token(self, client_id, token, scopes): # client_id, token used for un
return False
else:
matches_default = token_check['token']['client_id'] == utils.get_client_id(default=True)
message = 'Token created using default Client-ID |%s|' % str(matches_default)
matches_old = token_check['token']['client_id'] == utils.get_client_id(default=True, old=True)
message = 'Token created using %s Client-ID |%s|' % ('default' if matches_default else 'old' if matches_old else 'none', str(matches_default))
log_utils.log('Error: OAuth Client-ID mismatch: %s' % message, log_utils.LOGERROR)
if matches_default:
result = kodi.Dialog().ok(heading=i18n('oauth_token'), line1=i18n('client_id_mismatch'), line2=i18n('ok_to_resolve'))
utils.clear_client_id()
self.client_id = utils.get_client_id(default=True)
self.queries.CLIENT_ID = self.client_id
self.client = oauth.clients.MobileClient(self.client_id, self.client_secret)
elif matches_old:
result = kodi.Dialog().ok(heading=i18n('oauth_token'), line1=i18n('client_id_mismatch'), line2=i18n('ok_to_resolve'))
utils.clear_client_id()
self.client_id = utils.get_client_id(default=True, old=True)
self.queries.CLIENT_ID = self.client_id
self.client = oauth.clients.MobileClient(self.client_id, self.client_secret)
else:
result = kodi.Dialog().ok(heading=i18n('oauth_token'), line1=i18n('client_id_mismatch'),
line2=i18n('get_new_oauth_token') % (i18n('settings'), i18n('login'), i18n('get_oauth_token')))
Expand Down
7 changes: 5 additions & 2 deletions resources/lib/twitch_addon/addon/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ def __enum(**enums):

ADAPTIVE_SOURCE_TEMPLATE = {'id': 'hls', 'name': 'Adaptive', 'bandwidth': -1, 'url': ''}

CLIENT_ID = 'NjdlYnBmaHlvaWNhYjVrcjB5N3B6b2NzZm9oczd0eQ=='
REDIRECT_URI = 'https://mrsprigster.github.io/Twitch-on-Kodi/token/'
CLIENT_ID = 'cHMyZWQ5emxqOHp5cXp0c2R6MnRsNHV5czg0Yjhr'
REDIRECT_URI = 'https://anxdpanic.github.io/Twitch-on-Kodi/token/'

OLD_CLIENT_ID = 'NjdlYnBmaHlvaWNhYjVrcjB5N3B6b2NzZm9oczd0eQ=='
OLD_REDIRECT_URI = 'https://mrsprigster.github.io/Twitch-on-Kodi/token/'

LIVE_PREVIEW_TEMPLATE = '%://static-cdn.jtvnw.net/previews-ttv/live_user_%-%x%.jpg' # sqlite LIKE pattern

Expand Down
9 changes: 6 additions & 3 deletions resources/lib/twitch_addon/addon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from .common import kodi, json_store
from .strings import STRINGS
from .constants import CLIENT_ID, REDIRECT_URI, LIVE_PREVIEW_TEMPLATE, Images, ADDON_DATA_DIR, REQUEST_LIMIT, COLORS, Keys
from .constants import CLIENT_ID, REDIRECT_URI, LIVE_PREVIEW_TEMPLATE, Images, ADDON_DATA_DIR, REQUEST_LIMIT, COLORS, Keys, OLD_CLIENT_ID
from .search_history import StreamsSearchHistory, ChannelsSearchHistory, GamesSearchHistory, IdUrlSearchHistory

from twitch.api.parameters import Boolean, Period, ClipPeriod, Direction, Language, SortBy, VideoSort
Expand Down Expand Up @@ -123,7 +123,7 @@ def get_redirect_uri():
return kodi.decode_utf8(REDIRECT_URI)


def get_client_id(default=False):
def get_client_id(default=False, old=False):
settings_id = kodi.get_setting('oauth_clientid')
stripped_id = settings_id.strip()
if settings_id != stripped_id:
Expand All @@ -132,7 +132,10 @@ def get_client_id(default=False):
if settings_id and not default:
return kodi.decode_utf8(settings_id)
else:
return kodi.decode_utf8(b64decode(CLIENT_ID))
if old:
return kodi.decode_utf8(b64decode(OLD_CLIENT_ID))
else:
return kodi.decode_utf8(b64decode(CLIENT_ID))


def get_private_client_id():
Expand Down
13 changes: 13 additions & 0 deletions resources/lib/twitch_addon/routes/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def _set_seek_time(value):
videos = item_dict = name = None
seek_time = int(seek_time)
is_live = False
result = None
if video_id:
seek_id, _seek_time = _get_seek()
if seek_id == video_id:
Expand Down Expand Up @@ -154,6 +155,18 @@ def _set_seek_time(value):
log_utils.log('Attempting playback using quality |%s| @ |%s|' % (quality_label, play_url), log_utils.LOGDEBUG)
item_dict['path'] = play_url
playback_item = kodi.create_item(item_dict, add=False)
stream_info = {
'video': {},
'audio': {
'channels': '2'
}
}
if result:
language = result.get(Keys.CHANNEL, {}).get(Keys.BROADCASTER_LANGUAGE)
if language:
stream_info['audio']['language'] = language
playback_item.addStreamInfo('video', stream_info.get('video'))
playback_item.addStreamInfo('audio', stream_info.get('audio'))
if not clip:
try:
playback_item.setContentLookup(False)
Expand Down

0 comments on commit fd650e9

Please sign in to comment.