Permalink
Browse files

Fixed Video ID handling

  • Loading branch information...
1 parent ed32c45 commit efe3e5ae5e6ffc71d6d41cfea53f9cc1939daa3a Vasily Ponomarev committed Apr 16, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 youtube_downloader.py
View
@@ -3,6 +3,7 @@
to choose their quality"""
import locale
+import re
from sys import stdout
from urllib import urlopen, unquote, urlretrieve
from urlparse import parse_qs
@@ -31,9 +32,8 @@ def geturl(url, dst):
# Ask for Video ID
video_id = raw_input("\nYouTube Video ID? ")
-if not video_id.isalnum():
- raise ValueError("Video ID should contain alphanumeric characters only" \
- % video_id)
+if not re.match(r'[A-Za-z0-9\-]+', video_id):
+ raise ValueError("Video ID should contain alphanumeric characters only")
# Retrieve Video Information from YouTube
video_info = parse_qs(
@@ -62,7 +62,7 @@ def geturl(url, dst):
fmt_chosen = raw_input("\nFormat? ")
if fmt_chosen not in [fmt.split("/")[0] for fmt in video_fmt]:
- raise ValueError("You must select from available formats only" % fmt_chosen)
+ raise ValueError("You must select from available formats only")
# Video Download
video_link = "".join(

0 comments on commit efe3e5a

Please sign in to comment.