Skip to content

Commit

Permalink
Merge pull request #463 from anxdpanic/pr-1
Browse files Browse the repository at this point in the history
2.4.6
  • Loading branch information
anxdpanic authored Nov 18, 2019
2 parents 03108e4 + 197cc61 commit 7eac76a
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 11 deletions.
9 changes: 6 additions & 3 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<addon id='plugin.video.twitch' version='2.4.5' name='Twitch' provider-name='A Talented Community'>
<addon id='plugin.video.twitch' version='2.4.6' name='Twitch' provider-name='A Talented Community'>
<requires>
<import addon='xbmc.python' version='2.20.0'/>
<import addon='script.module.six' version='1.11.0'/>
<import addon='script.module.python.twitch' version='2.0.7'/>
<import addon='script.module.python.twitch' version='2.0.9'/>
<import addon='script.module.requests' version='2.9.1'/>
</requires>
<extension point='xbmc.python.pluginsource' library='resources/lib/addon_runner.py'>
Expand All @@ -13,7 +13,10 @@
<extension point='xbmc.addon.metadata'>
<platform>all</platform>
<news>
[rem] Remove deprecated api Communities and related content
[add] Settings - Login - Private API Credentials
[fix] basic playback, set default Private API Credentials - Client ID
[fix] oauth short link generation w/ python 3
[rem] Remove deprecated scope chat_login
</news>
<assets>
<icon>icon.png</icon>
Expand Down
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2.4.6
[add] Settings - Login - Private API Credentials
[fix] basic playback, set default Private API Credentials - Client ID
[fix] oauth short link generation w/ python 3
[rem] Remove deprecated scope chat_login

2.4.5
[rem] Remove deprecated api Communities and related content

Expand Down
4 changes: 4 additions & 0 deletions resources/language/resource.language.cs_cz/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -921,3 +921,7 @@ msgstr ""
msgctxt "#30260"
msgid "Limit to 30 fps"
msgstr ""

msgctxt "#30261"
msgid "Private API Credentials"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.da_dk/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -921,3 +921,7 @@ msgstr ""
msgctxt "#30260"
msgid "Limit to 30 fps"
msgstr ""

msgctxt "#30261"
msgid "Private API Credentials"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.de_de/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -921,3 +921,7 @@ msgstr ""
msgctxt "#30260"
msgid "Limit to 30 fps"
msgstr ""

msgctxt "#30261"
msgid "Private API Credentials"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -945,3 +945,7 @@ msgstr ""
msgctxt "#30260"
msgid "Limit to 30 fps"
msgstr ""

msgctxt "#30261"
msgid "Private API Credentials"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.es_es/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -921,3 +921,7 @@ msgstr ""
msgctxt "#30260"
msgid "Limit to 30 fps"
msgstr ""

msgctxt "#30261"
msgid "Private API Credentials"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.fr_fr/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -921,3 +921,7 @@ msgstr ""
msgctxt "#30260"
msgid "Limit to 30 fps"
msgstr ""

msgctxt "#30261"
msgid "Private API Credentials"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.he_il/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -944,3 +944,7 @@ msgstr ""
msgctxt "#30260"
msgid "Limit to 30 fps"
msgstr ""

msgctxt "#30261"
msgid "Private API Credentials"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.nb_no/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -925,3 +925,7 @@ msgstr ""
msgctxt "#30260"
msgid "Limit to 30 fps"
msgstr ""

msgctxt "#30261"
msgid "Private API Credentials"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -921,3 +921,7 @@ msgstr ""
msgctxt "#30260"
msgid "Limit to 30 fps"
msgstr ""

msgctxt "#30261"
msgid "Private API Credentials"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.pl_pl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -921,3 +921,7 @@ msgstr ""
msgctxt "#30260"
msgid "Limit to 30 fps"
msgstr ""

msgctxt "#30261"
msgid "Private API Credentials"
msgstr ""
25 changes: 19 additions & 6 deletions resources/lib/twitch_addon/addon/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def get_followed_streams(self, stream_type, offset, limit):
@api_error_handler
@cache.cache_method(cache_limit=cache.limit)
def get_vod(self, video_id):
results = self.usher.video(video_id)
results = self.usher.video(video_id, headers=self.get_private_credential_headers())
return self.error_check(results)

@api_error_handler
Expand All @@ -322,25 +322,25 @@ def get_clip(self, slug):
@api_error_handler
@cache.cache_method(cache_limit=cache.limit)
def get_live(self, name):
results = self.usher.live(name)
results = self.usher.live(name, headers=self.get_private_credential_headers())
return self.error_check(results)

