Skip to content

Commit

Permalink
Merge pull request #482 from anxdpanic/pr-1
Browse files Browse the repository at this point in the history
2.4.9~alpha1
  • Loading branch information
anxdpanic authored Feb 20, 2020
2 parents 7398b4f + 734a451 commit f505947
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 18 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.4.8' name='Twitch' provider-name='A Talented Community'>
<addon id='plugin.video.twitch' version='2.4.9~alpha1' 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] resolve indefinite busy dialog on failed playback
[fix] sort by viewers for followed live channels, restoring previous behavior
[fix] menu settings not taking effect
[fix] handle no stream available error
[rem] remove Playlists
[bandaid] fix listing live streams
</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.4.9
[bandaid] fix listing live streams

2.4.8
[fix] resolve indefinite busy dialog on failed playback
[fix] sort by viewers for followed live channels, restoring previous behavior
Expand Down
19 changes: 15 additions & 4 deletions resources/lib/twitch_addon/routes/followed.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,24 @@ def route(api, content, offset=0, cursor='MA=='):
if content == StreamType.LIVE:
utils.refresh_previews()
kodi.set_view('videos', set_sort=True)
streams = None

all_items = list()
requests = 0
total = None

while (per_page >= (len(all_items) + 1)) and (requests < MAX_REQUESTS):
requests += 1
streams = api.get_followed_streams(stream_type=content, offset=offset, limit=REQUEST_LIMIT)
if (streams[Keys.TOTAL] > 0) and (Keys.STREAMS in streams):

if total is None:
if Keys.TOTAL in streams:
total = streams[Keys.TOTAL]
elif Keys.STREAMS in streams:
total = len(streams[Keys.STREAMS])
else:
break

if (total > 0) and (Keys.STREAMS in streams):
filtered = \
blacklist_filter.by_type(streams, Keys.STREAMS, parent_keys=[Keys.CHANNEL], id_key=Keys._ID, list_type='user')
filtered = \
Expand All @@ -49,7 +60,7 @@ def route(api, content, offset=0, cursor='MA=='):
else:
break
offset = utils.get_offset(offset, last, streams[Keys.STREAMS])
if (offset is None) or (streams[Keys.TOTAL] <= offset) or (streams[Keys.TOTAL] <= REQUEST_LIMIT):
if (offset is None) or (total <= offset) or (total <= REQUEST_LIMIT):
break
else:
break
Expand All @@ -58,7 +69,7 @@ def route(api, content, offset=0, cursor='MA=='):
has_items = True
for stream in all_items:
kodi.create_item(converter.stream_to_listitem(stream))
if streams[Keys.TOTAL] > (offset + 1):
if total > (offset + 1):
has_items = True
kodi.create_item(utils.link_to_next_page({'mode': MODES.FOLLOWED, 'content': content, 'offset': offset}))
if has_items:
Expand Down
21 changes: 17 additions & 4 deletions resources/lib/twitch_addon/routes/game_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,26 @@ def route(api, game, offset=0):
utils.refresh_previews()
kodi.set_view('videos', set_sort=True)
per_page = utils.get_items_per_page()
streams = None

all_items = list()
requests = 0
total = None

while (per_page >= (len(all_items) + 1)) and (requests < MAX_REQUESTS):
requests += 1
languages = ','.join(utils.get_languages())
streams = api.get_game_streams(game=game, offset=offset, limit=REQUEST_LIMIT, language=languages)
if (streams[Keys.TOTAL] > 0) and (Keys.STREAMS in streams):

if total is None:
if Keys.TOTAL in streams:
total = streams[Keys.TOTAL]
elif Keys.STREAMS in streams:
total = len(streams[Keys.STREAMS])
else:
break

print('1' * 1000, total)
if (total > 0) and (Keys.STREAMS in streams):
filtered = \
blacklist_filter.by_type(streams, Keys.STREAMS, parent_keys=[Keys.CHANNEL], id_key=Keys._ID, list_type='user')
last = None
Expand All @@ -42,16 +54,17 @@ def route(api, game, offset=0):
else:
break
offset = utils.get_offset(offset, last, streams[Keys.STREAMS])
if (offset is None) or (streams[Keys.TOTAL] <= offset) or (streams[Keys.TOTAL] <= REQUEST_LIMIT):
if (offset is None) or (total <= offset) or (total <= REQUEST_LIMIT):
break
else:
break

has_items = False
if len(all_items) > 0:
has_items = True
for stream in all_items:
kodi.create_item(converter.stream_to_listitem(stream))
if streams[Keys.TOTAL] > (offset + 1):
if total > (offset + 1):
has_items = True
kodi.create_item(utils.link_to_next_page({'mode': MODES.GAMESTREAMS, 'game': game, 'offset': offset}))
if has_items:
Expand Down
19 changes: 15 additions & 4 deletions resources/lib/twitch_addon/routes/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,25 @@ def route(api, stream_type=StreamType.LIVE, offset=0, platform=Platform.ALL):
utils.refresh_previews()
kodi.set_view('videos', set_sort=True)
per_page = utils.get_items_per_page()
streams = None

all_items = list()
requests = 0
total = None

while (per_page >= (len(all_items) + 1)) and (requests < MAX_REQUESTS):
requests += 1
languages = ','.join(utils.get_languages())
streams = api.get_all_streams(stream_type=stream_type, platform=platform, offset=offset, limit=REQUEST_LIMIT, language=languages)
if (streams[Keys.TOTAL] > 0) and (Keys.STREAMS in streams):

if total is None:
if Keys.TOTAL in streams:
total = streams[Keys.TOTAL]
elif Keys.STREAMS in streams:
total = len(streams[Keys.STREAMS])
else:
break

if (total > 0) and (Keys.STREAMS in streams):
filtered = \
blacklist_filter.by_type(streams, Keys.STREAMS, parent_keys=[Keys.CHANNEL], id_key=Keys._ID, list_type='user')
filtered = \
Expand All @@ -46,7 +57,7 @@ def route(api, stream_type=StreamType.LIVE, offset=0, platform=Platform.ALL):
else:
break
offset = utils.get_offset(offset, last, streams[Keys.STREAMS])
if (offset is None) or (streams[Keys.TOTAL] <= offset) or (streams[Keys.TOTAL] <= REQUEST_LIMIT):
if (offset is None) or (total <= offset) or (total <= REQUEST_LIMIT):
break
else:
break
Expand All @@ -55,7 +66,7 @@ def route(api, stream_type=StreamType.LIVE, offset=0, platform=Platform.ALL):
has_items = True
for stream in all_items:
kodi.create_item(converter.stream_to_listitem(stream))
if streams[Keys.TOTAL] > (offset + 1):
if total > (offset + 1):
has_items = True
kodi.create_item(utils.link_to_next_page({'mode': MODES.STREAMLIST, 'stream_type': stream_type, 'platform': platform, 'offset': offset}))
if has_items:
Expand Down

0 comments on commit f505947

Please sign in to comment.