Skip to content

Commit

Permalink
Move playlist counter increase to stop_blocking() to prevent too many…
Browse files Browse the repository at this point in the history
… triggers
  • Loading branch information
thescooby committed Feb 17, 2021
1 parent 6b0dab4 commit 0c481c6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions spotrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,12 @@ def run(self):

# This gets called whenever Spotify sends the playingUriChanged signal
def on_playing_uri_changed(self, Player, three, four):
global _pl_track_counter
#log.debug("uri changed event")

# Update Metadata
self.update_metadata()

if _use_pl_track_counter:
_pl_track_counter += 1

# Update track & trackid
# Update track & trackid

self.trackid2 = self.metadata.get(dbus.String(u'mpris:trackid'))
if self.trackid != self.trackid2:
Expand Down Expand Up @@ -457,6 +453,8 @@ def record(self, filename, metadata_for_file={}):

# The blocking version of this method waits until the process is dead
def stop_blocking(self):
global _pl_track_counter

# Remove from instances list (and terminate)
if self in self.instances:
self.instances.remove(self)
Expand Down Expand Up @@ -491,6 +489,11 @@ def stop_blocking(self):
# Remove process from memory (and don't left a ffmpeg 'zombie' process)
self.process = None

# Update playlist counter here to get rid of too many triggers for counting
if _use_pl_track_counter:
print("Update PL counter")
_pl_track_counter += 1

# Kill the process in the background
def stop(self):
class KillThread(Thread):
Expand Down

0 comments on commit 0c481c6

Please sign in to comment.