Browse files

New approach on scrobble checking

pause didn't work that well.
  • Loading branch information...
1 parent b28e56a commit bdc9d267e7da43d7962ee7396055f29e2923ad59 tester22 committed Jan 1, 2012
Showing with 13 additions and 6 deletions.
  1. +13 −6 script.py
View
19 script.py
@@ -44,6 +44,7 @@
progress = 0
duration = 0
percent = 0
+last_scrobbled_id = 0
print ""
print "Started monitoring a "+platform+" running "+platformVersion+" with PMS Version "+version
@@ -117,7 +118,6 @@ def add_to_trakt (video_type, title, year, duration, progress, guid):
print "Message: " + html['message']
else:
print "Message: " + html['error']
- #print "Disabled"
#Set the filename and open the file
@@ -143,6 +143,7 @@ def add_to_trakt (video_type, title, year, duration, progress, guid):
print "Progress on "+m.group(1)+" is "+m2.group(1)+" ms"
url = 'http://localhost:32400/library/metadata/'+m.group(1)
progress = int(m2.group(1))
+ print last_scrobbled_id
except: pass
@@ -165,14 +166,20 @@ def add_to_trakt (video_type, title, year, duration, progress, guid):
percent = round((float(progress)/duration)*100, 0)
#print "percent "+str(percent)
print "Found the "+type+" "+title+" from "+year+", lets make a call to trakt.tv"
- add_to_trakt(type, title, year, int(float(duration)/60000), percent, guid)
+ if last_scrobbled_id != m.group(1):
+ add_to_trakt(type, title, year, int(float(duration)/60000), percent, guid)
+ else:
+ print "This is already scrobbled."
last_commit = datetime.datetime.now()
current_id = m.group(1)
remaining = float(float(duration)-int(progress))/1000
- if remaining < 15*60 and percent > 85.0:
- print "We are close to the end and have scrobbled so will pause for %s seconds." % str(remaining)
- time.sleep(remaining)
- current_id = None
+ if percent > 85.0:
+ last_scrobbled_id = current_id
+ # This won't work
+ #if remaining < 15*60 and percent > 85.0:
+ # print "We are close to the end and have scrobbled so will pause for %s seconds." % str(remaining)
+ # time.sleep(remaining)
+ # current_id = None
# Leave whatch state if not updated for 30 minutes
if last_commit < datetime.datetime.now() - datetime.timedelta(minutes=30) and current_id != None:

0 comments on commit bdc9d26

Please sign in to comment.