Mercurial > vixm
changeset 46:2d570448aba5 pure
Abstract out the stats code a little bit more
This is in preparation for moving the stats code completely out of player
code
author | Josef "Jeff" Sipek <jeffpc@josefsipek.net> |
---|---|
date | Mon, 06 Nov 2006 05:19:23 -0500 |
parents | 2bf81d95246a |
children | 1ae315a49009 |
files | run vixm/main.py vixm/player.py vixm/stats.py |
diffstat | 4 files changed, 13 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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) +
--- 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
--- 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:
--- 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() - +