mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-23 01:16:18 +00:00
parent
69c43b749b
commit
3b6186ebfc
@ -96,7 +96,7 @@ def show_directory():
|
|||||||
@api.route('/getGenres.view', methods = [ 'GET', 'POST' ])
|
@api.route('/getGenres.view', methods = [ 'GET', 'POST' ])
|
||||||
def list_genres():
|
def list_genres():
|
||||||
return request.formatter('genres', dict(
|
return request.formatter('genres', dict(
|
||||||
genre = [ dict(_value_ = genre) for genre in select(t.genre for t in Track if t.genre) ]
|
genre = [ dict(value = genre) for genre in select(t.genre for t in Track if t.genre) ]
|
||||||
))
|
))
|
||||||
|
|
||||||
@api.route('/getArtists.view', methods = [ 'GET', 'POST' ])
|
@api.route('/getArtists.view', methods = [ 'GET', 'POST' ])
|
||||||
|
@ -99,7 +99,7 @@ class XMLFormatter(BaseFormatter):
|
|||||||
raise TypeError('Dictionary keys must be strings')
|
raise TypeError('Dictionary keys must be strings')
|
||||||
|
|
||||||
for name, value in dictionary.items():
|
for name, value in dictionary.items():
|
||||||
if name == '_value_':
|
if name == 'value':
|
||||||
elem.text = self.__value_tostring(value)
|
elem.text = self.__value_tostring(value)
|
||||||
elif isinstance(value, dict):
|
elif isinstance(value, dict):
|
||||||
subelem = ElementTree.SubElement(elem, name)
|
subelem = ElementTree.SubElement(elem, name)
|
||||||
|
@ -224,7 +224,7 @@ def lyrics():
|
|||||||
return request.formatter('lyrics', dict(
|
return request.formatter('lyrics', dict(
|
||||||
artist = track.album.artist.name,
|
artist = track.album.artist.name,
|
||||||
title = track.title,
|
title = track.title,
|
||||||
_value_ = lyrics
|
value = lyrics
|
||||||
))
|
))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -236,7 +236,7 @@ def lyrics():
|
|||||||
return request.formatter('lyrics', dict(
|
return request.formatter('lyrics', dict(
|
||||||
artist = root.find('cl:LyricArtist', namespaces = ns).text,
|
artist = root.find('cl:LyricArtist', namespaces = ns).text,
|
||||||
title = root.find('cl:LyricSong', namespaces = ns).text,
|
title = root.find('cl:LyricSong', namespaces = ns).text,
|
||||||
_value_ = root.find('cl:Lyric', namespaces = ns).text
|
value = root.find('cl:Lyric', namespaces = ns).text
|
||||||
))
|
))
|
||||||
except requests.exceptions.RequestException as e: # pragma: nocover
|
except requests.exceptions.RequestException as e: # pragma: nocover
|
||||||
logger.warning('Error while requesting the ChartLyrics API: ' + str(e))
|
logger.warning('Error while requesting the ChartLyrics API: ' + str(e))
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#
|
#
|
||||||
# Distributed under terms of the GNU AGPLv3 license.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
|
import flask.json
|
||||||
import os.path
|
import os.path
|
||||||
import requests
|
import requests
|
||||||
import uuid
|
import uuid
|
||||||
@ -171,6 +172,12 @@ class MediaTestCase(ApiTestBase):
|
|||||||
# ChartLyrics
|
# ChartLyrics
|
||||||
rv, child = self._make_request('getLyrics', { 'artist': 'The Clash', 'title': 'London Calling' }, tag = 'lyrics')
|
rv, child = self._make_request('getLyrics', { 'artist': 'The Clash', 'title': 'London Calling' }, tag = 'lyrics')
|
||||||
self.assertIn('live by the river', child.text)
|
self.assertIn('live by the river', child.text)
|
||||||
|
# ChartLyrics, JSON format
|
||||||
|
args = { 'u': 'alice', 'p': 'Alic3', 'c': 'tests', 'f': 'json', 'artist': 'The Clash', 'title': 'London Calling' }
|
||||||
|
rv = self.client.get('/rest/getLyrics.view', query_string = args)
|
||||||
|
json = flask.json.loads(rv.data)
|
||||||
|
self.assertIn('value', json['subsonic-response']['lyrics'])
|
||||||
|
self.assertIn('live by the river', json['subsonic-response']['lyrics']['value'])
|
||||||
|
|
||||||
# Local file
|
# Local file
|
||||||
rv, child = self._make_request('getLyrics', { 'artist': 'artist', 'title': '23bytes' }, tag = 'lyrics')
|
rv, child = self._make_request('getLyrics', { 'artist': 'artist', 'title': '23bytes' }, tag = 'lyrics')
|
||||||
|
@ -192,7 +192,7 @@ class ResponseHelperXMLTestCase(TestBase, UnwrapperMixin.create_from(XMLFormatte
|
|||||||
def test_nesting(self):
|
def test_nesting(self):
|
||||||
resp = self.process_and_extract({
|
resp = self.process_and_extract({
|
||||||
'dict': {
|
'dict': {
|
||||||
'value': 'hey look! a string',
|
'somevalue': 'hey look! a string',
|
||||||
'list': [ 1, 2, 3 ],
|
'list': [ 1, 2, 3 ],
|
||||||
'emptyList': [],
|
'emptyList': [],
|
||||||
'subdict': { 'a': 'A' }
|
'subdict': { 'a': 'A' }
|
||||||
@ -210,7 +210,7 @@ class ResponseHelperXMLTestCase(TestBase, UnwrapperMixin.create_from(XMLFormatte
|
|||||||
lists = resp.findall('./list')
|
lists = resp.findall('./list')
|
||||||
|
|
||||||
self.assertIsNotNone(d)
|
self.assertIsNotNone(d)
|
||||||
self.assertAttributesMatchDict(d, { 'value': 'hey look! a string' })
|
self.assertAttributesMatchDict(d, { 'somevalue': 'hey look! a string' })
|
||||||
self.assertEqual(len(d.findall('./list')), 3)
|
self.assertEqual(len(d.findall('./list')), 3)
|
||||||
self.assertEqual(len(d.findall('./emptyList')), 0)
|
self.assertEqual(len(d.findall('./emptyList')), 0)
|
||||||
self.assertIsNotNone(d.find('./subdict'))
|
self.assertIsNotNone(d.find('./subdict'))
|
||||||
|
Loading…
Reference in New Issue
Block a user