Removed transcoding support (#271)
This commit is contained in:
parent
390dcfd06f
commit
36a0a4df4f
7 changed files with 60 additions and 146 deletions
|
|
@ -1,23 +0,0 @@
|
|||
from django import forms
|
||||
|
||||
from . import models
|
||||
|
||||
|
||||
class TranscodeForm(forms.Form):
|
||||
FORMAT_CHOICES = [
|
||||
('ogg', 'ogg'),
|
||||
('mp3', 'mp3'),
|
||||
]
|
||||
|
||||
to = forms.ChoiceField(choices=FORMAT_CHOICES)
|
||||
BITRATE_CHOICES = [
|
||||
(64, '64'),
|
||||
(128, '128'),
|
||||
(256, '256'),
|
||||
]
|
||||
bitrate = forms.ChoiceField(
|
||||
choices=BITRATE_CHOICES, required=False)
|
||||
|
||||
track_file = forms.ModelChoiceField(
|
||||
queryset=models.TrackFile.objects.exclude(audio_file__isnull=True)
|
||||
)
|
||||
|
|
@ -35,7 +35,6 @@ from funkwhale_api.musicbrainz import api
|
|||
from funkwhale_api.requests.models import ImportRequest
|
||||
|
||||
from . import filters
|
||||
from . import forms
|
||||
from . import importers
|
||||
from . import models
|
||||
from . import permissions as music_permissions
|
||||
|
|
@ -324,42 +323,6 @@ class TrackFileViewSet(viewsets.ReadOnlyModelViewSet):
|
|||
except models.TrackFile.DoesNotExist:
|
||||
return Response(status=404)
|
||||
|
||||
@list_route(methods=['get'])
|
||||
def viewable(self, request, *args, **kwargs):
|
||||
return Response({}, status=200)
|
||||
|
||||
@list_route(methods=['get'])
|
||||
def transcode(self, request, *args, **kwargs):
|
||||
form = forms.TranscodeForm(request.GET)
|
||||
if not form.is_valid():
|
||||
return Response(form.errors, status=400)
|
||||
|
||||
f = form.cleaned_data['track_file']
|
||||
if not f.audio_file:
|
||||
return Response(status=400)
|
||||
output_kwargs = {
|
||||
'format': form.cleaned_data['to']
|
||||
}
|
||||
args = (ffmpeg
|
||||
.input(f.audio_file.path)
|
||||
.output('pipe:', **output_kwargs)
|
||||
.get_args()
|
||||
)
|
||||
# we use a generator here so the view return immediatly and send
|
||||
# file chunk to the browser, instead of blocking a few seconds
|
||||
def _transcode():
|
||||
p = subprocess.Popen(
|
||||
['ffmpeg'] + args,
|
||||
stdout=subprocess.PIPE)
|
||||
for line in p.stdout:
|
||||
yield line
|
||||
|
||||
response = StreamingHttpResponse(
|
||||
_transcode(), status=200,
|
||||
content_type=form.cleaned_data['to'])
|
||||
|
||||
return response
|
||||
|
||||
|
||||
class TagViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
queryset = Tag.objects.all().order_by('name')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue