diff options
author | jerous <jerous@gmail.com> | 2008-10-28 13:59:45 +0100 |
---|---|---|
committer | jerous <jerous@gmail.com> | 2008-10-28 14:07:40 +0100 |
commit | ae87697f23971d7297452b2cf6971c97b01d2c64 (patch) | |
tree | 1441ae877cc236a0071651c18e6798f8c9c98340 /plugins | |
parent | ce8bcfd5c8a156c5fc5a7b10cce922b0fff7009b (diff) |
Scrobbler: no fatal crash (or error messages) when there is no internetconnection
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Scrobbler.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/Scrobbler.py b/plugins/Scrobbler.py index fc60502..f634196 100644 --- a/plugins/Scrobbler.py +++ b/plugins/Scrobbler.py @@ -8,6 +8,7 @@ from clPlugin import * class pluginScrobbler(Plugin): submitted=False time=None + loggedIn=False def __init__(self, winMain): Plugin.__init__(self, winMain, 'Scrobbler') self.addMontyListener('onSongChange', self.onSongChange) @@ -18,10 +19,14 @@ class pluginScrobbler(Plugin): def _login(self): self.submitting=False + self.loggedIn=False if self._username(): self.normal("logging in %s"%(self._username())) - login(self._username(), self._password()) - self.normal("logged in") + try: + login(self._username(), self._password()) + self.loggedIn=True + except Exception, e: + self.normal("failed to login: "+str(e)) else: self.debug("no username provided, not logging in") @@ -30,7 +35,7 @@ class pluginScrobbler(Plugin): def _password(self): return settings.get('scrobbler.password', '') def onTimeChange(self, params): - if self.submitted==False: + if self.submitted==False and self.loggedIn: song=monty.getCurrentSong() if song.getTag('time')>30: if int(params['newTime'])>int(song.getTag('time'))/2 \ @@ -56,6 +61,8 @@ class pluginScrobbler(Plugin): self.important("failed to submit the song!") def onSongChange(self, params): + if self.loggedIn==False: + return self.time=int(time.mktime(datetime.utcnow().timetuple())) self.submitted=False song=monty.getCurrentSong() |