9 Commits

Author SHA1 Message Date
4fffcd143e Merge pull request #47 from GioF71/feature/search-album
[Feature] Search Album
2023-02-03 08:25:49 +11:00
e59b65d5e0 [Feature] Search Album 2023-02-02 19:43:09 +01:00
fa0c4ec165 Update repo link 2022-09-18 18:39:33 +10:00
2c785729ee Merge pull request #43 from BlackIkeEagle/collections-abc-import
also use collections.abc in simpleplugin to import MutableMapping
2022-03-05 16:12:22 +11:00
d11505bd04 also use collections.abc in simpleplugin to import MutableMapping
Signed-off-by: BlackEagle <ike.devolder@gmail.com>
2022-03-03 22:40:02 +01:00
d221fa4f39 Resolved incorrect repo link 2022-01-30 16:25:47 +11:00
ec86d2abdd Modify separator for verifypeer 2022-01-28 11:09:11 +11:00
b9a556eded Handle subfolder in server setting 2021-10-11 12:50:10 +11:00
4e15a1d0d3 Update addon.xml for v3.0.2 2021-09-28 16:06:38 +10:00
8 changed files with 93 additions and 31 deletions

View File

@ -20,7 +20,7 @@ Leia compatible version available in alternate branch
## Installation ## Installation
From repository 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) [repository.warwickh](https://github.com/warwickh/repository.warwickh/raw/master/matrix/zips/repository.warwickh) (Please report any issues)
From GitHub From GitHub
* Click the code button and download * Click the code button and download

View File

@ -1,5 +1,5 @@
<?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="3.0.1" provider-name="BasilFX,warwickh"> <addon id="plugin.audio.subsonic" name="Subsonic" version="3.0.2" provider-name="BasilFX,warwickh">
<requires> <requires>
<import addon="xbmc.python" version="3.0.0"/> <import addon="xbmc.python" version="3.0.0"/>
</requires> </requires>

View File

@ -20,6 +20,7 @@ from netrc import netrc
from hashlib import md5 from hashlib import md5
import urllib.request import urllib.request
import urllib.error import urllib.error
import urllib.parse
from http import client as http_client from http import client as http_client
from urllib.parse import urlencode from urllib.parse import urlencode
from io import StringIO from io import StringIO
@ -154,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
@ -172,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)
@ -899,7 +909,7 @@ class Connection(object):
#xbmc.log("Requesting %s"%str(req.full_url),xbmc.LOGDEBUG) #xbmc.log("Requesting %s"%str(req.full_url),xbmc.LOGDEBUG)
return_url = req.full_url return_url = req.full_url
if self._insecure: if self._insecure:
return_url += '|verifypeer=false' return_url += '&verifypeer=false'
xbmc.log("Request is insecure %s"%return_url,level=xbmc.LOGDEBUG) xbmc.log("Request is insecure %s"%return_url,level=xbmc.LOGDEBUG)
return return_url return return_url
@ -948,7 +958,7 @@ class Connection(object):
#xbmc.log("Requesting %s"%str(req.full_url),xbmc.LOGDEBUG) #xbmc.log("Requesting %s"%str(req.full_url),xbmc.LOGDEBUG)
return_url = req.full_url return_url = req.full_url
if self._insecure: if self._insecure:
return_url += '|verifypeer=false' return_url += '&verifypeer=false'
xbmc.log("Request is insecure %s"%return_url,level=xbmc.LOGDEBUG) xbmc.log("Request is insecure %s"%return_url,level=xbmc.LOGDEBUG)
return return_url return return_url

View File

@ -19,7 +19,8 @@ import inspect
import time import time
import hashlib import hashlib
import pickle import pickle
from collections import MutableMapping, namedtuple from collections.abc import MutableMapping
from collections import namedtuple
from copy import deepcopy from copy import deepcopy
from functools import wraps from functools import wraps
from shutil import copyfile from shutil import copyfile
@ -58,7 +59,7 @@ def _format_vars(variables):
:return: formatted string with sorted ``var = val`` pairs :return: formatted string with sorted ``var = val`` pairs
:rtype: str :rtype: str
""" """
var_list = [(var, val) for var, val in iteritems(variables)] var_list = [(var, val) for var, val in iter(variables.items())]
lines = [] lines = []
for var, val in sorted(var_list, key=lambda i: i[0]): for var, val in sorted(var_list, key=lambda i: i[0]):
if not (var.startswith('__') or var.endswith('__')): if not (var.startswith('__') or var.endswith('__')):

55
main.py
View File

@ -107,6 +107,11 @@ def root(params):
'callback': 'search', 'callback': 'search',
'thumb': None 'thumb': None
}, },
'searchalbum': {
'name': Addon().get_localized_string(30045),
'callback': 'search_album',
'thumb': None
},
} }
# Iterate through categories # Iterate through categories
@ -578,27 +583,61 @@ def search(params):
dialog = xbmcgui.Dialog() dialog = xbmcgui.Dialog()
d = dialog.input(Addon().get_localized_string(30039), type=xbmcgui.INPUT_ALPHANUM) d = dialog.input(Addon().get_localized_string(30039), type=xbmcgui.INPUT_ALPHANUM)
if not d:
d = " "
listing = []
if d:
# get connection # get connection
connection = get_connection() connection = get_connection()
if connection==False: if connection == False:
return return
listing = []
# Get items # Get items
items = connection.search2(query=d) items = connection.search2(query=d)
# Iterate through items # Iterate through items
for item in items.get('searchResult2').get('song'): songs = items.get('searchResult2').get('song')
if songs:
for item in songs:
entry = get_entry_track( item, params) entry = get_entry_track( item, params)
listing.append(entry) listing.append(entry)
if len(listing) == 1: if len(listing) == 0:
plugin.log('One single Media Folder found; do return listing from browse_indexes()...') plugin.log('No songs found; do return listing from browse_indexes()...')
return browse_indexes(params)
else:
add_directory_items(create_listing(listing))
@plugin.action()
def search_album(params):
dialog = xbmcgui.Dialog()
d = dialog.input(Addon().get_localized_string(30045), type=xbmcgui.INPUT_ALPHANUM)
listing = []
if d:
# get connection
connection = get_connection()
if connection==False:
return
# Get items, we are only looking for albums here
# so artistCount and songCount is set to 0
items = connection.search2(query=d, artistCount=0, songCount=0)
# Iterate through items
album_list = items.get('searchResult2').get('album')
if album_list:
for item in items.get('searchResult2').get('album'):
entry = get_entry_album( item, params)
listing.append(entry)
# I believe it is ok to return an empty listing if
# the search gave no result
# maybe inform the user?
if len(listing) == 0:
plugin.log('No albums found; do return listing from browse_indexes()...')
return browse_indexes(params) return browse_indexes(params)
else: else:
add_directory_items(create_listing(listing)) add_directory_items(create_listing(listing))

View File

@ -154,7 +154,7 @@ msgid "Browse"
msgstr "" msgstr ""
msgctxt "#30039" msgctxt "#30039"
msgid "Search" msgid "Search Songs"
msgstr "" msgstr ""
msgctxt "#30040" msgctxt "#30040"
@ -176,3 +176,7 @@ msgstr ""
msgctxt "#30044" msgctxt "#30044"
msgid "Scrobble to Last.FM" msgid "Scrobble to Last.FM"
msgstr "" msgstr ""
msgctxt "#30045"
msgid "Search Albums"
msgstr ""

View File

@ -153,8 +153,8 @@ msgid "Browse"
msgstr "Parcourir" msgstr "Parcourir"
msgctxt "#30039" msgctxt "#30039"
msgid "Search" msgid "Search Songs"
msgstr "Rechercher" msgstr "Rechercher Chansons"
msgctxt "#30040" msgctxt "#30040"
@ -176,3 +176,7 @@ msgstr ""
msgctxt "#30044" msgctxt "#30044"
msgid "Scrobble to Last.FM" msgid "Scrobble to Last.FM"
msgstr "" msgstr ""
msgctxt "#30045"
msgid "Search Albums"
msgstr "Rechercher Albums"

View File

@ -153,8 +153,8 @@ msgid "Browse"
msgstr "Durchsuchen" msgstr "Durchsuchen"
msgctxt "#30039" msgctxt "#30039"
msgid "Search" msgid "Search Songs"
msgstr "Suche" msgstr "Suche Lieder"
msgctxt "#30040" msgctxt "#30040"
msgid "useGET" msgid "useGET"
@ -175,3 +175,7 @@ msgstr ""
msgctxt "#30044" msgctxt "#30044"
msgid "Scrobble to Last.FM" msgid "Scrobble to Last.FM"
msgstr "" msgstr ""
msgctxt "#30045"
msgid "Search Albums"
msgstr "Suche Albums"