I'm new in Django and im trying to achieve what mentioned...but i was not able to get some AudioField or MediaField in Django models, more or less likely ImageField.
Explaining better what i want:
I want to give to the user a form where he can fill with some information and can upload a zip file containing mp3 files. Then, in server i want to get this zip file, unzip it, get all of mp3 inside and get some information about these files (name, artist, duration, etc) and save this in my model (Music).
Is there some tutorial explaining how to achieve that or some links explaining how to work with zip files, and mp3 files?
I think all you need here are the 2 following links:
Python standard library (both 2.x.x and 3.x.x) contains module for work with zip files. https://docs.python.org/3/library/zipfile.html
i.e.:
with ZipFile('music_files.zip') as zip_file:
# get the list of files
names = zip_file.namelist()
# handle your files as you need. You can read the file with:
with zip_file.open(name) as f:
music_file = f.read()
# retrieve music_file metadata here
As for the extraction of mp3 files metadata there is a library: http://eyed3.nicfit.net
Hope it will help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With