Compare commits
91 Commits
Author | SHA1 | Date |
---|---|---|
warwickh | 4fffcd143e | |
Giovanni Fulco | e59b65d5e0 | |
warwickh | fa0c4ec165 | |
warwickh | 2c785729ee | |
BlackEagle | d11505bd04 | |
warwickh | d221fa4f39 | |
warwickh | ec86d2abdd | |
warwickh | b9a556eded | |
warwickh | 4e15a1d0d3 | |
warwickh | 1295d078e5 | |
warwickh | 4b1e0ad104 | |
warwickh | 7baa12f06f | |
warwickh | f97b9e1de9 | |
warwickh | 8ca52e6cc8 | |
Warwick Harris | c4c0aa00c6 | |
Warwick Harris | 67bd25496e | |
warwickh | 0932e650f8 | |
Warwick Harris | 57141eed02 | |
Warwick Harris | 2335973433 | |
warwickh | 150b5012da | |
warwickh | 8c4f31db05 | |
warwickh | 596ddaacdb | |
warwickh | c25e5848cf | |
warwickh | 469681bf5e | |
warwickh | ced597b6d2 | |
warwickh | 03da132550 | |
warwickh | 742c5b66fc | |
warwickh | 640157dad0 | |
warwickh | 56dffe70bc | |
warwickh | 34a7c249be | |
warwickh | 67d2302bc4 | |
warwickh | 9fbb67cc3c | |
warwickh | 0ac9d36187 | |
warwickh | 49754bccaa | |
warwickh | 358df44fb1 | |
Warwick Harris | a551df5c8c | |
warwickh | e640d0f81d | |
warwickh | 3aac9d1c54 | |
Warwick Harris | 7564e75f63 | |
Warwick Harris | ed3f7da8b5 | |
warwickh | 194844571c | |
warwickh | 6035ff49b8 | |
warwickh | bc30d36466 | |
gordielachance | 445303a2fc | |
warwickh | 2d76c74f42 | |
warwickh | a7f74582de | |
warwickh | 41a747a2b7 | |
warwickh | 2e5d012cae | |
warwickh | 53ecd6e5d1 | |
warwickh | 2efa209227 | |
warwickh | 1703d433a3 | |
warwickh | 17f77aca93 | |
warwickh | a136a7b47e | |
warwickh | b461af0269 | |
warwickh | bf1ee6bd1b | |
warwickh | 79a9b1ebc3 | |
warwickh | 46da611895 | |
warwickh | d524b8cc8e | |
warwickh | 0ddda4676c | |
warwickh | 1d22cd75c1 | |
warwickh | 1fc06bd790 | |
warwickh | e958c5bb2a | |
warwickh | 9d86ff2051 | |
warwickh | 71e208b662 | |
warwickh | 6910755b36 | |
warwickh | aca6ad6e83 | |
warwickh | adc78f9783 | |
warwickh | 0c32547c0d | |
warwickh | 67b5e4ab8c | |
warwickh | 861e7534c6 | |
warwickh | c65548a73b | |
warwickh | f5202f2229 | |
warwickh | 2b3789fe5c | |
warwickh | 92356ab533 | |
warwickh | 1d3181fe4e | |
gordielachance | 577181bb73 | |
gordielachance | f0649bf2b5 | |
gordielachance | b630801150 | |
David | 99d57fa1f9 | |
gordielachance | f7ccef89ef | |
gordielachance | d90af02d8b | |
heru | 4429451454 | |
heru | 313b413fc5 | |
heru | 30d0e8641e | |
gordielachance | b18b8e0094 | |
gordielachance | 66ae5ee093 | |
gordielachance | 426dcf964f | |
Silas Cutler | ce58b6993f | |
Silas Cutler | f51e5c3c28 | |
Silas Cutler | e966b5bfa2 | |
Silas Cutler | 9e7e542585 |
29
CHANGELOG.md
29
CHANGELOG.md
|
@ -1,5 +1,34 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v3.0.2
|
||||||
|
Released 29th September 2021 (by warwickh)
|
||||||
|
* Removed dependency on future and dateutil
|
||||||
|
* Simpleplugin modified - no longer py2 compatible
|
||||||
|
|
||||||
|
## v3.0.1
|
||||||
|
Released 2nd September 2021 (by warwickh)
|
||||||
|
* Added Navidrome compatibility (remove dependency on integer ids)
|
||||||
|
|
||||||
|
## v3.0.0
|
||||||
|
Released 29th June 2021 (by warwickh)
|
||||||
|
* Basic update to provide Matrix compatility. Not tested on Kodi below v19
|
||||||
|
* Updates simpleplugin to latest version (3.0.0) https://github.com/vlmaksime/script.module.simpleplugin
|
||||||
|
* Moves some legacy simpleplugin static routines into main.py
|
||||||
|
* Removes dependancy on libsonic_extra by moving some walk functions into main.py
|
||||||
|
* Updates libsonic to latest version and adds functions for returning raw url for populating menus
|
||||||
|
* Move to version 3+ for diffferentiation from Leia compatible version
|
||||||
|
|
||||||
|
## v2.0.8
|
||||||
|
Released 29th November 2017 (by Heruwar)
|
||||||
|
* Fixes a security issue where the password is sent as plaintext in the URL query parameters when methods from libsonic_extas are used.
|
||||||
|
Also adds Subsonic hex encoding when using legacy auth.
|
||||||
|
* Adds support for URL paths like https://hostname.com/subsonic as requested in Github issue #17 and also encountered in some of the reports (#14 and #5)
|
||||||
|
* Fixes an error when the password only contains digits, which simpleplugin converts to a Long, which later fails when libsonic tries to salt the password expecting a string.
|
||||||
|
|
||||||
|
## v2.0.7
|
||||||
|
Released 18 April 2017
|
||||||
|
* Added Search (by silascutler)
|
||||||
|
|
||||||
## v2.0.6
|
## v2.0.6
|
||||||
Released 14 January 2017
|
Released 14 January 2017
|
||||||
* Upgrade to simpleplugin 2.1.0
|
* Upgrade to simpleplugin 2.1.0
|
||||||
|
|
30
README.md
30
README.md
|
@ -1,22 +1,39 @@
|
||||||
# Subsonic
|
# Subsonic
|
||||||
Kodi plugin to stream, star and download music from Subsonic.
|
Kodi plugin to stream, star and download music from Subsonic/Airsonic/Navidrome (requires Subsonic API compatibility)
|
||||||
|
|
||||||
For feature requests / issues:
|
For feature requests / issues:
|
||||||
https://github.com/gordielachance/plugin.audio.subsonic/issues
|
https://github.com/warwickh/plugin.audio.subsonic/issues
|
||||||
|
|
||||||
Contributions are welcome:
|
Contributions are welcome:
|
||||||
https://github.com/gordielachance/plugin.audio.subsonic
|
https://github.com/warwickh/plugin.audio.subsonic
|
||||||
|
|
||||||
|
Master branch updated to support Kodi 19 Matrix
|
||||||
|
|
||||||
|
Leia compatible version available in alternate branch
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* Browse by artist, albums (newest/most played/recently played/random), tracks (starred/random), and playlists
|
* Browse by artist, albums (newest/most played/recently played/random), tracks (starred/random), and playlists
|
||||||
* Download songs
|
* Download songs
|
||||||
* Star songs
|
* Star songs
|
||||||
|
* Navidrome compatibility added (please report any issues)
|
||||||
|
* Scrobble to Last.FM
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
From repository
|
||||||
|
[repository.warwickh](https://github.com/warwickh/repository.warwickh/raw/master/matrix/zips/repository.warwickh) (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
|
* Navigate to your `.kodi/addons/` folder
|
||||||
* Clone this repository: `git clone https://github.com/gordielachance/plugin.audio.subsonic.git`
|
* Clone this repository: `git clone https://github.com/warwickh/plugin.audio.subsonic.git`
|
||||||
* (Re)start Kodi.
|
* (Re)start Kodi.
|
||||||
|
|
||||||
|
Note: You will need to enter your server settings into the plugin configuration before use
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
* Scrobble to Last.FM (http://forum.kodi.tv/showthread.php?tid=195597&pid=2429362#pid2429362)
|
|
||||||
* Improve the caching system
|
* Improve the caching system
|
||||||
* Search filter GUI for tracks and albums
|
* Search filter GUI for tracks and albums
|
||||||
|
|
||||||
|
@ -24,7 +41,8 @@ https://github.com/gordielachance/plugin.audio.subsonic
|
||||||
See the `LICENSE` file.
|
See the `LICENSE` file.
|
||||||
|
|
||||||
Additional copyright notices:
|
Additional copyright notices:
|
||||||
|
* [Previous version of this plugin](https://github.com/gordielachance/plugin.audio.subsonic) by gordielachance
|
||||||
* [Previous version of this plugin](https://github.com/basilfx/plugin.audio.subsonic) by basilfx
|
* [Previous version of this plugin](https://github.com/basilfx/plugin.audio.subsonic) by basilfx
|
||||||
* [SimplePlugin](https://github.com/romanvm/script.module.simpleplugin/stargazers) by romanvm
|
* [SimplePlugin](https://github.com/romanvm/script.module.simpleplugin/stargazers) by romanvm now at [SimplePlugin3](https://github.com/vlmaksime/script.module.simpleplugin)
|
||||||
* The original [SubKodi](https://github.com/DarkAllMan/SubKodi) plugin
|
* The original [SubKodi](https://github.com/DarkAllMan/SubKodi) plugin
|
||||||
* [`py-sonic`](https://github.com/crustymonkey/py-sonic) Python module
|
* [`py-sonic`](https://github.com/crustymonkey/py-sonic) Python module
|
||||||
|
|
34
addon.xml
34
addon.xml
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="plugin.audio.subsonic" name="Subsonic" version="2.0.6" provider-name="BasilFX,grosbouff">
|
<addon id="plugin.audio.subsonic" name="Subsonic" version="3.0.2" provider-name="BasilFX,warwickh">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.14.0"/>
|
<import addon="xbmc.python" version="3.0.0"/>
|
||||||
<import addon="script.module.dateutil" version="2.4.2"/>
|
</requires>
|
||||||
</requires>
|
<extension point="xbmc.python.pluginsource" library="main.py">
|
||||||
<extension point="xbmc.python.pluginsource" library="main.py">
|
<provides>audio</provides>
|
||||||
<provides>audio</provides>
|
</extension>
|
||||||
</extension>
|
<extension point="xbmc.service" library="service.py" />
|
||||||
<extension point="xbmc.addon.metadata">
|
<extension point="xbmc.addon.metadata">
|
||||||
<summary lang="en">Subsonic music addon for Kodi.</summary>
|
<summary lang="en">Subsonic music addon for Kodi.</summary>
|
||||||
<summary lang="fr">Extension Subsonic pour Kodi.</summary>
|
<summary lang="fr">Extension Subsonic pour Kodi.</summary>
|
||||||
|
@ -14,31 +14,35 @@
|
||||||
<description lang="en">
|
<description lang="en">
|
||||||
Stream, star and download your tunes, directly to Kodi !
|
Stream, star and download your tunes, directly to Kodi !
|
||||||
For feature requests / issues:
|
For feature requests / issues:
|
||||||
https://github.com/gordielachance/plugin.audio.subsonic/issues
|
https://github.com/warwickh/plugin.audio.subsonic/issues
|
||||||
Contributions are welcome:
|
Contributions are welcome:
|
||||||
https://github.com/gordielachance/plugin.audio.subsonic
|
https://github.com/warwickh/plugin.audio.subsonic
|
||||||
</description>
|
</description>
|
||||||
<description lang="fr">
|
<description lang="fr">
|
||||||
Jouez, marquez vos favoris et téléchargez votre musique, directement dans Kodi !
|
Jouez, marquez vos favoris et téléchargez votre musique, directement dans Kodi !
|
||||||
Pour les demandes et problèmes :
|
Pour les demandes et problèmes :
|
||||||
https://github.com/gordielachance/plugin.audio.subsonic/issues
|
https://github.com/warwickh/plugin.audio.subsonic/issues
|
||||||
Les contributions sont les bienvenues :
|
Les contributions sont les bienvenues :
|
||||||
https://github.com/gordielachance/plugin.audio.subsonic
|
https://github.com/warwickh/plugin.audio.subsonic
|
||||||
</description>
|
</description>
|
||||||
<description lang="de">
|
<description lang="de">
|
||||||
Streame, bewerte und downloade deine Medien direkt in Kodi !
|
Streame, bewerte und downloade deine Medien direkt in Kodi !
|
||||||
Für neue Eigentschaften oder Fehler:
|
Für neue Eigentschaften oder Fehler:
|
||||||
https://github.com/gordielachance/plugin.audio.subsonic/issues
|
https://github.com/warwickh/plugin.audio.subsonic/issues
|
||||||
Beihilfe ist Willkommen:
|
Beihilfe ist Willkommen:
|
||||||
https://github.com/gordielachance/plugin.audio.subsonic
|
https://github.com/warwickh/plugin.audio.subsonic
|
||||||
</description>
|
</description>
|
||||||
|
<assets>
|
||||||
|
<icon>icon.png</icon>
|
||||||
|
<fanart>fanart.jpg</fanart>
|
||||||
|
</assets>
|
||||||
<disclaimer lang="en"></disclaimer>
|
<disclaimer lang="en"></disclaimer>
|
||||||
<language>multi</language>
|
<language>multi</language>
|
||||||
<platform>all</platform>
|
<platform>all</platform>
|
||||||
<license>MIT</license>
|
<license>MIT</license>
|
||||||
<forum></forum>
|
<forum></forum>
|
||||||
<website>http://www.subsonic.org</website>
|
<website>http://www.subsonic.org</website>
|
||||||
<source>https://github.com/gordielachance/plugin.audio.subsonic</source>
|
<source>https://github.com/warwickh/plugin.audio.subsonic</source>
|
||||||
<email></email>
|
<email></email>
|
||||||
</extension>
|
</extension>
|
||||||
</addon>
|
</addon>
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 124 KiB |
|
@ -1,32 +1,24 @@
|
||||||
"""
|
"""
|
||||||
This file is part of py-sonic.
|
This file is part of py-sonic.
|
||||||
|
|
||||||
py-sonic is free software: you can redistribute it and/or modify
|
py-sonic is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
py-sonic is distributed in the hope that it will be useful,
|
py-sonic is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with py-sonic. If not, see <http://www.gnu.org/licenses/>
|
along with py-sonic. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
For information on method calls, see 'pydoc libsonic.connection'
|
For information on method calls, see 'pydoc libsonic.connection'
|
||||||
|
|
||||||
----------
|
----------
|
||||||
Basic example:
|
Basic example:
|
||||||
----------
|
----------
|
||||||
|
|
||||||
import libsonic
|
import libsonic
|
||||||
|
|
||||||
conn = libsonic.Connection('http://localhost' , 'admin' , 'password')
|
conn = libsonic.Connection('http://localhost' , 'admin' , 'password')
|
||||||
print conn.ping()
|
print conn.ping()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from connection import *
|
from .connection import *
|
||||||
|
|
||||||
__version__ = '0.6.2'
|
__version__ = '0.7.9'
|
||||||
|
|
|
@ -15,23 +15,29 @@ You should have received a copy of the GNU General Public License
|
||||||
along with py-sonic. If not, see <http://www.gnu.org/licenses/>
|
along with py-sonic. If not, see <http://www.gnu.org/licenses/>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from urllib import urlencode
|
from libsonic.errors import *
|
||||||
from .errors import *
|
|
||||||
from pprint import pprint
|
|
||||||
from cStringIO import StringIO
|
|
||||||
from netrc import netrc
|
from netrc import netrc
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
import json, urllib2, httplib, logging, socket, ssl, sys, os
|
import urllib.request
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
from http import client as http_client
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
from io import StringIO
|
||||||
|
|
||||||
API_VERSION = '1.14.0'
|
import json
|
||||||
|
import logging
|
||||||
|
import socket
|
||||||
|
import ssl
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import xbmc
|
||||||
|
|
||||||
|
API_VERSION = '1.16.1'
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class HTTPSConnectionChain(httplib.HTTPSConnection):
|
class HTTPSConnectionChain(http_client.HTTPSConnection):
|
||||||
_preferred_ssl_protos = sorted([ p for p in dir(ssl)
|
|
||||||
if p.startswith('PROTOCOL_') ], reverse=True)
|
|
||||||
_ssl_working_proto = None
|
|
||||||
|
|
||||||
def _create_sock(self):
|
def _create_sock(self):
|
||||||
sock = socket.create_connection((self.host, self.port), self.timeout)
|
sock = socket.create_connection((self.host, self.port), self.timeout)
|
||||||
if self._tunnel_host:
|
if self._tunnel_host:
|
||||||
|
@ -40,38 +46,21 @@ class HTTPSConnectionChain(httplib.HTTPSConnection):
|
||||||
return sock
|
return sock
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
if self._ssl_working_proto is not None:
|
sock = self._create_sock()
|
||||||
# If we have a working proto, let's use that straight away
|
try:
|
||||||
logger.debug("Using known working proto: '%s'",
|
self.sock = self._context.wrap_socket(sock,
|
||||||
self._ssl_working_proto)
|
server_hostname=self.host)
|
||||||
sock = self._create_sock()
|
except:
|
||||||
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file,
|
sock.close()
|
||||||
ssl_version=self._ssl_working_proto)
|
|
||||||
return
|
|
||||||
|
|
||||||
# Try connecting via the different SSL protos in preference order
|
class HTTPSHandlerChain(urllib.request.HTTPSHandler):
|
||||||
for proto_name in self._preferred_ssl_protos:
|
|
||||||
sock = self._create_sock()
|
|
||||||
proto = getattr(ssl, proto_name, None)
|
|
||||||
try:
|
|
||||||
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file,
|
|
||||||
ssl_version=proto)
|
|
||||||
except:
|
|
||||||
sock.close()
|
|
||||||
else:
|
|
||||||
# Cache the working ssl version
|
|
||||||
HTTPSConnectionChain._ssl_working_proto = proto
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
class HTTPSHandlerChain(urllib2.HTTPSHandler):
|
|
||||||
def https_open(self, req):
|
def https_open(self, req):
|
||||||
return self.do_open(HTTPSConnectionChain, req)
|
return self.do_open(HTTPSConnectionChain, req, context=self._context)
|
||||||
|
|
||||||
# install opener
|
# install opener
|
||||||
urllib2.install_opener(urllib2.build_opener(HTTPSHandlerChain()))
|
urllib.request.install_opener(urllib.request.build_opener(HTTPSHandlerChain()))
|
||||||
|
|
||||||
class PysHTTPRedirectHandler(urllib2.HTTPRedirectHandler):
|
class PysHTTPRedirectHandler(urllib.request.HTTPRedirectHandler):
|
||||||
"""
|
"""
|
||||||
This class is used to override the default behavior of the
|
This class is used to override the default behavior of the
|
||||||
HTTPRedirectHandler, which does *not* redirect POST data
|
HTTPRedirectHandler, which does *not* redirect POST data
|
||||||
|
@ -81,24 +70,30 @@ class PysHTTPRedirectHandler(urllib2.HTTPRedirectHandler):
|
||||||
if (code in (301, 302, 303, 307) and m in ("GET", "HEAD")
|
if (code in (301, 302, 303, 307) and m in ("GET", "HEAD")
|
||||||
or code in (301, 302, 303) and m == "POST"):
|
or code in (301, 302, 303) and m == "POST"):
|
||||||
newurl = newurl.replace(' ', '%20')
|
newurl = newurl.replace(' ', '%20')
|
||||||
newheaders = dict((k, v) for k, v in req.headers.items()
|
newheaders = dict((k, v) for k, v in list(req.headers.items())
|
||||||
if k.lower() not in ("content-length", "content-type")
|
if k.lower() not in ("content-length", "content-type")
|
||||||
)
|
)
|
||||||
data = None
|
data = None
|
||||||
if req.has_data():
|
if req.data:
|
||||||
data = req.get_data()
|
data = req.data
|
||||||
return urllib2.Request(newurl,
|
return urllib.request.Request(newurl,
|
||||||
data=data,
|
data=data,
|
||||||
headers=newheaders,
|
headers=newheaders,
|
||||||
origin_req_host=req.get_origin_req_host(),
|
origin_req_host=req.origin_req_host,
|
||||||
unverifiable=True)
|
unverifiable=True)
|
||||||
else:
|
else:
|
||||||
raise urllib2.HTTPError(req.get_full_url(), code, msg, headers, fp)
|
raise urllib.error.HTTPError(
|
||||||
|
req.get_full_url(),
|
||||||
|
code,
|
||||||
|
msg,
|
||||||
|
headers,
|
||||||
|
fp,
|
||||||
|
)
|
||||||
|
|
||||||
class Connection(object):
|
class Connection(object):
|
||||||
def __init__(self, baseUrl, username=None, password=None, port=4040,
|
def __init__(self, baseUrl, username=None, password=None, port=4040,
|
||||||
serverPath='/rest', appName='py-sonic', apiVersion=API_VERSION,
|
serverPath='/rest', appName='py-sonic', apiVersion=API_VERSION,
|
||||||
insecure=False, useNetrc=None, legacyAuth=False, useGET=False):
|
insecure=False, useNetrc=None, legacyAuth=False, useGET=True):
|
||||||
"""
|
"""
|
||||||
This will create a connection to your subsonic server
|
This will create a connection to your subsonic server
|
||||||
|
|
||||||
|
@ -160,8 +155,18 @@ class Connection(object):
|
||||||
request. This is not recommended as request
|
request. This is not recommended as request
|
||||||
URLs can get very long with some API calls
|
URLs can get very long with some API calls
|
||||||
"""
|
"""
|
||||||
self._baseUrl = baseUrl
|
|
||||||
self._hostname = baseUrl.split('://')[1].strip()
|
self._baseUrl = baseUrl.rstrip('/')
|
||||||
|
self._hostname = self._baseUrl.split('://')[1]
|
||||||
|
if len(self._hostname.split('/'))>1:
|
||||||
|
print(len(self._hostname.split('/')))
|
||||||
|
xbmc.log("Got a folder %s"%(self._hostname.split('/')[1]),xbmc.LOGDEBUG)
|
||||||
|
parts = urllib.parse.urlparse(self._baseUrl)
|
||||||
|
self._baseUrl = "%s://%s" % (parts.scheme, parts.hostname)
|
||||||
|
self._hostname = parts.hostname
|
||||||
|
self._serverPath = parts.path.strip('/') + '/rest'
|
||||||
|
else:
|
||||||
|
self._serverPath = serverPath.strip('/')
|
||||||
self._username = username
|
self._username = username
|
||||||
self._rawPass = password
|
self._rawPass = password
|
||||||
self._legacyAuth = legacyAuth
|
self._legacyAuth = legacyAuth
|
||||||
|
@ -178,7 +183,6 @@ class Connection(object):
|
||||||
self._port = int(port)
|
self._port = int(port)
|
||||||
self._apiVersion = apiVersion
|
self._apiVersion = apiVersion
|
||||||
self._appName = appName
|
self._appName = appName
|
||||||
self._serverPath = serverPath.strip('/')
|
|
||||||
self._insecure = insecure
|
self._insecure = insecure
|
||||||
self._opener = self._getOpener(self._username, self._rawPass)
|
self._opener = self._getOpener(self._username, self._rawPass)
|
||||||
|
|
||||||
|
@ -236,9 +240,11 @@ class Connection(object):
|
||||||
viewName = '%s.view' % methodName
|
viewName = '%s.view' % methodName
|
||||||
|
|
||||||
req = self._getRequest(viewName)
|
req = self._getRequest(viewName)
|
||||||
|
xbmc.log("Pinging %s"%str(req.full_url),xbmc.LOGDEBUG)
|
||||||
try:
|
try:
|
||||||
res = self._doInfoReq(req)
|
res = self._doInfoReq(req)
|
||||||
except:
|
except Exception as e:
|
||||||
|
print("Ping failed %s"%e)
|
||||||
return False
|
return False
|
||||||
if res['status'] == 'ok':
|
if res['status'] == 'ok':
|
||||||
return True
|
return True
|
||||||
|
@ -271,6 +277,52 @@ class Connection(object):
|
||||||
self._checkStatus(res)
|
self._checkStatus(res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def getScanStatus(self):
|
||||||
|
"""
|
||||||
|
since: 1.15.0
|
||||||
|
|
||||||
|
returns the current status for media library scanning.
|
||||||
|
takes no extra parameters.
|
||||||
|
|
||||||
|
returns a dict like the following:
|
||||||
|
|
||||||
|
{'status': 'ok', 'version': '1.15.0',
|
||||||
|
'scanstatus': {'scanning': true, 'count': 4680}}
|
||||||
|
|
||||||
|
'count' is the total number of items to be scanned
|
||||||
|
"""
|
||||||
|
methodName = 'getScanStatus'
|
||||||
|
viewName = '%s.view' % methodName
|
||||||
|
|
||||||
|
req = self._getRequest(viewName)
|
||||||
|
res = self._doInfoReq(req)
|
||||||
|
self._checkStatus(res)
|
||||||
|
return res
|
||||||
|
|
||||||
|
def startScan(self):
|
||||||
|
"""
|
||||||
|
since: 1.15.0
|
||||||
|
|
||||||
|
Initiates a rescan of the media libraries.
|
||||||
|
Takes no extra parameters.
|
||||||
|
|
||||||
|
returns a dict like the following:
|
||||||
|
|
||||||
|
{'status': 'ok', 'version': '1.15.0',
|
||||||
|
'scanstatus': {'scanning': true, 'count': 0}}
|
||||||
|
|
||||||
|
'scanning' changes to false when a scan is complete
|
||||||
|
'count' starts a 0 and ends at the total number of items scanned
|
||||||
|
|
||||||
|
"""
|
||||||
|
methodName = 'startScan'
|
||||||
|
viewName = '%s.view' % methodName
|
||||||
|
|
||||||
|
req = self._getRequest(viewName)
|
||||||
|
res = self._doInfoReq(req)
|
||||||
|
self._checkStatus(res)
|
||||||
|
return res
|
||||||
|
|
||||||
def getMusicFolders(self):
|
def getMusicFolders(self):
|
||||||
"""
|
"""
|
||||||
since: 1.0.0
|
since: 1.0.0
|
||||||
|
@ -809,6 +861,59 @@ class Connection(object):
|
||||||
self._checkStatus(res)
|
self._checkStatus(res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def streamUrl(self, sid, maxBitRate=0, tformat=None, timeOffset=None,
|
||||||
|
size=None, estimateContentLength=False, converted=False):
|
||||||
|
"""
|
||||||
|
since: 1.0.0
|
||||||
|
|
||||||
|
Downloads a given music file.
|
||||||
|
|
||||||
|
sid:str The ID of the music file to download.
|
||||||
|
maxBitRate:int (since: 1.2.0) If specified, the server will
|
||||||
|
attempt to limit the bitrate to this value, in
|
||||||
|
kilobits per second. If set to zero (default), no limit
|
||||||
|
is imposed. Legal values are: 0, 32, 40, 48, 56, 64,
|
||||||
|
80, 96, 112, 128, 160, 192, 224, 256 and 320.
|
||||||
|
tformat:str (since: 1.6.0) Specifies the target format
|
||||||
|
(e.g. "mp3" or "flv") in case there are multiple
|
||||||
|
applicable transcodings (since: 1.9.0) You can use
|
||||||
|
the special value "raw" to disable transcoding
|
||||||
|
timeOffset:int (since: 1.6.0) Only applicable to video
|
||||||
|
streaming. Start the stream at the given
|
||||||
|
offset (in seconds) into the video
|
||||||
|
size:str (since: 1.6.0) The requested video size in
|
||||||
|
WxH, for instance 640x480
|
||||||
|
estimateContentLength:bool (since: 1.8.0) If set to True,
|
||||||
|
the HTTP Content-Length header
|
||||||
|
will be set to an estimated
|
||||||
|
value for trancoded media
|
||||||
|
converted:bool (since: 1.14.0) Only applicable to video streaming.
|
||||||
|
Subsonic can optimize videos for streaming by
|
||||||
|
converting them to MP4. If a conversion exists for
|
||||||
|
the video in question, then setting this parameter
|
||||||
|
to "true" will cause the converted video to be
|
||||||
|
returned instead of the original.
|
||||||
|
|
||||||
|
Returns the file-like object for reading or raises an exception
|
||||||
|
on error
|
||||||
|
"""
|
||||||
|
methodName = 'stream'
|
||||||
|
viewName = '%s.view' % methodName
|
||||||
|
|
||||||
|
q = self._getQueryDict({'id': sid, 'maxBitRate': maxBitRate,
|
||||||
|
'format': tformat, 'timeOffset': timeOffset, 'size': size,
|
||||||
|
'estimateContentLength': estimateContentLength,
|
||||||
|
'converted': converted})
|
||||||
|
|
||||||
|
req = self._getRequest(viewName, q)
|
||||||
|
#xbmc.log("Requesting %s"%str(req.full_url),xbmc.LOGDEBUG)
|
||||||
|
return_url = req.full_url
|
||||||
|
if self._insecure:
|
||||||
|
return_url += '&verifypeer=false'
|
||||||
|
xbmc.log("Request is insecure %s"%return_url,level=xbmc.LOGDEBUG)
|
||||||
|
return return_url
|
||||||
|
|
||||||
|
|
||||||
def getCoverArt(self, aid, size=None):
|
def getCoverArt(self, aid, size=None):
|
||||||
"""
|
"""
|
||||||
since: 1.0.0
|
since: 1.0.0
|
||||||
|
@ -832,6 +937,32 @@ class Connection(object):
|
||||||
self._checkStatus(res)
|
self._checkStatus(res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def getCoverArtUrl(self, aid, size=None):
|
||||||
|
"""
|
||||||
|
since: 1.0.0
|
||||||
|
|
||||||
|
Returns a cover art image
|
||||||
|
|
||||||
|
aid:str ID string for the cover art image to download
|
||||||
|
size:int If specified, scale image to this size
|
||||||
|
|
||||||
|
Returns the file-like object for reading or raises an exception
|
||||||
|
on error
|
||||||
|
"""
|
||||||
|
methodName = 'getCoverArt'
|
||||||
|
viewName = '%s.view' % methodName
|
||||||
|
|
||||||
|
q = self._getQueryDict({'id': aid, 'size': size})
|
||||||
|
|
||||||
|
req = self._getRequest(viewName, q)
|
||||||
|
#xbmc.log("Requesting %s"%str(req.full_url),xbmc.LOGDEBUG)
|
||||||
|
return_url = req.full_url
|
||||||
|
if self._insecure:
|
||||||
|
return_url += '&verifypeer=false'
|
||||||
|
xbmc.log("Request is insecure %s"%return_url,level=xbmc.LOGDEBUG)
|
||||||
|
return return_url
|
||||||
|
|
||||||
|
|
||||||
def scrobble(self, sid, submission=True, listenTime=None):
|
def scrobble(self, sid, submission=True, listenTime=None):
|
||||||
"""
|
"""
|
||||||
since: 1.5.0
|
since: 1.5.0
|
||||||
|
@ -980,7 +1111,7 @@ class Connection(object):
|
||||||
streamRole=True, jukeboxRole=False, downloadRole=False,
|
streamRole=True, jukeboxRole=False, downloadRole=False,
|
||||||
uploadRole=False, playlistRole=False, coverArtRole=False,
|
uploadRole=False, playlistRole=False, coverArtRole=False,
|
||||||
commentRole=False, podcastRole=False, shareRole=False,
|
commentRole=False, podcastRole=False, shareRole=False,
|
||||||
musicFolderId=None):
|
videoConversionRole=False, musicFolderId=None):
|
||||||
"""
|
"""
|
||||||
since: 1.1.0
|
since: 1.1.0
|
||||||
|
|
||||||
|
@ -1011,6 +1142,7 @@ class Connection(object):
|
||||||
'uploadRole': uploadRole, 'playlistRole': playlistRole,
|
'uploadRole': uploadRole, 'playlistRole': playlistRole,
|
||||||
'coverArtRole': coverArtRole, 'commentRole': commentRole,
|
'coverArtRole': coverArtRole, 'commentRole': commentRole,
|
||||||
'podcastRole': podcastRole, 'shareRole': shareRole,
|
'podcastRole': podcastRole, 'shareRole': shareRole,
|
||||||
|
'videoConversionRole': videoConversionRole,
|
||||||
'musicFolderId': musicFolderId
|
'musicFolderId': musicFolderId
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1024,7 +1156,7 @@ class Connection(object):
|
||||||
streamRole=True, jukeboxRole=False, downloadRole=False,
|
streamRole=True, jukeboxRole=False, downloadRole=False,
|
||||||
uploadRole=False, playlistRole=False, coverArtRole=False,
|
uploadRole=False, playlistRole=False, coverArtRole=False,
|
||||||
commentRole=False, podcastRole=False, shareRole=False,
|
commentRole=False, podcastRole=False, shareRole=False,
|
||||||
musicFolderId=None, maxBitRate=0):
|
videoConversionRole=False, musicFolderId=None, maxBitRate=0):
|
||||||
"""
|
"""
|
||||||
since 1.10.1
|
since 1.10.1
|
||||||
|
|
||||||
|
@ -1056,6 +1188,7 @@ class Connection(object):
|
||||||
'uploadRole': uploadRole, 'playlistRole': playlistRole,
|
'uploadRole': uploadRole, 'playlistRole': playlistRole,
|
||||||
'coverArtRole': coverArtRole, 'commentRole': commentRole,
|
'coverArtRole': coverArtRole, 'commentRole': commentRole,
|
||||||
'podcastRole': podcastRole, 'shareRole': shareRole,
|
'podcastRole': podcastRole, 'shareRole': shareRole,
|
||||||
|
'videoConversionRole': videoConversionRole,
|
||||||
'musicFolderId': musicFolderId, 'maxBitRate': maxBitRate
|
'musicFolderId': musicFolderId, 'maxBitRate': maxBitRate
|
||||||
})
|
})
|
||||||
req = self._getRequest(viewName, q)
|
req = self._getRequest(viewName, q)
|
||||||
|
@ -1874,6 +2007,7 @@ class Connection(object):
|
||||||
q['musicFolderId'] = musicFolderId
|
q['musicFolderId'] = musicFolderId
|
||||||
|
|
||||||
req = self._getRequest(viewName, q)
|
req = self._getRequest(viewName, q)
|
||||||
|
xbmc.log("Requesting %s"%str(req.full_url),xbmc.LOGDEBUG)
|
||||||
res = self._doInfoReq(req)
|
res = self._doInfoReq(req)
|
||||||
self._checkStatus(res)
|
self._checkStatus(res)
|
||||||
return res
|
return res
|
||||||
|
@ -1960,7 +2094,7 @@ class Connection(object):
|
||||||
req = self._getRequest(viewName, q)
|
req = self._getRequest(viewName, q)
|
||||||
try:
|
try:
|
||||||
res = self._doBinReq(req)
|
res = self._doBinReq(req)
|
||||||
except urllib2.HTTPError:
|
except urllib.error.HTTPError:
|
||||||
# Avatar is not set/does not exist, return None
|
# Avatar is not set/does not exist, return None
|
||||||
return None
|
return None
|
||||||
if isinstance(res, dict):
|
if isinstance(res, dict):
|
||||||
|
@ -2065,7 +2199,7 @@ class Connection(object):
|
||||||
musicFolderId:int Only return results from the music folder
|
musicFolderId:int Only return results from the music folder
|
||||||
with the given ID. See getMusicFolders
|
with the given ID. See getMusicFolders
|
||||||
"""
|
"""
|
||||||
methodName = 'getGenres'
|
methodName = 'getSongsByGenre'
|
||||||
viewName = '%s.view' % methodName
|
viewName = '%s.view' % methodName
|
||||||
|
|
||||||
q = self._getQueryDict({'genre': genre,
|
q = self._getQueryDict({'genre': genre,
|
||||||
|
@ -2112,7 +2246,7 @@ class Connection(object):
|
||||||
req = self._getRequest(viewName, q)
|
req = self._getRequest(viewName, q)
|
||||||
try:
|
try:
|
||||||
res = self._doBinReq(req)
|
res = self._doBinReq(req)
|
||||||
except urllib2.HTTPError:
|
except urllib.error.HTTPError:
|
||||||
# Avatar is not set/does not exist, return None
|
# Avatar is not set/does not exist, return None
|
||||||
return None
|
return None
|
||||||
if isinstance(res, dict):
|
if isinstance(res, dict):
|
||||||
|
@ -2224,6 +2358,70 @@ class Connection(object):
|
||||||
self._checkStatus(res)
|
self._checkStatus(res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def createInternetRadioStation(self, streamUrl, name, homepageUrl=None):
|
||||||
|
"""
|
||||||
|
since 1.16.0
|
||||||
|
|
||||||
|
Create an internet radio station
|
||||||
|
|
||||||
|
streamUrl:str The stream URL for the station
|
||||||
|
name:str The user-defined name for the station
|
||||||
|
homepageUrl:str The homepage URL for the station
|
||||||
|
"""
|
||||||
|
methodName = 'createInternetRadioStation'
|
||||||
|
viewName = '{}.view'.format(methodName)
|
||||||
|
|
||||||
|
q = self._getQueryDict({
|
||||||
|
'streamUrl': streamUrl, 'name': name, 'homepageUrl': homepageUrl})
|
||||||
|
|
||||||
|
req = self._getRequest(viewName, q)
|
||||||
|
res = self._doInfoReq(req)
|
||||||
|
self._checkStatus(res)
|
||||||
|
return res
|
||||||
|
|
||||||
|
def updateInternetRadioStation(self, iid, streamUrl, name,
|
||||||
|
homepageUrl=None):
|
||||||
|
"""
|
||||||
|
since 1.16.0
|
||||||
|
|
||||||
|
Create an internet radio station
|
||||||
|
|
||||||
|
iid:str The ID for the station
|
||||||
|
streamUrl:str The stream URL for the station
|
||||||
|
name:str The user-defined name for the station
|
||||||
|
homepageUrl:str The homepage URL for the station
|
||||||
|
"""
|
||||||
|
methodName = 'updateInternetRadioStation'
|
||||||
|
viewName = '{}.view'.format(methodName)
|
||||||
|
|
||||||
|
q = self._getQueryDict({
|
||||||
|
'id': iid, 'streamUrl': streamUrl, 'name': name,
|
||||||
|
'homepageUrl': homepageUrl,
|
||||||
|
})
|
||||||
|
|
||||||
|
req = self._getRequest(viewName, q)
|
||||||
|
res = self._doInfoReq(req)
|
||||||
|
self._checkStatus(res)
|
||||||
|
return res
|
||||||
|
|
||||||
|
def deleteInternetRadioStation(self, iid):
|
||||||
|
"""
|
||||||
|
since 1.16.0
|
||||||
|
|
||||||
|
Create an internet radio station
|
||||||
|
|
||||||
|
iid:str The ID for the station
|
||||||
|
"""
|
||||||
|
methodName = 'deleteInternetRadioStation'
|
||||||
|
viewName = '{}.view'.format(methodName)
|
||||||
|
|
||||||
|
q = {'id': iid}
|
||||||
|
|
||||||
|
req = self._getRequest(viewName, q)
|
||||||
|
res = self._doInfoReq(req)
|
||||||
|
self._checkStatus(res)
|
||||||
|
return res
|
||||||
|
|
||||||
def getBookmarks(self):
|
def getBookmarks(self):
|
||||||
"""
|
"""
|
||||||
since: 1.9.0
|
since: 1.9.0
|
||||||
|
@ -2301,6 +2499,8 @@ class Connection(object):
|
||||||
|
|
||||||
req = self._getRequest(viewName, q)
|
req = self._getRequest(viewName, q)
|
||||||
res = self._doInfoReq(req)
|
res = self._doInfoReq(req)
|
||||||
|
print(req.get_full_url())
|
||||||
|
print(res)
|
||||||
self._checkStatus(res)
|
self._checkStatus(res)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -2490,7 +2690,8 @@ class Connection(object):
|
||||||
methodName = 'getVideoInfo'
|
methodName = 'getVideoInfo'
|
||||||
viewName = '%s.view' % methodName
|
viewName = '%s.view' % methodName
|
||||||
|
|
||||||
q = {'id': int(vid)}
|
#q = {'id': int(vid)}
|
||||||
|
q = {'id': vid}
|
||||||
req = self._getRequest(viewName, q)
|
req = self._getRequest(viewName, q)
|
||||||
res = self._doInfoReq(req)
|
res = self._doInfoReq(req)
|
||||||
self._checkStatus(res)
|
self._checkStatus(res)
|
||||||
|
@ -2507,7 +2708,8 @@ class Connection(object):
|
||||||
methodName = 'getAlbumInfo'
|
methodName = 'getAlbumInfo'
|
||||||
viewName = '%s.view' % methodName
|
viewName = '%s.view' % methodName
|
||||||
|
|
||||||
q = {'id': int(aid)}
|
#q = {'id': int(aid)}
|
||||||
|
q = {'id': aid}
|
||||||
req = self._getRequest(viewName, q)
|
req = self._getRequest(viewName, q)
|
||||||
res = self._doInfoReq(req)
|
res = self._doInfoReq(req)
|
||||||
self._checkStatus(res)
|
self._checkStatus(res)
|
||||||
|
@ -2524,7 +2726,8 @@ class Connection(object):
|
||||||
methodName = 'getAlbumInfo2'
|
methodName = 'getAlbumInfo2'
|
||||||
viewName = '%s.view' % methodName
|
viewName = '%s.view' % methodName
|
||||||
|
|
||||||
q = {'id': int(aid)}
|
#q = {'id': int(aid)}
|
||||||
|
q = {'id': aid}
|
||||||
req = self._getRequest(viewName, q)
|
req = self._getRequest(viewName, q)
|
||||||
res = self._doInfoReq(req)
|
res = self._doInfoReq(req)
|
||||||
self._checkStatus(res)
|
self._checkStatus(res)
|
||||||
|
@ -2543,7 +2746,8 @@ class Connection(object):
|
||||||
methodName = 'getCaptions'
|
methodName = 'getCaptions'
|
||||||
viewName = '%s.view' % methodName
|
viewName = '%s.view' % methodName
|
||||||
|
|
||||||
q = self._getQueryDict({'id': int(vid), 'format': fmt})
|
#q = self._getQueryDict({'id': int(vid), 'format': fmt})
|
||||||
|
q = self._getQueryDict({'id': vid, 'format': fmt})
|
||||||
req = self._getRequest(viewName, q)
|
req = self._getRequest(viewName, q)
|
||||||
res = self._doInfoReq(req)
|
res = self._doInfoReq(req)
|
||||||
self._checkStatus(res)
|
self._checkStatus(res)
|
||||||
|
@ -2561,7 +2765,7 @@ class Connection(object):
|
||||||
|
|
||||||
url = '%s:%d/%s/%s?%s' % (self._baseUrl, self._port,
|
url = '%s:%d/%s/%s?%s' % (self._baseUrl, self._port,
|
||||||
self._separateServerPath(), viewName, methodName)
|
self._separateServerPath(), viewName, methodName)
|
||||||
req = urllib2.Request(url)
|
req = urllib.request.Request(url)
|
||||||
res = self._opener.open(req)
|
res = self._opener.open(req)
|
||||||
res_msg = res.msg.lower()
|
res_msg = res.msg.lower()
|
||||||
return res_msg == 'ok'
|
return res_msg == 'ok'
|
||||||
|
@ -2575,14 +2779,17 @@ class Connection(object):
|
||||||
if sys.version_info[:3] >= (2, 7, 9) and self._insecure:
|
if sys.version_info[:3] >= (2, 7, 9) and self._insecure:
|
||||||
https_chain = HTTPSHandlerChain(
|
https_chain = HTTPSHandlerChain(
|
||||||
context=ssl._create_unverified_context())
|
context=ssl._create_unverified_context())
|
||||||
opener = urllib2.build_opener(PysHTTPRedirectHandler, https_chain)
|
opener = urllib.request.build_opener(
|
||||||
|
PysHTTPRedirectHandler,
|
||||||
|
https_chain,
|
||||||
|
)
|
||||||
return opener
|
return opener
|
||||||
|
|
||||||
def _getQueryDict(self, d):
|
def _getQueryDict(self, d):
|
||||||
"""
|
"""
|
||||||
Given a dictionary, it cleans out all the values set to None
|
Given a dictionary, it cleans out all the values set to None
|
||||||
"""
|
"""
|
||||||
for k, v in d.items():
|
for k, v in list(d.items()):
|
||||||
if v is None:
|
if v is None:
|
||||||
del d[k]
|
del d[k]
|
||||||
return d
|
return d
|
||||||
|
@ -2599,7 +2806,7 @@ class Connection(object):
|
||||||
qdict['p'] = 'enc:%s' % self._hexEnc(self._rawPass)
|
qdict['p'] = 'enc:%s' % self._hexEnc(self._rawPass)
|
||||||
else:
|
else:
|
||||||
salt = self._getSalt()
|
salt = self._getSalt()
|
||||||
token = md5(self._rawPass + salt).hexdigest()
|
token = md5((self._rawPass + salt).encode('utf-8')).hexdigest()
|
||||||
qdict.update({
|
qdict.update({
|
||||||
's': salt,
|
's': salt,
|
||||||
't': token,
|
't': token,
|
||||||
|
@ -2612,12 +2819,13 @@ class Connection(object):
|
||||||
qdict.update(query)
|
qdict.update(query)
|
||||||
url = '%s:%d/%s/%s' % (self._baseUrl, self._port, self._serverPath,
|
url = '%s:%d/%s/%s' % (self._baseUrl, self._port, self._serverPath,
|
||||||
viewName)
|
viewName)
|
||||||
req = urllib2.Request(url, urlencode(qdict))
|
#xbmc.log("Standard URL %s"%url,level=xbmc.LOGDEBUG)
|
||||||
|
#xbmc.log("Qdict %s"%str(qdict),level=xbmc.LOGDEBUG)
|
||||||
if self._useGET:
|
req = urllib.request.Request(url, urlencode(qdict).encode('utf-8'))
|
||||||
|
if(self._useGET or ('getCoverArt' in viewName) or ('stream' in viewName)):
|
||||||
url += '?%s' % urlencode(qdict)
|
url += '?%s' % urlencode(qdict)
|
||||||
req = urllib2.Request(url)
|
#xbmc.log("UseGET URL %s"%(url),xbmc.LOGDEBUG)
|
||||||
|
req = urllib.request.Request(url)
|
||||||
return req
|
return req
|
||||||
|
|
||||||
def _getRequestWithList(self, viewName, listName, alist, query={}):
|
def _getRequestWithList(self, viewName, listName, alist, query={}):
|
||||||
|
@ -2633,7 +2841,7 @@ class Connection(object):
|
||||||
data.write(urlencode(qdict))
|
data.write(urlencode(qdict))
|
||||||
for i in alist:
|
for i in alist:
|
||||||
data.write('&%s' % urlencode({listName: i}))
|
data.write('&%s' % urlencode({listName: i}))
|
||||||
req = urllib2.Request(url, data.getvalue())
|
req = urllib.request.Request(url, data.getvalue().encode('utf-8'))
|
||||||
|
|
||||||
if self._useGET:
|
if self._useGET:
|
||||||
url += '?%s' % data.getvalue()
|
url += '?%s' % data.getvalue()
|
||||||
|
@ -2657,10 +2865,10 @@ class Connection(object):
|
||||||
viewName)
|
viewName)
|
||||||
data = StringIO()
|
data = StringIO()
|
||||||
data.write(urlencode(qdict))
|
data.write(urlencode(qdict))
|
||||||
for k, l in listMap.iteritems():
|
for k, l in listMap.items():
|
||||||
for i in l:
|
for i in l:
|
||||||
data.write('&%s' % urlencode({k: i}))
|
data.write('&%s' % urlencode({k: i}))
|
||||||
req = urllib2.Request(url, data.getvalue())
|
req = urllib.request.Request(url, data.getvalue().encode('utf-8'))
|
||||||
|
|
||||||
if self._useGET:
|
if self._useGET:
|
||||||
url += '?%s' % data.getvalue()
|
url += '?%s' % data.getvalue()
|
||||||
|
@ -2671,12 +2879,17 @@ class Connection(object):
|
||||||
def _doInfoReq(self, req):
|
def _doInfoReq(self, req):
|
||||||
# Returns a parsed dictionary version of the result
|
# Returns a parsed dictionary version of the result
|
||||||
res = self._opener.open(req)
|
res = self._opener.open(req)
|
||||||
dres = json.loads(res.read())
|
dres = json.loads(res.read().decode('utf-8'))
|
||||||
return dres['subsonic-response']
|
return dres['subsonic-response']
|
||||||
|
|
||||||
def _doBinReq(self, req):
|
def _doBinReq(self, req):
|
||||||
res = self._opener.open(req)
|
res = self._opener.open(req)
|
||||||
contType = res.info().getheader('Content-Type')
|
info = res.info()
|
||||||
|
if hasattr(info, 'getheader'):
|
||||||
|
contType = info.getheader('Content-Type')
|
||||||
|
else:
|
||||||
|
contType = info.get('Content-Type')
|
||||||
|
|
||||||
if contType:
|
if contType:
|
||||||
if contType.startswith('text/html') or \
|
if contType.startswith('text/html') or \
|
||||||
contType.startswith('application/json'):
|
contType.startswith('application/json'):
|
||||||
|
@ -2716,7 +2929,7 @@ class Connection(object):
|
||||||
"""
|
"""
|
||||||
separate REST portion of URL from base server path.
|
separate REST portion of URL from base server path.
|
||||||
"""
|
"""
|
||||||
return urllib2.splithost(self._serverPath)[1].split('/')[0]
|
return urllib.parse.splithost(self._serverPath)[1].split('/')[0]
|
||||||
|
|
||||||
def _fixLastModified(self, data):
|
def _fixLastModified(self, data):
|
||||||
"""
|
"""
|
||||||
|
@ -2726,9 +2939,9 @@ class Connection(object):
|
||||||
of SECONDS since the unix epoch. JAVA SUCKS!
|
of SECONDS since the unix epoch. JAVA SUCKS!
|
||||||
"""
|
"""
|
||||||
if isinstance(data, dict):
|
if isinstance(data, dict):
|
||||||
for k, v in data.items():
|
for k, v in list(data.items()):
|
||||||
if k == 'lastModified':
|
if k == 'lastModified':
|
||||||
data[k] = long(v) / 1000.0
|
data[k] = int(v) / 1000.0
|
||||||
return
|
return
|
||||||
elif isinstance(v, (tuple, list, dict)):
|
elif isinstance(v, (tuple, list, dict)):
|
||||||
return self._fixLastModified(v)
|
return self._fixLastModified(v)
|
||||||
|
|
|
@ -1,440 +0,0 @@
|
||||||
import urllib
|
|
||||||
import urlparse
|
|
||||||
import libsonic
|
|
||||||
|
|
||||||
def force_list(value):
|
|
||||||
"""
|
|
||||||
Coerce the input value to a list.
|
|
||||||
|
|
||||||
If `value` is `None`, return an empty list. If it is a single value, create
|
|
||||||
a new list with that element on index 0.
|
|
||||||
|
|
||||||
:param value: Input value to coerce.
|
|
||||||
:return: Value as list.
|
|
||||||
:rtype: list
|
|
||||||
"""
|
|
||||||
|
|
||||||
if value is None:
|
|
||||||
return []
|
|
||||||
elif type(value) == list:
|
|
||||||
return value
|
|
||||||
else:
|
|
||||||
return [value]
|
|
||||||
|
|
||||||
|
|
||||||
class SubsonicClient(libsonic.Connection):
|
|
||||||
"""
|
|
||||||
Extend `libsonic.Connection` with new features and fix a few issues.
|
|
||||||
|
|
||||||
- Parse URL for host and port for constructor.
|
|
||||||
- Make sure API results are of of uniform type.
|
|
||||||
- Provide methods to intercept URL of binary requests.
|
|
||||||
- Add order property to playlist items.
|
|
||||||
- Add conventient `walk_*' methods to iterate over the API responses.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, url, username, password, apiversion, insecure, legacyauth):
|
|
||||||
"""
|
|
||||||
Construct a new SubsonicClient.
|
|
||||||
|
|
||||||
:param str url: Full URL (including scheme) of the Subsonic server.
|
|
||||||
:param str username: Username of the server.
|
|
||||||
:param str password: Password of the server.
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.intercept_url = False
|
|
||||||
|
|
||||||
# Parse Subsonic URL
|
|
||||||
parts = urlparse.urlparse(url)
|
|
||||||
scheme = parts.scheme or "http"
|
|
||||||
|
|
||||||
# Make sure there is hostname
|
|
||||||
if not parts.hostname:
|
|
||||||
raise ValueError("Expected hostname for URL: %s" % url)
|
|
||||||
|
|
||||||
# Validate scheme
|
|
||||||
if scheme not in ("http", "https"):
|
|
||||||
raise ValueError("Unexpected scheme '%s' for URL: %s" % (
|
|
||||||
scheme, url))
|
|
||||||
|
|
||||||
# Pick a default port
|
|
||||||
host = "%s://%s" % (scheme, parts.hostname)
|
|
||||||
port = parts.port or {"http": 80, "https": 443}[scheme]
|
|
||||||
|
|
||||||
# Invoke original constructor
|
|
||||||
super(SubsonicClient, self).__init__(
|
|
||||||
host, username, password, port=port, appName='Kodi', apiVersion=apiversion, insecure=insecure, legacyAuth=legacyauth)
|
|
||||||
|
|
||||||
def getIndexes(self, *args, **kwargs):
|
|
||||||
"""
|
|
||||||
Improve the getIndexes method. Ensures IDs are integers.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _artists_iterator(artists):
|
|
||||||
for artist in force_list(artists):
|
|
||||||
artist["id"] = int(artist["id"])
|
|
||||||
yield artist
|
|
||||||
|
|
||||||
def _index_iterator(index):
|
|
||||||
for index in force_list(index):
|
|
||||||
index["artist"] = list(_artists_iterator(index.get("artist")))
|
|
||||||
yield index
|
|
||||||
|
|
||||||
def _children_iterator(children):
|
|
||||||
for child in force_list(children):
|
|
||||||
child["id"] = int(child["id"])
|
|
||||||
|
|
||||||
if "parent" in child:
|
|
||||||
child["parent"] = int(child["parent"])
|
|
||||||
if "coverArt" in child:
|
|
||||||
child["coverArt"] = int(child["coverArt"])
|
|
||||||
if "artistId" in child:
|
|
||||||
child["artistId"] = int(child["artistId"])
|
|
||||||
if "albumId" in child:
|
|
||||||
child["albumId"] = int(child["albumId"])
|
|
||||||
|
|
||||||
yield child
|
|
||||||
|
|
||||||
response = super(SubsonicClient, self).getIndexes(*args, **kwargs)
|
|
||||||
response["indexes"] = response.get("indexes", {})
|
|
||||||
response["indexes"]["index"] = list(
|
|
||||||
_index_iterator(response["indexes"].get("index")))
|
|
||||||
response["indexes"]["child"] = list(
|
|
||||||
_children_iterator(response["indexes"].get("child")))
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
def getPlaylists(self, *args, **kwargs):
|
|
||||||
"""
|
|
||||||
Improve the getPlaylists method. Ensures IDs are integers.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _playlists_iterator(playlists):
|
|
||||||
for playlist in force_list(playlists):
|
|
||||||
playlist["id"] = int(playlist["id"])
|
|
||||||
yield playlist
|
|
||||||
|
|
||||||
response = super(SubsonicClient, self).getPlaylists(*args, **kwargs)
|
|
||||||
response["playlists"]["playlist"] = list(
|
|
||||||
_playlists_iterator(response["playlists"].get("playlist")))
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
def getPlaylist(self, *args, **kwargs):
|
|
||||||
"""
|
|
||||||
Improve the getPlaylist method. Ensures IDs are integers and add an
|
|
||||||
order property to each entry.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _entries_iterator(entries):
|
|
||||||
for order, entry in enumerate(force_list(entries), start=1):
|
|
||||||
entry["id"] = int(entry["id"])
|
|
||||||
entry["order"] = order
|
|
||||||
yield entry
|
|
||||||
|
|
||||||
response = super(SubsonicClient, self).getPlaylist(*args, **kwargs)
|
|
||||||
response["playlist"]["entry"] = list(
|
|
||||||
_entries_iterator(response["playlist"].get("entry")))
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
def getArtists(self, *args, **kwargs):
|
|
||||||
"""
|
|
||||||
(ID3 tags)
|
|
||||||
Improve the getArtists method. Ensures IDs are integers.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _artists_iterator(artists):
|
|
||||||
for artist in force_list(artists):
|
|
||||||
artist["id"] = int(artist["id"])
|
|
||||||
yield artist
|
|
||||||
|
|
||||||
def _index_iterator(index):
|
|
||||||
for index in force_list(index):
|
|
||||||
index["artist"] = list(_artists_iterator(index.get("artist")))
|
|
||||||
yield index
|
|
||||||
|
|
||||||
response = super(SubsonicClient, self).getArtists(*args, **kwargs)
|
|
||||||
response["artists"] = response.get("artists", {})
|
|
||||||
response["artists"]["index"] = list(
|
|
||||||
_index_iterator(response["artists"].get("index")))
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
def getArtist(self, *args, **kwargs):
|
|
||||||
"""
|
|
||||||
(ID3 tags)
|
|
||||||
Improve the getArtist method. Ensures IDs are integers.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _albums_iterator(albums):
|
|
||||||
for album in force_list(albums):
|
|
||||||
album["id"] = int(album["id"])
|
|
||||||
|
|
||||||
if "artistId" in album:
|
|
||||||
album["artistId"] = int(album["artistId"])
|
|
||||||
|
|
||||||
yield album
|
|
||||||
|
|
||||||
response = super(SubsonicClient, self).getArtist(*args, **kwargs)
|
|
||||||
response["artist"]["album"] = list(
|
|
||||||
_albums_iterator(response["artist"].get("album")))
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
def getMusicDirectory(self, *args, **kwargs):
|
|
||||||
"""
|
|
||||||
Improve the getMusicDirectory method. Ensures IDs are integers.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _children_iterator(children):
|
|
||||||
for child in force_list(children):
|
|
||||||
child["id"] = int(child["id"])
|
|
||||||
|
|
||||||
if "parent" in child:
|
|
||||||
child["parent"] = int(child["parent"])
|
|
||||||
if "coverArt" in child:
|
|
||||||
child["coverArt"] = int(child["coverArt"])
|
|
||||||
if "artistId" in child:
|
|
||||||
child["artistId"] = int(child["artistId"])
|
|
||||||
if "albumId" in child:
|
|
||||||
child["albumId"] = int(child["albumId"])
|
|
||||||
|
|
||||||
yield child
|
|
||||||
|
|
||||||
response = super(SubsonicClient, self).getMusicDirectory(
|
|
||||||
*args, **kwargs)
|
|
||||||
response["directory"]["child"] = list(
|
|
||||||
_children_iterator(response["directory"].get("child")))
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
def getAlbum(self, *args, **kwargs):
|
|
||||||
"""
|
|
||||||
(ID3 tags)
|
|
||||||
Improve the getAlbum method. Ensures the IDs are real integers.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _songs_iterator(songs):
|
|
||||||
for song in force_list(songs):
|
|
||||||
song["id"] = int(song["id"])
|
|
||||||
yield song
|
|
||||||
|
|
||||||
response = super(SubsonicClient, self).getAlbum(*args, **kwargs)
|
|
||||||
response["album"]["song"] = list(
|
|
||||||
_songs_iterator(response["album"].get("song")))
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
def getAlbumList2(self, *args, **kwargs):
|
|
||||||
"""
|
|
||||||
Improve the getAlbumList2 method. Ensures the IDs are real integers.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _album_iterator(albums):
|
|
||||||
for album in force_list(albums):
|
|
||||||
album["id"] = int(album["id"])
|
|
||||||
yield album
|
|
||||||
|
|
||||||
response = super(SubsonicClient, self).getAlbumList2(*args, **kwargs)
|
|
||||||
response["albumList2"]["album"] = list(
|
|
||||||
_album_iterator(response["albumList2"].get("album")))
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
def getStarred(self, *args, **kwargs):
|
|
||||||
"""
|
|
||||||
Improve the getStarred method. Ensures the IDs are real integers.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _song_iterator(songs):
|
|
||||||
for song in force_list(songs):
|
|
||||||
song["id"] = int(song["id"])
|
|
||||||
yield song
|
|
||||||
|
|
||||||
response = super(SubsonicClient, self).getStarred(*args, **kwargs)
|
|
||||||
response["starred"]["song"] = list(
|
|
||||||
_song_iterator(response["starred"].get("song")))
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
def getCoverArtUrl(self, *args, **kwargs):
|
|
||||||
"""
|
|
||||||
Return an URL to the cover art.
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.intercept_url = True
|
|
||||||
url = self.getCoverArt(*args, **kwargs)
|
|
||||||
self.intercept_url = False
|
|
||||||
|
|
||||||
return url
|
|
||||||
|
|
||||||
def streamUrl(self, *args, **kwargs):
|
|
||||||
"""
|
|
||||||
Return an URL to the file to stream.
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.intercept_url = True
|
|
||||||
url = self.stream(*args, **kwargs)
|
|
||||||
self.intercept_url = False
|
|
||||||
|
|
||||||
return url
|
|
||||||
|
|
||||||
def _doBinReq(self, *args, **kwargs):
|
|
||||||
"""
|
|
||||||
Intercept request URL to provide the URL of the item that is requested.
|
|
||||||
|
|
||||||
If the URL is intercepted, the request is not executed. A username and
|
|
||||||
password is added to provide direct access to the stream.
|
|
||||||
"""
|
|
||||||
|
|
||||||
if self.intercept_url:
|
|
||||||
parts = list(urlparse.urlparse(
|
|
||||||
args[0].get_full_url() + "?" + args[0].data))
|
|
||||||
parts[4] = dict(urlparse.parse_qsl(parts[4]))
|
|
||||||
parts[4].update({"u": self.username, "p": self.password})
|
|
||||||
parts[4] = urllib.urlencode(parts[4])
|
|
||||||
|
|
||||||
return urlparse.urlunparse(parts)
|
|
||||||
else:
|
|
||||||
return super(SubsonicClient, self)._doBinReq(*args, **kwargs)
|
|
||||||
|
|
||||||
def walk_index(self, folder_id=None):
|
|
||||||
"""
|
|
||||||
Request Subsonic's index and iterate each item.
|
|
||||||
"""
|
|
||||||
|
|
||||||
response = self.getIndexes(folder_id)
|
|
||||||
|
|
||||||
for index in response["indexes"]["index"]:
|
|
||||||
for artist in index["artist"]:
|
|
||||||
yield artist
|
|
||||||
|
|
||||||
|
|
||||||
def walk_playlists(self):
|
|
||||||
"""
|
|
||||||
Request Subsonic's playlists and iterate over each item.
|
|
||||||
"""
|
|
||||||
|
|
||||||
response = self.getPlaylists()
|
|
||||||
|
|
||||||
for child in response["playlists"]["playlist"]:
|
|
||||||
yield child
|
|
||||||
|
|
||||||
def walk_playlist(self, playlist_id):
|
|
||||||
"""
|
|
||||||
Request Subsonic's playlist items and iterate over each item.
|
|
||||||
"""
|
|
||||||
|
|
||||||
response = self.getPlaylist(playlist_id)
|
|
||||||
|
|
||||||
for child in response["playlist"]["entry"]:
|
|
||||||
yield child
|
|
||||||
|
|
||||||
def walk_folders(self):
|
|
||||||
response = self.getMusicFolders()
|
|
||||||
|
|
||||||
for child in response["musicFolders"]["musicFolder"]:
|
|
||||||
yield child
|
|
||||||
|
|
||||||
def walk_directory(self, directory_id):
|
|
||||||
"""
|
|
||||||
Request a Subsonic music directory and iterate over each item.
|
|
||||||
"""
|
|
||||||
|
|
||||||
response = self.getMusicDirectory(directory_id)
|
|
||||||
|
|
||||||
for child in response["directory"]["child"]:
|
|
||||||
if child.get("isDir"):
|
|
||||||
for child in self.walk_directory(child["id"]):
|
|
||||||
yield child
|
|
||||||
else:
|
|
||||||
yield child
|
|
||||||
|
|
||||||
def walk_artist(self, artist_id):
|
|
||||||
"""
|
|
||||||
Request a Subsonic artist and iterate over each album.
|
|
||||||
"""
|
|
||||||
|
|
||||||
response = self.getArtist(artist_id)
|
|
||||||
|
|
||||||
for child in response["artist"]["album"]:
|
|
||||||
yield child
|
|
||||||
|
|
||||||
def walk_artists(self):
|
|
||||||
"""
|
|
||||||
(ID3 tags)
|
|
||||||
Request all artists and iterate over each item.
|
|
||||||
"""
|
|
||||||
|
|
||||||
response = self.getArtists()
|
|
||||||
|
|
||||||
for index in response["artists"]["index"]:
|
|
||||||
for artist in index["artist"]:
|
|
||||||
yield artist
|
|
||||||
|
|
||||||
def walk_genres(self):
|
|
||||||
"""
|
|
||||||
(ID3 tags)
|
|
||||||
Request all genres and iterate over each item.
|
|
||||||
"""
|
|
||||||
|
|
||||||
response = self.getGenres()
|
|
||||||
|
|
||||||
for genre in response["genres"]["genre"]:
|
|
||||||
yield genre
|
|
||||||
|
|
||||||
def walk_albums(self, ltype, size=None, fromYear=None,toYear=None, genre=None, offset=None):
|
|
||||||
"""
|
|
||||||
(ID3 tags)
|
|
||||||
Request all albums for a given genre and iterate over each album.
|
|
||||||
"""
|
|
||||||
|
|
||||||
if ltype == 'byGenre' and genre is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
if ltype == 'byYear' and (fromYear is None or toYear is None):
|
|
||||||
return
|
|
||||||
|
|
||||||
response = self.getAlbumList2(
|
|
||||||
ltype=ltype, size=size, fromYear=fromYear, toYear=toYear,genre=genre, offset=offset)
|
|
||||||
|
|
||||||
if not response["albumList2"]["album"]:
|
|
||||||
return
|
|
||||||
|
|
||||||
for album in response["albumList2"]["album"]:
|
|
||||||
yield album
|
|
||||||
|
|
||||||
|
|
||||||
def walk_album(self, album_id):
|
|
||||||
"""
|
|
||||||
(ID3 tags)
|
|
||||||
Request an album and iterate over each item.
|
|
||||||
"""
|
|
||||||
|
|
||||||
response = self.getAlbum(album_id)
|
|
||||||
|
|
||||||
for song in response["album"]["song"]:
|
|
||||||
yield song
|
|
||||||
|
|
||||||
def walk_tracks_random(self, size=None, genre=None, fromYear=None,toYear=None):
|
|
||||||
"""
|
|
||||||
Request random songs by genre and/or year and iterate over each song.
|
|
||||||
"""
|
|
||||||
|
|
||||||
response = self.getRandomSongs(
|
|
||||||
size=size, genre=genre, fromYear=fromYear, toYear=toYear)
|
|
||||||
|
|
||||||
for song in response["randomSongs"]["song"]:
|
|
||||||
yield song
|
|
||||||
|
|
||||||
|
|
||||||
def walk_tracks_starred(self):
|
|
||||||
"""
|
|
||||||
Request Subsonic's starred songs and iterate over each item.
|
|
||||||
"""
|
|
||||||
|
|
||||||
response = self.getStarred()
|
|
||||||
|
|
||||||
for song in response["starred"]["song"]:
|
|
||||||
yield song
|
|
|
@ -1,4 +1,4 @@
|
||||||
#v2.1.0
|
#v2.1.0
|
||||||
#https://github.com/romanvm/script.module.simpleplugin/releases
|
#https://github.com/romanvm/script.module.simpleplugin/releases
|
||||||
|
|
||||||
from simpleplugin import *
|
from .simpleplugin import *
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -77,7 +77,7 @@ msgid "Cache (in minutes)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#30018"
|
msgctxt "#30018"
|
||||||
msgid "Cache datas time"
|
msgid "Cache data time"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#30019"
|
msgctxt "#30019"
|
||||||
|
@ -152,3 +152,31 @@ msgstr ""
|
||||||
msgctxt "#30038"
|
msgctxt "#30038"
|
||||||
msgid "Browse"
|
msgid "Browse"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30039"
|
||||||
|
msgid "Search Songs"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30040"
|
||||||
|
msgid "useGET"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30041"
|
||||||
|
msgid "legacyauth"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30042"
|
||||||
|
msgid "port"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30043"
|
||||||
|
msgid "Merge album folders"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30044"
|
||||||
|
msgid "Scrobble to Last.FM"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30045"
|
||||||
|
msgid "Search Albums"
|
||||||
|
msgstr ""
|
||||||
|
|
|
@ -151,3 +151,32 @@ msgstr "Pistes au hasard"
|
||||||
msgctxt "#30038"
|
msgctxt "#30038"
|
||||||
msgid "Browse"
|
msgid "Browse"
|
||||||
msgstr "Parcourir"
|
msgstr "Parcourir"
|
||||||
|
|
||||||
|
msgctxt "#30039"
|
||||||
|
msgid "Search Songs"
|
||||||
|
msgstr "Rechercher Chansons"
|
||||||
|
|
||||||
|
|
||||||
|
msgctxt "#30040"
|
||||||
|
msgid "useGET"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30041"
|
||||||
|
msgid "legacyauth"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30042"
|
||||||
|
msgid "port"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30043"
|
||||||
|
msgid "Merge album folders"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30044"
|
||||||
|
msgid "Scrobble to Last.FM"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30045"
|
||||||
|
msgid "Search Albums"
|
||||||
|
msgstr "Rechercher Albums"
|
||||||
|
|
|
@ -151,3 +151,31 @@ msgstr "Zufällig lieder"
|
||||||
msgctxt "#30038"
|
msgctxt "#30038"
|
||||||
msgid "Browse"
|
msgid "Browse"
|
||||||
msgstr "Durchsuchen"
|
msgstr "Durchsuchen"
|
||||||
|
|
||||||
|
msgctxt "#30039"
|
||||||
|
msgid "Search Songs"
|
||||||
|
msgstr "Suche Lieder"
|
||||||
|
|
||||||
|
msgctxt "#30040"
|
||||||
|
msgid "useGET"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30041"
|
||||||
|
msgid "legacyauth"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30042"
|
||||||
|
msgid "port"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30043"
|
||||||
|
msgid "Merge album folders"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30044"
|
||||||
|
msgid "Scrobble to Last.FM"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30045"
|
||||||
|
msgid "Search Albums"
|
||||||
|
msgstr "Suche Albums"
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<category label="30000">
|
<category label="30000">
|
||||||
<setting label="30001" type="lsep" />
|
<setting label="30001" type="lsep" />
|
||||||
<setting label="30002" id="subsonic_url" type="text" default="http://demo.subsonic.org"/>
|
<setting label="30002" id="subsonic_url" type="text" default="http://demo.subsonic.org"/>
|
||||||
|
<setting label="30042" id="port" type="text" default="80"/>
|
||||||
<setting label="30003" id="username" type="text" default="guest3"/>
|
<setting label="30003" id="username" type="text" default="guest3"/>
|
||||||
<setting label="30004" id="password" type="text" option="hidden" default="guest"/>
|
<setting label="30004" id="password" type="text" option="hidden" default="guest"/>
|
||||||
<setting label="30005" type="lsep" />
|
<setting label="30005" type="lsep" />
|
||||||
|
@ -13,16 +14,20 @@
|
||||||
<setting label="30009" id="download_folder" type="folder" source="auto" option="writeable"/>
|
<setting label="30009" id="download_folder" type="folder" source="auto" option="writeable"/>
|
||||||
<setting label="30010" type="lsep" />
|
<setting label="30010" type="lsep" />
|
||||||
<setting label="30011" id="transcode_format_streaming" type="labelenum" values="mp3|raw|flv|ogg"/>
|
<setting label="30011" id="transcode_format_streaming" type="labelenum" values="mp3|raw|flv|ogg"/>
|
||||||
<setting label="30012" id="bitrate_streaming" type="labelenum" values="320|256|224|192|160|128|112|96|80|64|56|48|40|32"/>
|
<setting label="30012" id="bitrate_streaming" type="labelenum" default="0" values="320|256|224|192|160|128|112|96|80|64|56|48|40|32|0"/>
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
<!-- ADVANCED -->
|
<!-- ADVANCED -->
|
||||||
<category label="30013">
|
<category label="30013">
|
||||||
<setting label="30001" type="lsep" />
|
<setting label="30001" type="lsep" />
|
||||||
<setting label="30014" id="apiversion" type="labelenum" values="1.11.0|1.12.0|1.13.0|1.14.0" default="1.13.0"/>
|
<setting label="30014" id="apiversion" type="labelenum" values="1.11.0|1.12.0|1.13.0|1.14.0|1.15.0|1.16.0" default="1.15.0"/>
|
||||||
<setting label="30016" id="insecure" type="bool" default="false" />
|
<setting label="30016" id="insecure" type="bool" default="false" />
|
||||||
|
<setting label="30040" id="useget" type="bool" default="true" />
|
||||||
|
<setting label="30041" id="legacyauth" type="bool" default="false" />
|
||||||
<setting label="30017" type="lsep" />
|
<setting label="30017" type="lsep" />
|
||||||
<setting label="30018" id="cachetime" type="labelenum" default="15" values="1|5|15|30|60|120|180|720|1440"/>
|
<setting label="30018" id="cachetime" type="labelenum" default="3600" values="1|5|15|30|60|120|180|720|1440|3600"/>
|
||||||
|
<setting label="30043" id="merge" type="bool" default="false" />
|
||||||
|
<setting label="30044" id="scrobble" type="bool" default="false" />
|
||||||
|
|
||||||
</category>
|
</category>
|
||||||
</settings>
|
</settings>
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
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__':
|
||||||
|
if(scrobbleEnabled):
|
||||||
|
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:
|
||||||
|
|
||||||
|
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)
|
||||||
|
else:
|
||||||
|
xbmc.log("Subsonic service not started due to settings", xbmc.LOGINFO)
|
Loading…
Reference in New Issue