Created
November 13, 2016 02:15
-
-
Save dddExperiments/cd5eae7f420411a5f67257df949f37f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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