mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 08:56:17 +00:00
Fix requesting lyrics
This commit is contained in:
parent
e510f9622a
commit
ee8165bb03
@ -24,7 +24,7 @@ from xml.etree import ElementTree
|
||||
from zipstream import ZipStream
|
||||
|
||||
from ..cache import CacheMiss
|
||||
from ..db import Track, Album, Folder, now
|
||||
from ..db import Track, Album, Artist, Folder, now
|
||||
from ..covers import EXTENSIONS
|
||||
|
||||
from . import get_entity, get_entity_id, api_routing
|
||||
@ -413,7 +413,11 @@ def lyrics():
|
||||
artist = request.values["artist"]
|
||||
title = request.values["title"]
|
||||
|
||||
query = Track.select(lambda t: title in t.title and artist in t.artist.name)
|
||||
query = (
|
||||
Track.select()
|
||||
.join(Artist)
|
||||
.where(Track.title.contains(title), Artist.name.contains(artist))
|
||||
)
|
||||
for track in query:
|
||||
# Read from track metadata
|
||||
lyrics = mediafile.MediaFile(track.path).lyrics
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file is part of Supysonic.
|
||||
# Supysonic is a Python implementation of the Subsonic server API.
|
||||
#
|
||||
# Copyright (C) 2017 Alban 'spl0k' Féron
|
||||
# Copyright (C) 2017-2022 Alban 'spl0k' Féron
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
@ -10,8 +10,6 @@ import os.path
|
||||
import requests
|
||||
import unittest
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import Folder, Artist, Album, Track
|
||||
|
||||
from ..api.apitestbase import ApiTestBase
|
||||
@ -21,42 +19,41 @@ class LyricsTestCase(ApiTestBase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
with db_session:
|
||||
folder = Folder(
|
||||
name="Root",
|
||||
path=os.path.abspath("tests/assets/lyrics"),
|
||||
root=True,
|
||||
)
|
||||
folder = Folder.create(
|
||||
name="Root",
|
||||
path=os.path.abspath("tests/assets/lyrics"),
|
||||
root=True,
|
||||
)
|
||||
|
||||
artist = Artist(name="Artist")
|
||||
album = Album(artist=artist, name="Album")
|
||||
artist = Artist.create(name="Artist")
|
||||
album = Album.create(artist=artist, name="Album")
|
||||
|
||||
Track(
|
||||
title="Nope",
|
||||
number=1,
|
||||
disc=1,
|
||||
artist=artist,
|
||||
album=album,
|
||||
path=os.path.abspath("tests/assets/lyrics/empty.mp3"),
|
||||
root_folder=folder,
|
||||
folder=folder,
|
||||
duration=2,
|
||||
bitrate=320,
|
||||
last_modification=0,
|
||||
)
|
||||
Track(
|
||||
title="Yay",
|
||||
number=1,
|
||||
disc=1,
|
||||
artist=artist,
|
||||
album=album,
|
||||
path=os.path.abspath("tests/assets/lyrics/withlyrics.mp3"),
|
||||
root_folder=folder,
|
||||
folder=folder,
|
||||
duration=2,
|
||||
bitrate=320,
|
||||
last_modification=0,
|
||||
)
|
||||
Track.create(
|
||||
title="Nope",
|
||||
number=1,
|
||||
disc=1,
|
||||
artist=artist,
|
||||
album=album,
|
||||
path=os.path.abspath("tests/assets/lyrics/empty.mp3"),
|
||||
root_folder=folder,
|
||||
folder=folder,
|
||||
duration=2,
|
||||
bitrate=320,
|
||||
last_modification=0,
|
||||
)
|
||||
Track.create(
|
||||
title="Yay",
|
||||
number=1,
|
||||
disc=1,
|
||||
artist=artist,
|
||||
album=album,
|
||||
path=os.path.abspath("tests/assets/lyrics/withlyrics.mp3"),
|
||||
root_folder=folder,
|
||||
folder=folder,
|
||||
duration=2,
|
||||
bitrate=320,
|
||||
last_modification=0,
|
||||
)
|
||||
|
||||
def test_get_lyrics(self):
|
||||
self._make_request("getLyrics", error=10)
|
||||
|
Loading…
Reference in New Issue
Block a user