Provide guidance when called with a YouTube ID starting with a dash.
[youtube-dl] / youtube_dl / compat.py
index 9d33a8ec5fbd80a75a5d382e8621f6dc616c7aa0..54920653412b77e1fdd440a6ddf331b7a86c41d3 100644 (file)
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
 import getpass
 import optparse
 import os
+import re
 import subprocess
 import sys
 
@@ -174,7 +175,10 @@ try:
     from shlex import quote as shlex_quote
 except ImportError:  # Python < 3.3
     def shlex_quote(s):
-        return "'" + s.replace("'", "'\"'\"'") + "'"
+        if re.match(r'^[-_\w./]+$', s):
+            return s
+        else:
+            return "'" + s.replace("'", "'\"'\"'") + "'"
 
 
 def compat_ord(c):