import os | |
import subprocess | |
import urllib | |
import sys | |
# you need to pass the _list.txt file as 1st argument. | |
# python download_list.py ps2_list.txt | |
f = open(sys.argv[1], 'r+') | |
for line in f: | |
tmp = line.split(" ") | |
guid = tmp[0] | |
print "Processing: %s" % guid | |
url = tmp[2].rstrip('\r\n') # remove end of line | |
filename, file_extension = os.path.splitext(url) | |
target_file = guid + file_extension | |
tmp_file = guid + ".tmp" | |
if os.path.isfile(tmp_file): | |
# delete temporary file | |
os.remove(tmp_file) | |
if not os.path.isfile(target_file): | |
# download url to temporary file | |
urllib.urlretrieve (url, tmp_file) | |
# rename temporary file to target filename | |
os.rename(tmp_file, target_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment