]> git.parisson.com Git - deefuzzer.git/commitdiff
Fix to detect a playlist that changed in content, but not length
authorachbed <github@achbed.org>
Sun, 3 May 2015 17:07:03 +0000 (12:07 -0500)
committerachbed <github@achbed.org>
Sun, 3 May 2015 17:07:03 +0000 (12:07 -0500)
Signed-off-by: achbed <github@achbed.org>
deefuzzer/station.py

index c771b4b8fd2214b3e1c3328fc2ec2bd07b8367ec..50b032297ede68aa5e10ade981673ede1d0f213d 100644 (file)
@@ -46,6 +46,7 @@ import shout
 import urllib
 import mimetypes
 import json
+import hashlib
 
 from threading import Thread
 from player import *
@@ -438,6 +439,9 @@ class Station(Thread):
             pass
 
         return file_list
+        
+    def get_array_hash(self, s):
+        return hashlib.md5(str(s)).hexdigest()
 
     def get_jingles(self):
         file_list = []
@@ -483,7 +487,10 @@ class Station(Thread):
 
                 self._info('Generating new playlist (' + str(self.lp) + ' tracks)')
 
-            elif lp_new != self.lp:
+            # use a hash check instead to detect when a filename changes as well as playlist length
+            # Also, recompute the hash every time for the built-in playlist so we can catch when that
+            # changes as well
+            elif self.get_array_hash(new_playlist) != self.get_array_hash(self.playlist):
                 self.id += 1
                 if self.id >= lp_new:
                     self.id = 0