Provide guidance when called with a YouTube ID starting with a dash.

Reported at https://news.ycombinator.com/item?id=8648121
This commit is contained in:
Philipp Hagemeister 2014-11-23 10:49:19 +01:00
parent d37cab2a9d
commit 7d4111ed14
5 changed files with 41 additions and 4 deletions

View 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):