Skip to content

Instantly share code, notes, and snippets.

@GitHub30
Last active April 9, 2020 13:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GitHub30/e99263d1405ff81211d2e0ff346f9ed0 to your computer and use it in GitHub Desktop.
Save GitHub30/e99263d1405ff81211d2e0ff346f9ed0 to your computer and use it in GitHub Desktop.
{
"export": {
"id": "eda61457-f0eb-459a-991f-f8a597bd1a15",
"status": "SUCCEEDED",
"items": [
{
"id": "1TdFtOzKlGQnckOavxlwgJuW4nc9oGU6U"
}
],
"conversions": [
{
"sourceFormat": "application/vnd.google-apps.appmaker",
"destinationFormat": "application/zip"
},
{
"sourceFormat": "application/vnd.google-apps.document",
"destinationFormat": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
},
{
"sourceFormat": "application/vnd.google-apps.drawing",
"destinationFormat": "image/jpeg"
},
{
"sourceFormat": "application/vnd.google-apps.form",
"destinationFormat": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
},
{
"sourceFormat": "application/vnd.google-apps.presentation",
"destinationFormat": "application/vnd.openxmlformats-officedocument.presentationml.presentation"
},
{
"sourceFormat": "application/vnd.google-apps.spreadsheet",
"destinationFormat": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
}
],
"archives": [
{
"fileName": "takeout-20180910T161503Z-001.zip",
"storagePath": "https://storage.googleapis.com/drive-bulk-export-anonymous/20180910T161503Z/4133399871716478688/eda61457-f0eb-459a-991f-f8a597bd1a15/1/717f8bc5-9ce1-4b2e-89f4-5bd60ae8603d",
"compressedSize": "169649",
"sizeOfContents": "169379"
}
]
},
"percentDone": 100,
"numFetchedFiles": 1,
"exportJob": {
"id": "eda61457-f0eb-459a-991f-f8a597bd1a15",
"status": "SUCCEEDED",
"items": [
{
"id": "1TdFtOzKlGQnckOavxlwgJuW4nc9oGU6U"
}
],
"conversions": [
{
"sourceFormat": "application/vnd.google-apps.appmaker",
"destinationFormat": "application/zip"
},
{
"sourceFormat": "application/vnd.google-apps.document",
"destinationFormat": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
},
{
"sourceFormat": "application/vnd.google-apps.drawing",
"destinationFormat": "image/jpeg"
},
{
"sourceFormat": "application/vnd.google-apps.form",
"destinationFormat": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
},
{
"sourceFormat": "application/vnd.google-apps.presentation",
"destinationFormat": "application/vnd.openxmlformats-officedocument.presentationml.presentation"
},
{
"sourceFormat": "application/vnd.google-apps.spreadsheet",
"destinationFormat": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
}
],
"archives": [
{
"fileName": "takeout-20180910T161503Z-001.zip",
"storagePath": "https://storage.googleapis.com/drive-bulk-export-anonymous/20180910T161503Z/4133399871716478688/eda61457-f0eb-459a-991f-f8a597bd1a15/1/717f8bc5-9ce1-4b2e-89f4-5bd60ae8603d",
"compressedSize": "169649",
"sizeOfContents": "169379"
}
]
}
}
Downloading a folder misses half of it's content
https://productforums.google.com/forum/#!topic/drive/0rTmZmP_j0k
id=$1;
queued_json=$(curl https://takeout-pa.clients6.google.com/v1/exports?key=AIzaSyC1qbk75NzWBvSaDh6KnsjjA9pIrP4lYIE -H 'origin: https://drive.google.com' -H 'content-type: application/json' -d '{"archiveFormat":null,"archivePrefix":null,"conversions":null,"items":[{"id":"'$id'"}],"locale":null}')
export_job_id=$(echo "$queued_json" | grep -A100000 exportJob | awk -F'"' '$0~/^ "id"/{print$4}')
storage_path=''
until [ "$storage_path" ]; do
succeeded_json=$(curl "https://takeout-pa.clients6.google.com/v1/exports/$export_job_id?key=AIzaSyC1qbk75NzWBvSaDh6KnsjjA9pIrP4lYIE" -H 'origin: https://drive.google.com')
echo "$succeeded_json" | awk -F'"' '$0~/^ "percentDone"/{print$0}'
echo "$succeeded_json" | grep -A100000 exportJob | awk -F'"' '$0~/^ "status"/{print$0}'
storage_path=$(echo "$succeeded_json" | grep -A100000 exportJob | awk -F'"' '$0~/^ "storagePath"/{print$4}')
sleep 1
done
curl -OJ $storage_path
{
"export": {
"id": "eda61457-f0eb-459a-991f-f8a597bd1a15",
"status": "QUEUED",
"items": [
{
"id": "1TdFtOzKlGQnckOavxlwgJuW4nc9oGU6U"
}
],
"conversions": [
{
"sourceFormat": "application/vnd.google-apps.appmaker",
"destinationFormat": "application/zip"
},
{
"sourceFormat": "application/vnd.google-apps.document",
"destinationFormat": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
},
{
"sourceFormat": "application/vnd.google-apps.drawing",
"destinationFormat": "image/jpeg"
},
{
"sourceFormat": "application/vnd.google-apps.form",
"destinationFormat": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
},
{
"sourceFormat": "application/vnd.google-apps.presentation",
"destinationFormat": "application/vnd.openxmlformats-officedocument.presentationml.presentation"
},
{
"sourceFormat": "application/vnd.google-apps.spreadsheet",
"destinationFormat": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
}
]
},
"exportJob": {
"id": "eda61457-f0eb-459a-991f-f8a597bd1a15",
"status": "QUEUED",
"items": [
{
"id": "1TdFtOzKlGQnckOavxlwgJuW4nc9oGU6U"
}
],
"conversions": [
{
"sourceFormat": "application/vnd.google-apps.appmaker",
"destinationFormat": "application/zip"
},
{
"sourceFormat": "application/vnd.google-apps.document",
"destinationFormat": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
},
{
"sourceFormat": "application/vnd.google-apps.drawing",
"destinationFormat": "image/jpeg"
},
{
"sourceFormat": "application/vnd.google-apps.form",
"destinationFormat": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
},
{
"sourceFormat": "application/vnd.google-apps.presentation",
"destinationFormat": "application/vnd.openxmlformats-officedocument.presentationml.presentation"
},
{
"sourceFormat": "application/vnd.google-apps.spreadsheet",
"destinationFormat": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment