Created
August 16, 2012 21:36
-
-
Save Phhere/3373829 to your computer and use it in GitHub Desktop.
add_url überschreiben
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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