Merge scrobble to master
This commit is contained in:
commit
c4c0aa00c6
13
README.md
13
README.md
|
@ -16,24 +16,23 @@ Leia compatible version available in alternate branch
|
|||
* Download songs
|
||||
* Star songs
|
||||
* Navidrome compatibility added (please report any issues)
|
||||
* Scrobble to Last.FM
|
||||
|
||||
## Installation
|
||||
From repository
|
||||
[repository.warwickh-0.9.0.zip](https://github.com/warwickh/repository.warwickh/raw/master/matrix/zips/repository.warwickh/repository.warwickh-0.9.0.zip) (Please report any issues)
|
||||
|
||||
From GitHub
|
||||
* Click the code button and download
|
||||
* Enable unknown sources and install from zip in Kodi
|
||||
|
||||
|
||||
or
|
||||
|
||||
* Navigate to your `.kodi/addons/` folder
|
||||
* Clone this repository: `git clone https://github.com/warwickh/plugin.audio.subsonic.git`
|
||||
* (Re)start Kodi.
|
||||
|
||||
Note: You may need to install dependencies manually if installing this way. I recommend installing from zip first, then updating using git clone
|
||||
|
||||
Repository installation now available
|
||||
[repository.warwickh-0.9.0.zip](https://github.com/warwickh/repository.warwickh/raw/master/matrix/zips/repository.warwickh/repository.warwickh-0.9.0.zip) (Please report any issues)
|
||||
|
||||
## TODO
|
||||
* Scrobble to Last.FM (http://forum.kodi.tv/showthread.php?tid=195597&pid=2429362#pid2429362)
|
||||
* Improve the caching system
|
||||
* Search filter GUI for tracks and albums
|
||||
|
||||
|
|
17
addon.xml
17
addon.xml
|
@ -1,13 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<addon id="plugin.audio.subsonic" name="Subsonic" version="3.0.1" provider-name="BasilFX,grosbouff,silascutler,Heruwar,warwickh">
|
||||
<requires>
|
||||
<import addon="xbmc.python" version="3.0.0"/>
|
||||
<import addon="script.module.dateutil" version="2.4.2"/>
|
||||
<import addon="script.module.future" version="0.18.2"/>
|
||||
</requires>
|
||||
<extension point="xbmc.python.pluginsource" library="main.py">
|
||||
<provides>audio</provides>
|
||||
</extension>
|
||||
<requires>
|
||||
<import addon="xbmc.python" version="3.0.0"/>
|
||||
<import addon="script.module.dateutil" version="2.4.2"/>
|
||||
<import addon="script.module.future" version="0.18.2"/>
|
||||
</requires>
|
||||
<extension point="xbmc.python.pluginsource" library="main.py">
|
||||
<provides>audio</provides>
|
||||
</extension>
|
||||
<extension point="xbmc.service" library="service.py" />
|
||||
<extension point="xbmc.addon.metadata">
|
||||
<summary lang="en">Subsonic music addon for Kodi.</summary>
|
||||
<summary lang="fr">Extension Subsonic pour Kodi.</summary>
|
||||
|
|
|
@ -230,9 +230,11 @@ class Connection(object):
|
|||
viewName = '%s.view' % methodName
|
||||
|
||||
req = self._getRequest(viewName)
|
||||
xbmc.log("Pinging %s"%str(req.full_url),xbmc.LOGDEBUG)
|
||||
try:
|
||||
res = self._doInfoReq(req)
|
||||
except:
|
||||
except Exception as e:
|
||||
print("Ping failed %s"%e)
|
||||
return False
|
||||
if res['status'] == 'ok':
|
||||
return True
|
||||
|
|
|
@ -173,3 +173,6 @@ msgctxt "#30043"
|
|||
msgid "Merge album folders"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#30044"
|
||||
msgid "Scrobble to Last.FM"
|
||||
msgstr ""
|
||||
|
|
|
@ -172,3 +172,7 @@ msgstr ""
|
|||
msgctxt "#30043"
|
||||
msgid "Merge album folders"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#30044"
|
||||
msgid "Scrobble to Last.FM"
|
||||
msgstr ""
|
||||
|
|
|
@ -171,3 +171,7 @@ msgstr ""
|
|||
msgctxt "#30043"
|
||||
msgid "Merge album folders"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#30044"
|
||||
msgid "Scrobble to Last.FM"
|
||||
msgstr ""
|
||||
|
|
|
@ -26,7 +26,12 @@
|
|||
<setting label="30041" id="legacyauth" type="bool" default="false" />
|
||||
<setting label="30017" type="lsep" />
|
||||
<setting label="30018" id="cachetime" type="labelenum" default="3600" values="1|5|15|30|60|120|180|720|1440|3600"/>
|
||||
<<<<<<< HEAD
|
||||
<setting label="30043" id="merge" type="bool" default="true" />
|
||||
=======
|
||||
<setting label="30043" id="merge" type="bool" default="false" />
|
||||
<setting label="30044" id="scrobble" type="bool" default="false" />
|
||||
>>>>>>> scrobble
|
||||
|
||||
</category>
|
||||
</settings>
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
import re
|
||||
import xbmc
|
||||
import xbmcvfs
|
||||
import os
|
||||
import xbmcaddon
|
||||
# Add the /lib folder to sys
|
||||
sys.path.append(xbmcvfs.translatePath(os.path.join(xbmcaddon.Addon("plugin.audio.subsonic").getAddonInfo("path"), "lib")))
|
||||
|
||||
import libsonic
|
||||
|
||||
from simpleplugin import Plugin
|
||||
from simpleplugin import Addon
|
||||
|
||||
# Create plugin instance
|
||||
plugin = Plugin()
|
||||
connection = None
|
||||
|
||||
try:
|
||||
scrobbleEnabled = Addon().get_setting('scrobble')
|
||||
except:
|
||||
scrobbleEnabled = False
|
||||
|
||||
scrobbled = False
|
||||
|
||||
def popup(text, time=5000, image=None):
|
||||
title = plugin.addon.getAddonInfo('name')
|
||||
icon = plugin.addon.getAddonInfo('icon')
|
||||
xbmc.executebuiltin('Notification(%s, %s, %d, %s)' % (title, text,
|
||||
time, icon))
|
||||
def get_connection():
|
||||
global connection
|
||||
|
||||
if connection==None:
|
||||
connected = False
|
||||
# Create connection
|
||||
try:
|
||||
connection = libsonic.Connection(
|
||||
baseUrl=Addon().get_setting('subsonic_url'),
|
||||
username=Addon().get_setting('username', convert=False),
|
||||
password=Addon().get_setting('password', convert=False),
|
||||
port=Addon().get_setting('port'),
|
||||
apiVersion=Addon().get_setting('apiversion'),
|
||||
insecure=Addon().get_setting('insecure'),
|
||||
legacyAuth=Addon().get_setting('legacyauth'),
|
||||
useGET=Addon().get_setting('useget'),
|
||||
)
|
||||
connected = connection.ping()
|
||||
except:
|
||||
pass
|
||||
|
||||
if connected==False:
|
||||
popup('Connection error')
|
||||
return False
|
||||
|
||||
return connection
|
||||
|
||||
def scrobble_track(track_id):
|
||||
connection = get_connection()
|
||||
|
||||
if connection==False:
|
||||
return False
|
||||
res = connection.scrobble(track_id)
|
||||
#xbmc.log("response %s"%(res), xbmc.LOGINFO)
|
||||
if res['status'] == 'ok':
|
||||
popup("Scrobbled track")
|
||||
return True
|
||||
else:
|
||||
popup("Scrobble failed")
|
||||
return False
|
||||
|
||||
if __name__ == '__main__':
|
||||
monitor = xbmc.Monitor()
|
||||
xbmc.log("Subsonic service started", xbmc.LOGINFO)
|
||||
popup("Subsonic service started")
|
||||
while not monitor.abortRequested():
|
||||
if monitor.waitForAbort(10):
|
||||
break
|
||||
if (xbmc.getCondVisibility("Player.HasMedia")):
|
||||
try:
|
||||
if(scrobbleEnabled):
|
||||
currentFileName = xbmc.getInfoLabel("Player.Filenameandpath")
|
||||
currentFileProgress = xbmc.getInfoLabel("Player.Progress")
|
||||
pattern = re.compile(r'plugin:\/\/plugin\.audio\.subsonic\/\?action=play_track&id=(.*?)&')
|
||||
currentTrackId = re.findall(pattern, currentFileName)[0]
|
||||
#xbmc.log("Name %s Id %s Progress %s"%(currentFileName,currentTrackId,currentFileProgress), xbmc.LOGDEBUG)
|
||||
if (int(currentFileProgress)<50):
|
||||
scrobbled = False
|
||||
elif (int(currentFileProgress)>=50 and scrobbled == False):
|
||||
xbmc.log("Scrobbling Track Id %s"%(currentTrackId), xbmc.LOGDEBUG)
|
||||
success = scrobble_track(currentTrackId)
|
||||
if success:
|
||||
scrobbled = True
|
||||
else:
|
||||
pass
|
||||
except IndexError:
|
||||
print ("Not a Subsonic track")
|
||||
scrobbled = True
|
||||
except Exception as e:
|
||||
xbmc.log("Subsonic service failed %e"%e, xbmc.LOGINFO)
|
||||
else:
|
||||
pass
|
||||
#xbmc.log("Playing stopped", xbmc.LOGINFO)
|
||||
|
Loading…
Reference in New Issue