[tracks] Allow adding tracks to monthly playlists

This commit is contained in:
2026-06-05 13:29:49 -04:00
parent 7a504e45de
commit 99c056adeb
8 changed files with 157 additions and 2 deletions

View File

@ -1034,6 +1034,38 @@ def add_to_mopidy_queue(request, uuid):
return redirect("scrobbles:detail", uuid=uuid)
@require_POST
def add_to_mopidy_monthly_playlist(request, uuid):
if not request.user.is_authenticated:
return redirect("scrobbles:detail", uuid=uuid)
scrobble = get_object_or_404(Scrobble, uuid=uuid, user=request.user)
profile = request.user.profile
pattern = profile.monthly_mopidy_playlist_pattern
if not pattern or not profile.mopidy_api_url:
messages.add_message(
request,
messages.ERROR,
"Monthly playlist pattern or Mopidy API URL not configured in your profile.",
)
return redirect("scrobbles:detail", uuid=uuid)
from scrobbles.utils import add_track_to_mopidy_monthly_playlist
add_track_to_mopidy_monthly_playlist(scrobble)
from django.utils.dateformat import DateFormat
playlist_name = DateFormat(scrobble.timestamp).format(pattern)
messages.add_message(
request,
messages.SUCCESS,
f'Added "{scrobble.media_obj}" to monthly playlist "{playlist_name}".',
)
return redirect("scrobbles:detail", uuid=uuid)
@require_POST
def toggle_favorite(request, media_type, object_id):
if not request.user.is_authenticated: