From d24ce88c9362d0fe31b59588559a46ea6908f5eb Mon Sep 17 00:00:00 2001 From: ego-lay-atman-bay <70973578+ego-lay-atman-bay@users.noreply.github.com> Date: Wed, 29 Jun 2022 11:29:40 -0600 Subject: [PATCH] only download video.sb3 if it doesn't exist --- scratchVideo.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/scratchVideo.py b/scratchVideo.py index f9b63b4..e90b70b 100644 --- a/scratchVideo.py +++ b/scratchVideo.py @@ -252,6 +252,13 @@ def exportVideo(videoPath, fps=10, costumeName='video'): setVar('costume name', costumeName + '-') def loadProject(): + def extractProject(): + print('extracting video.sb3') + with zipfile.ZipFile(file, 'r') as zip: + zip.printdir() + zip.extractall('project') + print('Done!') + try: print('loading project.json') loadJson('project/project.json') @@ -262,19 +269,18 @@ def loadProject(): except: print('project folder already exists') pass - - url = "https://ego-lay-atman-bay.github.io/scratch-video/project/video.sb3" - print('downloading ' + url) - file = root + '/project/video.sb3' - wget.download(url, file) - print('\nsuccessfully downloaded video.sb3') - - print('extracting video.sb3') - with zipfile.ZipFile(file, 'r') as zip: - zip.printdir() - zip.extractall('project') - print('Done!') + try: + extractProject() + except: + print('project does not exist:') + url = "https://ego-lay-atman-bay.github.io/scratch-video/project/video.sb3" + print('downloading ' + url) + file = root + '/project/video.sb3' + wget.download(url, file) + print('\nsuccessfully downloaded video.sb3') + extractProject() + print('loading project.json') loadJson('project/project.json')