Commit 49517623 authored by fred's avatar fred

store uploaded tracks in temporary files as older mutagen requires a real file

parent 9afd969b
...@@ -2,6 +2,7 @@ import csv ...@@ -2,6 +2,7 @@ import csv
import datetime import datetime
from cStringIO import StringIO from cStringIO import StringIO
import os import os
import tempfile
import mutagen import mutagen
...@@ -160,8 +161,10 @@ class UploadTracksView(FormView): ...@@ -160,8 +161,10 @@ class UploadTracksView(FormView):
missing_metadata = [] missing_metadata = []
metadatas = {} metadatas = {}
for f in tracks: for f in tracks:
metadata = mutagen.File(f, easy=True) with tempfile.NamedTemporaryFile(prefix='track-upload') as tmpfile:
f.seek(0) tmpfile.write(f.read())
f.seek(0)
metadata = mutagen.File(tmpfile.name, easy=True)
if not metadata or not metadata.get('artist') or not metadata.get('title'): if not metadata or not metadata.get('artist') or not metadata.get('title'):
missing_metadata.append(f.name) missing_metadata.append(f.name)
else: else:
......
Markdown is supported
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