Skip to content

Instantly share code, notes, and snippets.

@Phhere
Created August 16, 2012 21:36
Show Gist options
  • Save Phhere/3373829 to your computer and use it in GitHub Desktop.
Save Phhere/3373829 to your computer and use it in GitHub Desktop.
add_url überschreiben
@login_required
def add_url(request):
url = request.POST['url']
if url == '':
raise ValidationError("url must not be empty")
if url.find("youtube"):
test_str = subprocess.check_output("youtube-dl","-g", url)
if test_str.find("http://"):
UserSong(owner=request.user, url=test_str).save()
else
raise ValidationError("can't get youtube url")
else
UserSong(owner=request.user, url=url).save()
return HttpResponseRedirect(reverse('cannen.views.index'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment