Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve scrobbling issues with new Plex Scanner/Agent #616

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ class Guid(Descriptor):

@classmethod
def from_node(cls, client, node):
return cls.construct(client, cls.helpers.find(node, 'Guid'), child=True)
items = []

for guid in cls.helpers.findall(node, 'Guid'):
_, obj = Guid.construct(client, guid, child=True)

items.append(obj)

return [], items
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Episode(Video, Metadata, PlaylistItemMixin, RateMixin, ScrobbleMixin):
@property
def guid(self):
try:
return self.guids.id
return self.guids[0].id
except:
return self.agent_guid

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Movie(Video, Metadata, PlaylistItemMixin, RateMixin, ScrobbleMixin):
@property
def guid(self):
try:
return self.guids.id
return self.guids[0].id
except:
return self.agent_guid

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Season(Directory, Metadata, RateMixin):
@property
def guid(self):
try:
return self.guids.id
return self.guids[0].id
except:
return self.agent_guid

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Show(Directory, Metadata, RateMixin):
@property
def guid(self):
try:
return self.guids.id
return self.guids[0].id
except:
return self.agent_guid

Expand Down
19 changes: 10 additions & 9 deletions Trakttv.bundle/Contents/Libraries/Shared/plugin/core/identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@

class Identifier(object):
@classmethod
def get_ids(cls, guid, strict=True):
def get_ids(cls, guids, strict=True):
ids = {}

if not guid:
if not guids:
return ids

if type(guid) is str:
# Parse raw guid
guid = Guid.parse(guid, strict=strict)
for guid in guids:
if type(guid.id) is str:
# Parse raw guid
guid = Guid.parse(guid.id, strict=strict)

if guid and guid.valid and guid.service in GUID_SERVICES:
ids[guid.service] = guid.id
elif strict:
return None
if guid and guid.valid and guid.service in GUID_SERVICES:
ids[guid.service] = guid.id
elif strict:
return None

return ids
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def build_request(cls, session, part=None, rating_key=None, view_offset=None):
@classmethod
def build_episode(cls, episode, guid, part):
# Retrieve show identifier
ids = Identifier.get_ids(guid, strict=False)
ids = Identifier.get_ids(episode.guids, strict=False)

if not ids:
# Try map episode to a supported service (with OEM)
Expand All @@ -107,18 +107,22 @@ def build_episode(cls, episode, guid, part):
log.warn('Matcher didn\'t return a valid result - season_num: %r, episodes: %r', season_num, episodes)
episode_num = episode.index

# Process guid episode identifier overrides
if guid.season is not None:
season_num = guid.season
# Get the show metadata
if episode.show:
show_metadata = Metadata.get(episode.show.rating_key)
show_ids = Identifier.get_ids(show_metadata.guids, strict=False)

if show_metadata:
show = {
'title': show_metadata.title,
'year': show_metadata.year,

'ids': show_ids
}

# Build request
return {
'show': {
'title': episode.show.title,
'year': episode.year,

'ids': ids
},
'show': show,
'episode': {
'title': episode.title,

Expand All @@ -129,7 +133,7 @@ def build_episode(cls, episode, guid, part):

@staticmethod
def build_movie(movie, guid, part):
ids = Identifier.get_ids(guid, strict=False)
ids = Identifier.get_ids(movie.guids, strict=False)

if not ids:
# Try map episode to a supported service (with OEM)
Expand Down