Skip to content

Commit

Permalink
Merge pull request #511 from anxdpanic/pr-1
Browse files Browse the repository at this point in the history
2.5.1~beta1
  • Loading branch information
anxdpanic authored May 16, 2020
2 parents d862734 + bc04ef5 commit 846dc85
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 32 deletions.
8 changes: 2 additions & 6 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.0" name="Twitch" provider-name="A Talented Community">
<addon id="plugin.video.twitch" version="2.5.1~beta1" 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"/>
Expand All @@ -13,11 +13,7 @@
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<news>
[fix] language setting
[fix] show vodcasts in Following Live Channels
[fix] logging in Kodi 19
[upd] frame rate limiting to allow for 60 fps limit
[lang] fr_FR |contrib: alan7000|
[fix] encoding issue causing streams/videos/live notifications to be inaccessible with some languages
</news>
<assets>
<icon>icon.png</icon>
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.5.1
[fix] encoding issue causing streams/videos/live notifications to be inaccessible with some languages

2.5.0
[fix] language setting
[fix] show vodcasts in Following Live Channels
Expand Down
50 changes: 29 additions & 21 deletions resources/lib/twitch_addon/addon/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from . import menu_items
from .common import kodi
from .constants import Keys, Images, MODES, ADAPTIVE_SOURCE_TEMPLATE
from .utils import the_art, TitleBuilder, i18n, get_oauth_token, get_vodcast_color, use_inputstream_adaptive, get_thumbnail_size, get_refresh_stamp
from .utils import the_art, TitleBuilder, i18n, get_oauth_token, get_vodcast_color, use_inputstream_adaptive, get_thumbnail_size, get_refresh_stamp, to_string


class PlaylistConverter(object):
Expand Down Expand Up @@ -156,14 +156,16 @@ def clip_to_listitem(self, clip):
broadcaster = clip[Keys.BROADCASTER]
context_menu = list()
context_menu.extend(menu_items.refresh())
name = broadcaster.get(Keys.DISPLAY_NAME) if broadcaster.get(Keys.DISPLAY_NAME) else broadcaster.get(Keys.NAME)
display_name = to_string(broadcaster.get(Keys.DISPLAY_NAME) if broadcaster.get(Keys.DISPLAY_NAME) else broadcaster.get(Keys.NAME))
channel_name = to_string(broadcaster[Keys.NAME])
game_name = to_string(clip[Keys.GAME])
if self.has_token:
context_menu.extend(menu_items.edit_follow(broadcaster[Keys.ID], name))
context_menu.extend(menu_items.edit_follow(broadcaster[Keys.ID], display_name))
# context_menu.extend(menu_items.edit_block(broadcaster[Keys.ID], name))
context_menu.extend(menu_items.channel_videos(broadcaster[Keys.ID], broadcaster[Keys.NAME], name))
context_menu.extend(menu_items.channel_videos(broadcaster[Keys.ID], channel_name, display_name))
if clip[Keys.GAME]:
context_menu.extend(menu_items.go_to_game(clip[Keys.GAME]))
context_menu.extend(menu_items.add_blacklist(broadcaster[Keys.ID], name))
context_menu.extend(menu_items.go_to_game(game_name))
context_menu.extend(menu_items.add_blacklist(broadcaster[Keys.ID], display_name))
context_menu.extend(menu_items.add_blacklist(b64encode(clip[Keys.GAME].encode('utf-8', 'ignore')), clip[Keys.GAME], list_type='game'))
context_menu.extend(menu_items.set_default_quality('clip', broadcaster[Keys.ID], broadcaster[Keys.NAME], clip_id=clip[Keys.SLUG]))
context_menu.extend(menu_items.run_plugin(i18n('play_choose_quality'),
Expand All @@ -188,14 +190,16 @@ def collection_video_to_listitem(self, video):
owner = video[Keys.OWNER]
context_menu = list()
context_menu.extend(menu_items.refresh())
name = owner.get(Keys.DISPLAY_NAME) if owner.get(Keys.DISPLAY_NAME) else owner.get(Keys.NAME)
display_name = to_string(owner.get(Keys.DISPLAY_NAME) if owner.get(Keys.DISPLAY_NAME) else owner.get(Keys.NAME))
channel_name = to_string(owner[Keys.NAME])
game_name = to_string(video[Keys.GAME])
if self.has_token:
context_menu.extend(menu_items.edit_follow(owner[Keys._ID], name))
context_menu.extend(menu_items.edit_follow(owner[Keys._ID], display_name))
# context_menu.extend(menu_items.edit_block(owner[Keys._ID], name))
context_menu.extend(menu_items.channel_videos(owner[Keys._ID], owner[Keys.NAME], name))
context_menu.extend(menu_items.channel_videos(owner[Keys._ID], channel_name, display_name))
if video[Keys.GAME]:
context_menu.extend(menu_items.go_to_game(video[Keys.GAME]))
context_menu.extend(menu_items.add_blacklist(owner[Keys._ID], name))
context_menu.extend(menu_items.go_to_game(game_name))
context_menu.extend(menu_items.add_blacklist(owner[Keys._ID], display_name))
context_menu.extend(menu_items.add_blacklist(b64encode(video[Keys.GAME].encode('utf-8', 'ignore')), video[Keys.GAME], list_type='game'))
context_menu.extend(menu_items.set_default_quality('video', owner[Keys._ID], owner[Keys.NAME], video[Keys.ITEM_ID]))
context_menu.extend(menu_items.run_plugin(i18n('play_choose_quality'),
Expand All @@ -218,14 +222,16 @@ def video_list_to_listitem(self, video):
channel = video[Keys.CHANNEL]
context_menu = list()
context_menu.extend(menu_items.refresh())
name = channel.get(Keys.DISPLAY_NAME) if channel.get(Keys.DISPLAY_NAME) else channel.get(Keys.NAME)
display_name = to_string(channel.get(Keys.DISPLAY_NAME) if channel.get(Keys.DISPLAY_NAME) else channel.get(Keys.NAME))
channel_name = to_string(channel[Keys.NAME])
game_name = to_string(video[Keys.GAME])
if self.has_token:
context_menu.extend(menu_items.edit_follow(channel[Keys._ID], name))
context_menu.extend(menu_items.edit_follow(channel[Keys._ID], display_name))
# context_menu.extend(menu_items.edit_block(channel[Keys._ID], name))
context_menu.extend(menu_items.channel_videos(channel[Keys._ID], channel[Keys.NAME], name))
context_menu.extend(menu_items.channel_videos(channel[Keys._ID], channel_name, display_name))
if video[Keys.GAME]:
context_menu.extend(menu_items.go_to_game(video[Keys.GAME]))
context_menu.extend(menu_items.add_blacklist(channel[Keys._ID], name))
context_menu.extend(menu_items.go_to_game(game_name))
context_menu.extend(menu_items.add_blacklist(channel[Keys._ID], display_name))
context_menu.extend(menu_items.add_blacklist(b64encode(video[Keys.GAME].encode('utf-8', 'ignore')), video[Keys.GAME], list_type='game'))
context_menu.extend(menu_items.set_default_quality('video', channel[Keys._ID], channel[Keys.NAME], video[Keys._ID]))
context_menu.extend(menu_items.run_plugin(i18n('play_choose_quality'),
Expand Down Expand Up @@ -258,14 +264,16 @@ def stream_to_listitem(self, stream):
info.update({'mediatype': 'video', 'playcount': 0})
context_menu = list()
context_menu.extend(menu_items.refresh())
name = channel.get(Keys.DISPLAY_NAME) if channel.get(Keys.DISPLAY_NAME) else channel.get(Keys.NAME)
display_name = to_string(channel.get(Keys.DISPLAY_NAME) if channel.get(Keys.DISPLAY_NAME) else channel.get(Keys.NAME))
channel_name = to_string(channel[Keys.NAME])
game_name = to_string(channel[Keys.GAME])
if self.has_token:
context_menu.extend(menu_items.edit_follow(channel[Keys._ID], name))
context_menu.extend(menu_items.edit_follow(channel[Keys._ID], display_name))
# context_menu.extend(menu_items.edit_block(channel[Keys._ID], name))
context_menu.extend(menu_items.channel_videos(channel[Keys._ID], channel[Keys.NAME], name))
context_menu.extend(menu_items.channel_videos(channel[Keys._ID], channel_name, display_name))
if channel[Keys.GAME]:
context_menu.extend(menu_items.go_to_game(channel[Keys.GAME]))
context_menu.extend(menu_items.add_blacklist(channel[Keys._ID], name))
context_menu.extend(menu_items.go_to_game(game_name))
context_menu.extend(menu_items.add_blacklist(channel[Keys._ID], display_name))
context_menu.extend(menu_items.add_blacklist(b64encode(channel[Keys.GAME].encode('utf-8', 'ignore')), channel[Keys.GAME], list_type='game'))
context_menu.extend(menu_items.set_default_quality('stream', channel[Keys._ID], channel[Keys.NAME]))
context_menu.extend(menu_items.run_plugin(i18n('play_choose_quality'),
Expand Down
9 changes: 9 additions & 0 deletions resources/lib/twitch_addon/addon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
See LICENSES/GPL-3.0-only for more information.
"""

from six import PY2, PY3
from six import iteritems, string_types
from six.moves.urllib.parse import quote_plus

Expand Down Expand Up @@ -43,6 +44,14 @@ def show_menu(menu, parent=None):
return kodi.get_setting(setting_id) == 'true'


def to_string(value):
if PY3:
return kodi.decode_utf8(value)
elif PY2:
return value.encode('utf-8')
return value


def loose_version(v):
filled = []
for point in v.split("."):
Expand Down
10 changes: 5 additions & 5 deletions resources/lib/twitch_addon/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from .addon.common import kodi, log_utils
from .addon.constants import Keys
from .addon.utils import BlacklistFilter, i18n, get_stamp_diff, get_vodcast_color
from .addon.utils import BlacklistFilter, i18n, get_stamp_diff, get_vodcast_color, to_string
from .addon.player import TwitchPlayer
from .addon import api, cache

Expand Down Expand Up @@ -168,12 +168,12 @@ def get_followed_streams(self, twitch_api, monitor, blacklist_filter):
if stream.get(Keys.STREAM_TYPE) != 'live':
color = get_vodcast_color()
if stream[Keys.CHANNEL].get(Keys.DISPLAY_NAME):
stream[Keys.CHANNEL][Keys.DISPLAY_NAME] = u'[COLOR={color}]{name}[/COLOR]'.format(name=stream[Keys.CHANNEL][Keys.DISPLAY_NAME], color=color)
stream[Keys.CHANNEL][Keys.DISPLAY_NAME] = u'[COLOR={color}]{name}[/COLOR]'.format(name=to_string(stream[Keys.CHANNEL][Keys.DISPLAY_NAME]), color=color)
if stream[Keys.CHANNEL].get(Keys.NAME):
stream[Keys.CHANNEL][Keys.NAME] = u'[COLOR={color}]{name}[/COLOR]'.format(name=stream[Keys.CHANNEL][Keys.NAME], color=color)
stream[Keys.CHANNEL][Keys.NAME] = u'[COLOR={color}]{name}[/COLOR]'.format(name=to_string(stream[Keys.CHANNEL][Keys.NAME]), color=color)
colorized.append(stream)
followed_tuples = [(stream[Keys.CHANNEL][Keys._ID], stream[Keys.CHANNEL][Keys.NAME],
stream[Keys.CHANNEL][Keys.DISPLAY_NAME], stream[Keys.GAME])
followed_tuples = [(stream[Keys.CHANNEL][Keys._ID], to_string(stream[Keys.CHANNEL][Keys.NAME]),
to_string(stream[Keys.CHANNEL][Keys.DISPLAY_NAME]), to_string(stream[Keys.GAME]))
for stream in colorized]
return followed_tuples

Expand Down

0 comments on commit 846dc85

Please sign in to comment.