@api_error_handler
@cache.cache_method(cache_limit=cache.limit)
def live_request(self, name):
if not utils.inputstream_adpative_supports('EXT-X-DISCONTINUITY'):
results = self.usher.live_request(name, platform='ps4')
results = self.usher.live_request(name, platform='ps4', headers=self.get_private_credential_headers())
else:
results = self.usher.live_request(name)
results = self.usher.live_request(name, headers=self.get_private_credential_headers())
return self.error_check(results)

@api_error_handler
@cache.cache_method(cache_limit=cache.limit)
def video_request(self, video_id):
if not utils.inputstream_adpative_supports('EXT-X-DISCONTINUITY'):
results = self.usher.video_request(video_id, platform='ps4')
results = self.usher.video_request(video_id, platform='ps4', headers=self.get_private_credential_headers())
else:
results = self.usher.video_request(video_id)
results = self.usher.video_request(video_id, headers=self.get_private_credential_headers())
return self.error_check(results)

def get_user_blocks(self):
Expand Down Expand Up @@ -374,3 +374,16 @@ def return_boolean(results):
raise TwitchException(results)
else:
return True

@staticmethod
def get_private_credential_headers():
headers = {}
private_client_id = utils.get_private_client_id()
private_oauth_token = utils.get_private_oauth_token()
if private_client_id:
headers['Client-ID'] = private_client_id
headers['Authorization'] = ''
if private_oauth_token:
headers['Authorization'] = 'OAuth {token}'.format(token=private_oauth_token)
headers['Client-ID'] = ''
return headers
2 changes: 1 addition & 1 deletion resources/lib/twitch_addon/addon/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,4 @@ class Scripts:
REFRESH = 'special://home/addons/plugin.video.twitch/resources/lib/twitch_addon/refresh.py'


SCOPES = [scopes.user_read, scopes.user_follows_edit, scopes.user_subscriptions, scopes.chat_login]
SCOPES = [scopes.user_read, scopes.user_follows_edit, scopes.user_subscriptions]
5 changes: 4 additions & 1 deletion resources/lib/twitch_addon/addon/google_firebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@


def dynamic_links_short_url(url):
post_url = 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=%s' % b64decode(__key)
key = b64decode(__key)
if isinstance(key, bytes):
key = key.decode('utf-8')
post_url = 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=%s' % key
data = {
'longDynamicLink': 'https://twitchaddon.page.link/?link=%s' % quote(url),
'suffix': {
Expand Down
22 changes: 22 additions & 0 deletions resources/lib/twitch_addon/addon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ def get_client_id(default=False):
return kodi.decode_utf8(b64decode(CLIENT_ID))


def get_private_client_id():
settings_id = kodi.get_setting('private_oauth_clientid')
stripped_id = settings_id.strip()
if settings_id != stripped_id:
settings_id = stripped_id
kodi.set_setting('private_oauth_clientid', settings_id)
if not settings_id:
return ""
return kodi.decode_utf8(settings_id)


def clear_client_id():
kodi.set_setting('oauth_clientid', '')

Expand Down Expand Up @@ -155,6 +166,17 @@ def get_oauth_token(token_only=True, required=False):
return kodi.decode_utf8(oauth_token)


def get_private_oauth_token():
settings_id = kodi.get_setting('private_oauth_token')
stripped_id = settings_id.strip()
if settings_id != stripped_id:
settings_id = stripped_id
kodi.set_setting('private_oauth_token', settings_id)
if not settings_id:
return ""
return kodi.decode_utf8(settings_id)


def get_search_history_size():
return int(kodi.get_setting('search_history_size'))

Expand Down
3 changes: 3 additions & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<setting label="30135" id="show_token_url" type="action" action="RunPlugin(plugin://$ID/?mode=get_token_url)" option="close"/>
<setting label="30138" type="lsep"/>
<setting label="30227" id="revoke_token" type="action" action="RunPlugin(plugin://$ID/?mode=revoke_token)" option="close"/>
<setting label="30261" type="lsep"/>
<setting id="private_oauth_clientid" type="text" label="30097" default="kimne78kx3ncx6brgo4mv6wki5h1ko"/>
<setting id="private_oauth_token" type="text" label="30099" default=""/>
</category>
<!-- Main Menu -->
<category label="30219">
Expand Down

0 comments on commit 7eac76a

Please sign in to comment.