Advertisement
iklio

Untitled

Mar 24th, 2021
943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import csv
  4. import os
  5. import wget
  6. import sys
  7.  
  8. #Title ID        Region  Name    PKG direct link RAP     Content ID      Last Modification Date  Download .RAP file      File Size       SHA256
  9.  
  10.  
  11.  
  12. if len(sys.argv)<2:
  13.     print("Please specify tsv file")
  14.     sys.exit(1)
  15.  
  16. with open(sys.argv[1]) as fd:
  17.     tsvfile = csv.reader(fd, delimiter="\t", quotechar='"')
  18.     next(tsvfile)
  19.     for row in tsvfile:
  20.         if row[0] == "":
  21.             print("Missing Title ID: " + str(row))
  22.             continue
  23.         title_region = row[0] + "_" + row[1]
  24.         dirPath = "data/" + title_region
  25.         if not row[3].startswith("http"):
  26.             if row[3] != "MISSING":
  27.                 print(row[3])
  28.             continue
  29.         dl_name = row[3].split("/")[-1]
  30.         #print(dl_name)
  31.         os.makedirs(dirPath, exist_ok=True)
  32.         filePath = dirPath + "/" + dl_name
  33.         if os.path.isfile(filePath) and  (os.path.getsize(filePath) == int(row[8])):
  34.             print("Skip already downloaded file" + filePath)
  35.             continue
  36.         print("Download " + filePath)
  37.         wget.download(row[3], filePath)
  38.         print("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement