command line option for language

This commit is contained in:
Paweł Płazieński 2016-02-20 16:19:21 +01:00
parent c467260b65
commit 4e587aec00

16
napi
View file

@ -27,14 +27,22 @@ base_url = "http://napiprojekt.pl/api/api-napiprojekt3.php"
password = "iBlm8NTigvru0Jr0" password = "iBlm8NTigvru0Jr0"
input_filename = '/tmp/napi-temp-file' input_filename = '/tmp/napi-temp-file'
from getopt import getopt
opts, args = getopt(sys.argv[1:], '', ['language='])
language = "PL" language = "PL"
if len(sys.argv) < 2: for optname, optvalue in opts:
print "usage: %s <movie>" % sys.argv[0] if optname == '--language':
sys.exit(2) language = optvalue
if len(args) < 1:
print "usage: %s <movie>" % (sys.argv[0],)
sys.exit(0)
d = md5.new() d = md5.new()
movie_filename = sys.argv[1] movie_filename = args[0]
try: try:
with open(movie_filename, "r") as movie_file: with open(movie_filename, "r") as movie_file:
d.update(movie_file.read(10485760)) d.update(movie_file.read(10485760))