mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06: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 zipstream import ZipStream
|
||||||
|
|
||||||
from ..cache import CacheMiss
|
from ..cache import CacheMiss
|
||||||
from ..db import Track, Album, Folder, now
|
from ..db import Track, Album, Artist, Folder, now
|
||||||
from ..covers import EXTENSIONS
|
from ..covers import EXTENSIONS
|
||||||
|
|
||||||
from . import get_entity, get_entity_id, api_routing
|
from . import get_entity, get_entity_id, api_routing
|
||||||
@ -413,7 +413,11 @@ def lyrics():
|
|||||||
artist = request.values["artist"]
|
artist = request.values["artist"]
|
||||||
title = request.values["title"]
|
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:
|
for track in query:
|
||||||
# Read from track metadata
|
# Read from track metadata
|
||||||
lyrics = mediafile.MediaFile(track.path).lyrics
|
lyrics = mediafile.MediaFile(track.path).lyrics
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# This file is part of Supysonic.
|
# This file is part of Supysonic.
|
||||||
# Supysonic is a Python implementation of the Subsonic server API.
|
# 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.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
@ -10,8 +10,6 @@ import os.path
|
|||||||
import requests
|
import requests
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from pony.orm import db_session
|
|
||||||
|
|
||||||
from supysonic.db import Folder, Artist, Album, Track
|
from supysonic.db import Folder, Artist, Album, Track
|
||||||
|
|
||||||
from ..api.apitestbase import ApiTestBase
|
from ..api.apitestbase import ApiTestBase
|
||||||
@ -21,17 +19,16 @@ class LyricsTestCase(ApiTestBase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
with db_session:
|
folder = Folder.create(
|
||||||
folder = Folder(
|
|
||||||
name="Root",
|
name="Root",
|
||||||
path=os.path.abspath("tests/assets/lyrics"),
|
path=os.path.abspath("tests/assets/lyrics"),
|
||||||
root=True,
|
root=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
artist = Artist(name="Artist")
|
artist = Artist.create(name="Artist")
|
||||||
album = Album(artist=artist, name="Album")
|
album = Album.create(artist=artist, name="Album")
|
||||||
|
|
||||||
Track(
|
Track.create(
|
||||||
title="Nope",
|
title="Nope",
|
||||||
number=1,
|
number=1,
|
||||||
disc=1,
|
disc=1,
|
||||||
@ -44,7 +41,7 @@ class LyricsTestCase(ApiTestBase):
|
|||||||
bitrate=320,
|
bitrate=320,
|
||||||
last_modification=0,
|
last_modification=0,
|
||||||
)
|
)
|
||||||
Track(
|
Track.create(
|
||||||
title="Yay",
|
title="Yay",
|
||||||
number=1,
|
number=1,
|
||||||
disc=1,
|
disc=1,
|
||||||
|
Loading…
Reference in New Issue
Block a user