# HG changeset patch # User Josef "Jeff" Sipek # Date 1162808363 18000 # Node ID 2d570448aba54a7d93426ad1110f0b5ea71f95f2 # Parent 2bf81d95246a676f05aa4bea873e06f17b57fe94 Abstract out the stats code a little bit more This is in preparation for moving the stats code completely out of player code diff -r 2bf81d95246a -r 2d570448aba5 run --- a/run Mon Nov 06 05:10:37 2006 -0500 +++ b/run Mon Nov 06 05:19:23 2006 -0500 @@ -6,5 +6,8 @@ from vixm import main -main.run(os.path.join(os.environ['HOME'], ".vixm/list.m3u")) +list = os.path.join(os.environ['HOME'], ".vixm/list.m3u") +stats = os.path.join(os.environ['HOME'], ".vixm/stats") +main.run(list, stats) + diff -r 2bf81d95246a -r 2d570448aba5 vixm/main.py --- a/vixm/main.py Mon Nov 06 05:10:37 2006 -0500 +++ b/vixm/main.py Mon Nov 06 05:19:23 2006 -0500 @@ -3,7 +3,7 @@ import playlist, song, player import ui as uimod -def run(filename): +def run(listfn, statsfn): """ this is where we start execution """ # first, let's create the two playlists @@ -16,7 +16,7 @@ print "Loading songs from XMMS's playlist..." songs = [] idx = 0 - for l in open(filename, "r").readlines(): + for l in open(listfn, "r").readlines(): if l[0] == "#": continue diff -r 2bf81d95246a -r 2d570448aba5 vixm/player.py --- a/vixm/player.py Mon Nov 06 05:10:37 2006 -0500 +++ b/vixm/player.py Mon Nov 06 05:19:23 2006 -0500 @@ -42,7 +42,7 @@ self.playing = True self.current = s - self.stats.current = s + self.stats.playing(s) def run(self): while not self.shutdown: diff -r 2bf81d95246a -r 2d570448aba5 vixm/stats.py --- a/vixm/stats.py Mon Nov 06 05:10:37 2006 -0500 +++ b/vixm/stats.py Mon Nov 06 05:19:23 2006 -0500 @@ -9,7 +9,7 @@ self.__stats = {} self.__new_songs = 0 - self.current = None + self.__current = None def __del__(self): self.sync() @@ -21,8 +21,11 @@ self.__new_songs = 0 + def playing(self, s): + self.__current = s + def played(self): - s = str(self.current) + s = str(self.__current) if not self.__stats.has_key(s): self.__stats[s] = 0 @@ -32,4 +35,4 @@ self.__new_songs += 1 if self.__new_songs >= NEW_SONGS_SYNC: self.sync() - +