def index(request): form = TrackForm() if request.method == "POST": form = TrackForm(request.POST); t = Track() t.url = form.data['url'] t.save() return render_to_response('index.html',locals())
def handle(self, *args, **options): #thanks to http://rosettacode.org/wiki/Walk_a_directory/Recursively#Python for music_path in args: for root, dirs, files in os.walk(music_path): for filename in fnmatch.filter(files, '*.mp3'): music_tags = MP3(os.path.join(root, filename)) try: track = Track( title=music_tags['title'][0], number = int(music_tags['tracknumber'][0].split('/')[0]), artist = music_tags['artist'][0], album = music_tags['album'][0], ) except KeyError: raise CommandError('Track %s Is missing Tag Information!' % filename) track.save()