From e6784de347775baf1d65d936c59a309330aae910 Mon Sep 17 00:00:00 2001 From: im85288 Date: Sat, 2 May 2015 15:34:59 +0100 Subject: [PATCH] use the etag when available --- resources/lib/API.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/resources/lib/API.py b/resources/lib/API.py index 738eb48d..6f297024 100644 --- a/resources/lib/API.py +++ b/resources/lib/API.py @@ -120,19 +120,23 @@ class API(): } def getChecksum(self, item): - #TODO --> use the etags or serverside checksum for this - # for now we just add some fields to a string + # use the etags or serverside checksum for this if available + # else just add some fields to a string checksum = "" - userData = item.get("UserData") - if(userData != None): - checksum += str(userData.get("Played")) - checksum += str(userData.get("IsFavorite")) - if userData.get('UnplayedItemCount') != None: - checksum += str(userData.get("UnplayedItemCount")) - if userData.get('LastPlayedDate') != None: - checksum += str(userData.get("LastPlayedDate")) - if userData.get('PlaybackPositionTicks') != None: - checksum += str(userData.get("PlaybackPositionTicks")) + + if item.get("Etag") != None: + checksum = item.get("Etag") + else: + userData = item.get("UserData") + if(userData != None): + checksum += str(userData.get("Played")) + checksum += str(userData.get("IsFavorite")) + if userData.get('UnplayedItemCount') != None: + checksum += str(userData.get("UnplayedItemCount")) + if userData.get('LastPlayedDate') != None: + checksum += str(userData.get("LastPlayedDate")) + if userData.get('PlaybackPositionTicks') != None: + checksum += str(userData.get("PlaybackPositionTicks")) return checksum