From fb480771f64735fc855b23c71e5e895bfae5a9f8 Mon Sep 17 00:00:00 2001 From: ali-shamakhi Date: Sun, 21 Aug 2016 21:50:32 +0430 Subject: [PATCH] Skip previous downloaded files from the album. --- khinsider.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/khinsider.py b/khinsider.py index 7aa0695..133dfa7 100644 --- a/khinsider.py +++ b/khinsider.py @@ -164,8 +164,18 @@ def download(ostName, path="", verbose=False): songInfos = getFileList(ostName) totalSongs = len(songInfos) for songNumber, (name, url) in enumerate(songInfos): - downloadSong(url, path, name, verbose=verbose, - songNumber=songNumber + 1, totalSongs=totalSongs) + if not os.path.isfile(path + '/' + name): # if file does not exist + downloadSong(url, path, name, verbose=verbose, + songNumber=songNumber + 1, totalSongs=totalSongs) + else: + if verbose: + numberStr = "" + if songNumber is not None and totalSongs is not None: + numberStr += str(songNumber+1).zfill(len(str(totalSongs))) + numberStr += "/" + numberStr += str(totalSongs) + numberStr += ": " + print("File Exists {}{}... Skipped.".format(numberStr, name)) def downloadSong(songUrl, path, name="song", numTries=3, verbose=False, songNumber=None, totalSongs=None): """Download a single song at `songUrl` to `path`."""