mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 21:52:21 +01:00
Merge branch 'replaygain' into 'master'
Replaygain support for django component See merge request !12
This commit is contained in:
@ -9,7 +9,9 @@ def song_to_dict(song, hash=False, user=False):
|
|||||||
'id': song.id,
|
'id': song.id,
|
||||||
'artist': song.artist,
|
'artist': song.artist,
|
||||||
'title': song.title,
|
'title': song.title,
|
||||||
'duration': song.duration
|
'duration': song.duration,
|
||||||
|
'rg_gain': song.rg_gain,
|
||||||
|
'rg_peak': song.rg_peak,
|
||||||
}
|
}
|
||||||
|
|
||||||
if hash:
|
if hash:
|
||||||
|
|||||||
@ -8,4 +8,5 @@ urlpatterns = [
|
|||||||
url(r'^queue', views.queue),
|
url(r'^queue', views.queue),
|
||||||
url(r'^play', views.play),
|
url(r'^play', views.play),
|
||||||
url(r'^next', views.next),
|
url(r'^next', views.next),
|
||||||
|
url(r'^analysed', views.analysed),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -6,6 +6,7 @@ from django.views.decorators.csrf import csrf_exempt
|
|||||||
|
|
||||||
from marietje.utils import playlist_song_to_dict
|
from marietje.utils import playlist_song_to_dict
|
||||||
from queues.models import Queue
|
from queues.models import Queue
|
||||||
|
from songs.models import Song
|
||||||
|
|
||||||
from .decorators import token_required
|
from .decorators import token_required
|
||||||
|
|
||||||
@ -44,3 +45,23 @@ def next(request):
|
|||||||
player_song.state = 2
|
player_song.state = 2
|
||||||
player_song.save()
|
player_song.save()
|
||||||
return JsonResponse({})
|
return JsonResponse({})
|
||||||
|
|
||||||
|
@csrf_exempt
|
||||||
|
@token_required
|
||||||
|
def next(request):
|
||||||
|
queue = get_object_or_404(Queue, id=request.POST.get('queue'))
|
||||||
|
player_song = queue.current_song()
|
||||||
|
player_song.state = 2
|
||||||
|
player_song.save()
|
||||||
|
return JsonResponse({})
|
||||||
|
|
||||||
|
@csrf_exempt
|
||||||
|
@token_required
|
||||||
|
def analysed(request):
|
||||||
|
song = get_object_or_404(Song, id=request.POST.get('song'))
|
||||||
|
if 'gain' in request.POST:
|
||||||
|
song.rg_gain = request.POST.get('gain')
|
||||||
|
if 'peak' in request.POST:
|
||||||
|
song.rg_peak = request.POST.get('peak')
|
||||||
|
song.save()
|
||||||
|
return JsonResponse({})
|
||||||
|
|||||||
30
marietje/songs/migrations/0002_replaygain.py
Normal file
30
marietje/songs/migrations/0002_replaygain.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.5 on 2017-09-18 12:14
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('songs', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='song',
|
||||||
|
name='rg_gain',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=6, help_text='replaygain gain level', max_digits=9, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='song',
|
||||||
|
name='rg_peak',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=6, help_text='replaygain peak level', max_digits=9, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='song',
|
||||||
|
name='duration',
|
||||||
|
field=models.IntegerField(help_text='track duration in seconds'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -12,7 +12,11 @@ class Song(models.Model):
|
|||||||
artist = models.TextField()
|
artist = models.TextField()
|
||||||
title = models.TextField()
|
title = models.TextField()
|
||||||
hash = models.TextField()
|
hash = models.TextField()
|
||||||
duration = models.IntegerField()
|
duration = models.IntegerField(help_text="track duration in seconds")
|
||||||
|
rg_gain = models.DecimalField(max_digits=9, decimal_places=6,
|
||||||
|
blank=True, null=True, help_text="replaygain gain level")
|
||||||
|
rg_peak = models.DecimalField(max_digits=9, decimal_places=6,
|
||||||
|
blank=True, null=True, help_text="replaygain peak level")
|
||||||
old_id = models.TextField(blank=True, null=True, default=None)
|
old_id = models.TextField(blank=True, null=True, default=None)
|
||||||
deleted = models.BooleanField(default=False)
|
deleted = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user