Oct-30-2017, 01:57 PM
I am trying to get this script to work to download video clips off of a filerecorder device networked. I'm getting errors and I don't understand why.
import urllib, sys, string, os, posix, time
def is_download_allowed(address):
f = urllib.urlopen("http://"+address+"/config?action=get¶mid=eParamID_MediaState")
response = f.read()
if (response.find('"value":"1"') > -1):
return True
f = urllib.urlopen("http://"+address+"/config?action=set¶mid=eParamID_MediaState&value=1")
def download_clip(clip):
url = "http://" + address + "/media/" + clip
print url
posix.system("curl --output " + clip + " " + url);
def download_clips(response):
values = response.split(":")
i = 0
for word in values:
i += 1
if(word.find('clipname') > -1):
clip = values[i].split(',')[0].translate(string.maketrans("",""), '[]{} \,\"\" ')
if not os.path.exists(clip):
print "Downloading clip: " + clip
download_clip(clip)
else:
f = urllib.urlopen("http://"+address+"/config?action=set¶mid=eParamID_MediaState&value=0")
print "No new clips found"Error:At line:9 char:23
+ response = f.read()
+ ~
An expression was expected after '('.
At line:10 char:42
+ if (response.find('"value":"1"') > -1):
+ ~
Missing statement block after if ( condition ).
At line:17 char:36
+ posix.system("curl --output " + clip + " " + url);
+ ~
You must provide a value expression following the '+' operator.
At line:17 char:37
+ posix.system("curl --output " + clip + " " + url);
+ ~~~~
Unexpected token 'clip' in expression or statement.
At line:17 char:36
+ posix.system("curl --output " + clip + " " + url);
+ ~
Missing closing ')' in expression.
At line:17 char:53
+ posix.system("curl --output " + clip + " " + url);
+ ~
Unexpected token ')' in expression or statement.
At line:22 char:8
+ for word in values:
+ ~
Missing opening '(' after keyword 'for'.
At line:24 char:38
+ if(word.find('clipname') > -1):
+ ~
Missing statement block after if ( condition ).
At line:25 char:54
+ clip = values[i].split(',')[0].translate(string.maketrans ...
+ ~
Missing ')' in method call.
At line:25 char:93
+ ... s[i].split(',')[0].translate(string.maketrans("",""), '[]{} \,\"\" ')
+ ~
Unexpected token ')' in expression or statement.
Not all parse errors were reported. Correct the reported errors and try again.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedExpression
