Esempio n. 1
0
def upload(request, usrid):
    if request.method == "POST":

        this = AudioMeta()
        try:
            this.name = request.POST['title']
        except:
            this.name = "NONE"

        try:
            this.user_id = User.objects.get(id=usrid)
        except:
            try:
                this.user_id = User.objects.get(id=1)
            except:
                pass

        this.annotations = 0
        this.transcriptions = 0
        this.plays = 0
        this.likes = 0

        if request.FILES:

            this.bytes = request.FILES['file'].size
            a = open("/home/leegao/webapps/notetag/notetag/audio/a.txt", "w")
            a.write(str(request.FILES))
            a.close()
            try:
                this.type = extension_re.search(
                    request.FILES['file'].name).group(1).lower()
            except:
                this.type = "wav"
            this.save()

            try:
                marks = request.POST['marks']

                for secs in [int(i.strip()) for i in marks.split(",") if i]:
                    m = Bookmark(aud_id=this, time=secs)
                    m.save()
            except:
                pass

            handle_uploaded_file(request.FILES['file'], this.id, this.type)
        else:
            return HttpResponseForbidden()

        return HttpResponse(content="1")
    else:
        form = UploadFileForm()
        return render_to_response('upload.html', {
            'form': form,
            'usrid': usrid
        })
Esempio n. 2
0
def upload(request, usrid):
    if request.method == "POST":

        this = AudioMeta()
        try:
            this.name = request.POST["title"]
        except:
            this.name = "NONE"

        try:
            this.user_id = User.objects.get(id=usrid)
        except:
            try:
                this.user_id = User.objects.get(id=1)
            except:
                pass

        this.annotations = 0
        this.transcriptions = 0
        this.plays = 0
        this.likes = 0

        if request.FILES:

            this.bytes = request.FILES["file"].size
            a = open("/home/leegao/webapps/notetag/notetag/audio/a.txt", "w")
            a.write(str(request.FILES))
            a.close()
            try:
                this.type = extension_re.search(request.FILES["file"].name).group(1).lower()
            except:
                this.type = "wav"
            this.save()

            try:
                marks = request.POST["marks"]

                for secs in [int(i.strip()) for i in marks.split(",") if i]:
                    m = Bookmark(aud_id=this, time=secs)
                    m.save()
            except:
                pass

            handle_uploaded_file(request.FILES["file"], this.id, this.type)
        else:
            return HttpResponseForbidden()

        return HttpResponse(content="1")
    else:
        form = UploadFileForm()
        return render_to_response("upload.html", {"form": form, "usrid": usrid})
Esempio n. 3
0
def upload(request, usrid):
    if request.method == "POST":

        this = AudioMeta()
        this.name = request.POST['title']
        #try:
        this.user_id = User.objects.get(id=usrid)
        #except:
        #return HttpResponseForbidden()
        this.annotations = 0
        this.transcriptions = 0
        this.plays = 0
        this.likes = 0

        if request.FILES:
            this.bytes = request.FILES['file'].size
            try:
                this.type = extension_re.search(
                    request.FILES['file'].name).group(1).lower()
            except:
                this.type = "wav"
            this.save()
            try:
                marks = request.POST['marks']
                for secs in [int(i.strip()) for i in marks.split(",")]:
                    m = Bookmark(aud_id=this, time=secs)
                    m.save()
            except:
                pass
            handle_uploaded_file(request.FILES['file'], this.id, this.type)
        else:
            return HttpResponseForbidden()

        return HttpResponseRedirect('/')
    else:
        form = UploadFileForm()
        return render_to_response('upload.html', {
            'form': form,
            'usrid': usrid
        })
Esempio n. 4
0
def upload(request, usrid):
    if request.method == "POST":


        this = AudioMeta()
        this.name = request.POST['title']
        #try:
        this.user_id = User.objects.get(id=usrid)
        #except:
            #return HttpResponseForbidden()
        this.annotations = 0
        this.transcriptions = 0
        this.plays = 0
        this.likes = 0

        if request.FILES:
            this.bytes = request.FILES['file'].size
            try:
                this.type = extension_re.search(request.FILES['file'].name).group(1).lower()
            except:
                this.type = "wav"
            this.save()
            try:
                marks = request.POST['marks']
                for secs in [int(i.strip()) for i in marks.split(",")]:
                    m = Bookmark(aud_id = this, time = secs)
                    m.save()
            except:
                pass
            handle_uploaded_file(request.FILES['file'], this.id, this.type)
        else:
            return HttpResponseForbidden()

        return HttpResponseRedirect('/')
    else:
        form = UploadFileForm()
        return render_to_response('upload.html', {'form': form, 'usrid':usrid})