Last active
June 9, 2022 18:52
-
-
Save gornostay25/c50afd6608e491e61620eb3fb589d9b8 to your computer and use it in GitHub Desktop.
Export your google app script project to a local directory. Python
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 requests,configparser | |
filename = "GASsettings.ini" | |
config = configparser.ConfigParser() | |
config.read(filename) | |
if not "GAS" in config: | |
print("Please create "+filename+" file!") | |
exit(1) | |
exportFolder = "./MyGASproject" | |
scriptid = config["GAS"]["script_id"] | |
authGoogleToken = config["GAS"]["token"] | |
filelist = [ f for f in os.listdir(exportFolder)] | |
for f in filelist: | |
os.remove(os.path.join(exportFolder, f)) | |
r = requests.get("https://script.google.com/feeds/download/export?id="+scriptid+"&format=json",headers={ | |
"Authorization": "Bearer "+authGoogleToken | |
}) | |
files = r.json()["files"] | |
print("-"*30) | |
print("Exporting "+str(len(files))+" file(s)") | |
for x in files: | |
ftype = x["type"] | |
if ftype == "server_js": | |
ftype = "gs" | |
with open(exportFolder+"/"+x["name"]+"."+ftype,"w") as f: | |
f.write(x["source"]) | |
print("-"*30) | |
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
[GAS] | |
script_id = blabla | |
token = blabla |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment