[Streams] Match Twitch streams by ID if available (#1134)

Fixes #777
This commit is contained in:
Twentysix 2017-12-03 00:53:56 +01:00 committed by GitHub
parent 4a77e764a6
commit 77d3b9b5e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -524,9 +524,13 @@ class Streams:
def enable_or_disable_if_active(self, streams, stream, channel, _id=None):
"""Returns True if enabled or False if disabled"""
for i, s in enumerate(streams):
stream_id = s.get("ID")
if stream_id and _id: # ID is available, matching by ID is
if stream_id != _id: # preferable
continue
else: # ID unavailable, matching by name
if s["NAME"] != stream:
continue
if channel.id in s["CHANNELS"]:
streams[i]["CHANNELS"].remove(channel.id)
if not s["CHANNELS"]: