lint
Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2658>
This commit is contained in:
parent
6414302899
commit
17c4a92f77
|
@ -4,13 +4,6 @@ from django.utils import timezone
|
||||||
import funkwhale_api
|
import funkwhale_api
|
||||||
import pylistenbrainz
|
import pylistenbrainz
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
from config import plugins
|
|
||||||
from django.utils import timezone
|
|
||||||
|
|
||||||
from . import tasks
|
|
||||||
>>>>>>> bf0c861a0 (implement listening and favorite sync with listenbrainz)
|
|
||||||
from .funkwhale_startup import PLUGIN
|
from .funkwhale_startup import PLUGIN
|
||||||
|
|
||||||
from funkwhale_api.history import models as history_models
|
from funkwhale_api.history import models as history_models
|
||||||
|
@ -25,17 +18,10 @@ def submit_listen(listening, conf, **kwargs):
|
||||||
|
|
||||||
logger = PLUGIN["logger"]
|
logger = PLUGIN["logger"]
|
||||||
logger.info("Submitting listen to ListenBrainz")
|
logger.info("Submitting listen to ListenBrainz")
|
||||||
<<<<<<< HEAD
|
|
||||||
client = liblistenbrainz.ListenBrainz()
|
client = liblistenbrainz.ListenBrainz()
|
||||||
client.set_auth_token(user_token)
|
client.set_auth_token(user_token)
|
||||||
listen = get_listen(listening.track)
|
listen = get_listen(listening.track)
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
listen = get_listen(listening.track)
|
|
||||||
client = pylistenbrainz.ListenBrainz()
|
|
||||||
client.set_auth_token(user_token)
|
|
||||||
>>>>>>> bf0c861a0 (implement listening and favorite sync with listenbrainz)
|
|
||||||
client.submit_single_listen(listen)
|
client.submit_single_listen(listen)
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,19 +51,13 @@ def get_listen(track):
|
||||||
if upload:
|
if upload:
|
||||||
additional_info["duration"] = upload.duration
|
additional_info["duration"] = upload.duration
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
return liblistenbrainz.Listen(
|
return liblistenbrainz.Listen(
|
||||||
=======
|
|
||||||
return pylistenbrainz.Listen(
|
|
||||||
>>>>>>> bf0c861a0 (implement listening and favorite sync with listenbrainz)
|
|
||||||
track_name=track.title,
|
track_name=track.title,
|
||||||
artist_name=track.artist.name,
|
artist_name=track.artist.name,
|
||||||
listened_at=int(timezone.now()),
|
listened_at=int(timezone.now()),
|
||||||
release_name=release_name,
|
release_name=release_name,
|
||||||
additional_info=additional_info,
|
additional_info=additional_info,
|
||||||
)
|
)
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
|
|
||||||
|
|
||||||
@plugins.register_hook(plugins.FAVORITE_CREATED, PLUGIN)
|
@plugins.register_hook(plugins.FAVORITE_CREATED, PLUGIN)
|
||||||
|
@ -152,4 +132,3 @@ def sync_favorites_from_listenbrainz(user, conf):
|
||||||
)
|
)
|
||||||
except history_models.Listening.DoesNotExist:
|
except history_models.Listening.DoesNotExist:
|
||||||
tasks.import_listenbrainz_favorites(user, user_name, last_ts)
|
tasks.import_listenbrainz_favorites(user, user_name, last_ts)
|
||||||
>>>>>>> bf0c861a0 (implement listening and favorite sync with listenbrainz)
|
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import datetime
|
import datetime
|
||||||
import pylistenbrainz
|
import pylistenbrainz
|
||||||
|
|
||||||
from config import plugins
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from config import plugins
|
||||||
from funkwhale_api.users import models
|
|
||||||
from funkwhale_api.taskapp import celery
|
|
||||||
from funkwhale_api.history import models as history_models
|
from funkwhale_api.history import models as history_models
|
||||||
from funkwhale_api.music import models as music_models
|
from funkwhale_api.music import models as music_models
|
||||||
|
from funkwhale_api.taskapp import celery
|
||||||
|
from funkwhale_api.users import models
|
||||||
|
|
||||||
|
|
||||||
@celery.app.task(name="listenbrainz.trigger_listening_sync_with_listenbrainz")
|
@celery.app.task(name="listenbrainz.trigger_listening_sync_with_listenbrainz")
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
from config import plugins
|
|
||||||
|
|
||||||
from django.db.models import Prefetch
|
from django.db.models import Prefetch
|
||||||
from drf_spectacular.utils import extend_schema
|
from drf_spectacular.utils import extend_schema
|
||||||
from rest_framework import mixins, status, viewsets
|
from rest_framework import mixins, status, viewsets
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
|
||||||
|
from config import plugins
|
||||||
from funkwhale_api.activity import record
|
from funkwhale_api.activity import record
|
||||||
from funkwhale_api.common import fields, permissions
|
from funkwhale_api.common import fields, permissions
|
||||||
from funkwhale_api.music import utils as music_utils
|
from funkwhale_api.music import utils as music_utils
|
||||||
|
|
|
@ -27,7 +27,7 @@ from funkwhale_api.activity import record
|
||||||
from funkwhale_api.federation import actors
|
from funkwhale_api.federation import actors
|
||||||
from funkwhale_api.moderation import mrf
|
from funkwhale_api.moderation import mrf
|
||||||
from funkwhale_api.music import licenses
|
from funkwhale_api.music import licenses
|
||||||
|
from funkwhale_api.contrib import listenbrainz
|
||||||
from . import utils as test_utils
|
from . import utils as test_utils
|
||||||
|
|
||||||
pytest_plugins = "aiohttp.pytest_plugin"
|
pytest_plugins = "aiohttp.pytest_plugin"
|
||||||
|
@ -277,6 +277,16 @@ def disabled_musicbrainz(mocker):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# @pytest.fixture()
|
||||||
|
# def disabled_listenbrainz(mocker):
|
||||||
|
# # we ensure no listenbrainz requests gets out
|
||||||
|
# yield mocker.patch.object(
|
||||||
|
# listenbrainz.client.ListenBrainzClient,
|
||||||
|
# "_submit",
|
||||||
|
# return_value=None,
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def r_mock(requests_mock):
|
def r_mock(requests_mock):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import datetime
|
import datetime
|
||||||
import pytest
|
|
||||||
|
|
||||||
import pylistenbrainz
|
import pylistenbrainz
|
||||||
|
import pytest
|
||||||
|
|
||||||
from funkwhale_api.contrib.listenbrainz import tasks
|
from funkwhale_api.contrib.listenbrainz import tasks
|
||||||
from funkwhale_api.history import models as history_models
|
from funkwhale_api.history import models as history_models
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Add favorite and listening sync ith Listenbrainz (#2079)
|
Loading…
Reference in New Issue