~abranches/listen/statusbar

« back to all changes in this revision

Viewing changes to src/widget/timer.py

  • Committer: Pedro Abranches
  • Date: 2009-06-08 22:34:05 UTC
  • Revision ID: pedro@pedro-laptop-20090608223405-cgkeiakk7t5ipvok
Improved the Last.fm queue feature.
Now it saves the report queue to a cache file and those songs can be later reported when Listen is started with an internet connection.

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
        else:
107
107
            text = utils.duration_to_string(pos*1000,"00:00")+" "+_("of")+" "+utils.duration_to_string(duration*1000,"00:00")
108
108
        self.label_time.set_label("<span size=\"small\">"+text+"</span>")
109
 
        if self.__need_report and duration>10 and pos >= min(duration/2, 240*1000):
110
 
            self.__need_report = False
111
 
            s = Player.song
112
 
            if s:
113
 
                if s.get("#playcount"):
114
 
                    ListenDB.set_property(s,{"#playcount":s.get("#playcount")+1})
115
 
                else:
116
 
                    ListenDB.set_property(s,{"#playcount":1})
117
 
                ListenDB.set_property(s,{"#lastplayed":time.time()})
118
 
                stamp = str(int(time.time()) - duration)
119
 
                Player.set_song_reported()
120
 
                AudioScrobblerManager.report_song(Player.song, stamp)
 
109
 
 
110
        s = Player.song
 
111
        if self.__need_report and duration>10 and pos >= min(duration/2, 240*1000) and \
 
112
           s.get("#duration")>=30*1000 and ListenDB.song_has_capability(s,"audioscrobbler"):
 
113
               self.__need_report = False
 
114
               if s:
 
115
                   if s.get("#playcount"):
 
116
                       ListenDB.set_property(s,{"#playcount":s.get("#playcount")+1})
 
117
                   else:
 
118
                       ListenDB.set_property(s,{"#playcount":1})
 
119
                   ListenDB.set_property(s,{"#lastplayed":time.time()})
 
120
                   stamp = str(int(time.time()) - duration)
 
121
                   Player.set_song_reported()
 
122
                   AudioScrobblerManager.report_song(Player.song, stamp)
121
123
 
122
124
    def on_seek(self, *args, **kwargs):
123
125
        self.__need_report = False