Skip to content

Instantly share code, notes, and snippets.

@Utopiah
Created March 25, 2019 20:31
Show Gist options
  • Save Utopiah/7306915027821217035e412ec8ce2f2d to your computer and use it in GitHub Desktop.
Save Utopiah/7306915027821217035e412ec8ce2f2d to your computer and use it in GitHub Desktop.
Download all your Glitch projects
// cf https://support.glitch.com/t/exporting-all-projects/9367/2
const fetch = require('node-fetch');
const wget = require('node-wget');
// cf localStorage.cachedUser in Glitch editor
var OWNER_TOKEN = "xxxx-yyyy-zzzzz-aaaa-bbbbb"
var USER_ID = "123456"
var PROJECT_ID = ""
var urlAllProjects = `https://api.glitch.com/users/${USER_ID}?authorization=${OWNER_TOKEN}`
fetch(urlAllProjects)
.then(function(response) {
return response.json();
})
.then(function(response) {
for (var project of response.projects){
PROJECT_ID = project.id
var urlDownloadProject = `https://api.glitch.com/project/download/?authorization=${OWNER_TOKEN}&projectId=${PROJECT_ID}`
wget({url: urlDownloadProject,
dest: project.name+'.tar.gz'},
function wgetDone(err, data){ if (err) console.log('wget error:', err)} );
console.log('getting', project.name)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment