mirror of
https://github.com/gordielachance/plugin.audio.subsonic
synced 2025-01-06 05:18:42 +01:00
More efficient settings and return value
This commit is contained in:
parent
596ddaacdb
commit
8c4f31db05
12
service.py
12
service.py
@ -15,6 +15,7 @@ from simpleplugin import Addon
|
|||||||
plugin = Plugin()
|
plugin = Plugin()
|
||||||
connection = None
|
connection = None
|
||||||
|
|
||||||
|
scrobbleEnabled = Addon().get_setting('scrobble')
|
||||||
scrobbled = False
|
scrobbled = False
|
||||||
|
|
||||||
def get_connection():
|
def get_connection():
|
||||||
@ -48,9 +49,9 @@ def scrobble_track(track_id):
|
|||||||
connection = get_connection()
|
connection = get_connection()
|
||||||
|
|
||||||
if connection==False:
|
if connection==False:
|
||||||
return
|
return False
|
||||||
res = connection.scrobble(track_id)
|
res = connection.scrobble(track_id)
|
||||||
xbmc.log("response %s"%(scrobble), xbmc.LOGINFO)
|
#xbmc.log("response %s"%(res), xbmc.LOGINFO)
|
||||||
if res['status'] == 'ok':
|
if res['status'] == 'ok':
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@ -64,7 +65,7 @@ if __name__ == '__main__':
|
|||||||
break
|
break
|
||||||
if (xbmc.getCondVisibility("Player.HasMedia")):
|
if (xbmc.getCondVisibility("Player.HasMedia")):
|
||||||
try:
|
try:
|
||||||
if(Addon().get_setting('scrobble')):
|
if(scrobbleEnabled):
|
||||||
currentFileName = xbmc.getInfoLabel("Player.Filenameandpath")
|
currentFileName = xbmc.getInfoLabel("Player.Filenameandpath")
|
||||||
currentFileProgress = xbmc.getInfoLabel("Player.Progress")
|
currentFileProgress = xbmc.getInfoLabel("Player.Progress")
|
||||||
pattern = re.compile(r'plugin:\/\/plugin\.audio\.subsonic\/\?action=play_track&id=(.*?)&')
|
pattern = re.compile(r'plugin:\/\/plugin\.audio\.subsonic\/\?action=play_track&id=(.*?)&')
|
||||||
@ -74,8 +75,9 @@ if __name__ == '__main__':
|
|||||||
scrobbled = False
|
scrobbled = False
|
||||||
elif (int(currentFileProgress)>=50 and scrobbled == False):
|
elif (int(currentFileProgress)>=50 and scrobbled == False):
|
||||||
xbmc.log("Scrobbling Track Id %s"%(currentTrackId), xbmc.LOGDEBUG)
|
xbmc.log("Scrobbling Track Id %s"%(currentTrackId), xbmc.LOGDEBUG)
|
||||||
scrobble_track(currentTrackId)
|
success = scrobble_track(currentTrackId)
|
||||||
scrobbled = True
|
if success:
|
||||||
|
scrobbled = True
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user