Verified Commit fe03d08a authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Removed unused acoustid dependency / logic

parent 14392ebb
......@@ -391,7 +391,7 @@ This is regular pytest, so you can use any arguments/options that pytest usually
# Stop on first failure
docker-compose -f dev.yml run --rm api pytest -x
# Run a specific test file
docker-compose -f dev.yml run --rm api pytest tests/test_acoustid.py
docker-compose -f dev.yml run --rm api pytest tests/music/test_models.py
Writing tests
^^^^^^^^^^^^^
......
......@@ -10,7 +10,7 @@ RUN apt-get update; \
grep -Fv "python3-dev" | \
xargs apt-get install -y --no-install-recommends; \
rm -rf /usr/share/doc/* /usr/share/locale/*
RUN curl -L https://github.com/acoustid/chromaprint/releases/download/v1.4.2/chromaprint-fpcalc-1.4.2-linux-x86_64.tar.gz | tar -xz -C /usr/local/bin --strip 1
COPY ./requirements/base.txt /requirements/base.txt
RUN pip install -r /requirements/base.txt
COPY ./requirements/production.txt /requirements/production.txt
......
......@@ -160,7 +160,6 @@ LOCAL_APPS = (
"funkwhale_api.radios",
"funkwhale_api.history",
"funkwhale_api.playlists",
"funkwhale_api.providers.acoustid",
"funkwhale_api.subsonic",
)
......
......@@ -11,8 +11,6 @@ RUN apt-get update; \
xargs apt-get install -y --no-install-recommends; \
rm -rf /usr/share/doc/* /usr/share/locale/*
RUN curl -L https://github.com/acoustid/chromaprint/releases/download/v1.4.2/chromaprint-fpcalc-1.4.2-linux-x86_64.tar.gz | tar -xz -C /usr/local/bin --strip 1
RUN mkdir /requirements
COPY ./requirements/base.txt /requirements/base.txt
RUN pip install -r /requirements/base.txt
......
import acoustid
from dynamic_preferences.registries import global_preferences_registry
class Client(object):
def __init__(self, api_key):
self.api_key = api_key
def match(self, file_path):
return acoustid.match(self.api_key, file_path, parse=False)
def get_best_match(self, file_path):
results = self.match(file_path=file_path)
MIN_SCORE_FOR_MATCH = 0.8
try:
rows = results["results"]
except KeyError:
return
for row in rows:
if row["score"] >= MIN_SCORE_FOR_MATCH:
return row
def get_acoustid_client():
manager = global_preferences_registry.manager()
return Client(api_key=manager["providers_acoustid__api_key"])
from django import forms
from dynamic_preferences.registries import global_preferences_registry
from dynamic_preferences.types import Section, StringPreference
acoustid = Section("providers_acoustid")
@global_preferences_registry.register
class APIKey(StringPreference):
section = acoustid
name = "api_key"
default = ""
verbose_name = "Acoustid API key"
help_text = "The API key used to query AcoustID. Get one at https://acoustid.org/new-application."
widget = forms.PasswordInput
field_kwargs = {"required": False}
......@@ -50,7 +50,6 @@ django-taggit>=0.22,<0.23
pymemoize==1.0.3
django-dynamic-preferences>=1.7,<1.8
pyacoustid>=1.1.5,<1.2
raven>=6.5,<7
python-magic==0.4.15
ffmpeg-python==0.1.10
......
from funkwhale_api.providers.acoustid import get_acoustid_client
def test_client_is_configured_with_correct_api_key(preferences):
api_key = "hello world"
preferences["providers_acoustid__api_key"] = api_key
client = get_acoustid_client()
assert client.api_key == api_key
def test_client_returns_raw_results(db, mocker, preferences):
api_key = "test"
preferences["providers_acoustid__api_key"] = api_key
payload = {
"results": [
{
"id": "e475bf79-c1ce-4441-bed7-1e33f226c0a2",
"recordings": [
{
"artists": [
{
"id": "9c6bddde-6228-4d9f-ad0d-03f6fcb19e13",
"name": "Binärpilot",
}
],
"duration": 268,
"id": "f269d497-1cc0-4ae4-a0c4-157ec7d73fcb",
"title": "Bend",
}
],
"score": 0.860825,
}
],
"status": "ok",
}
m = mocker.patch("acoustid.match", return_value=payload)
client = get_acoustid_client()
response = client.match("/tmp/noopfile.mp3")
assert response == payload
m.assert_called_once_with("test", "/tmp/noopfile.mp3", parse=False)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment