Giter Club home page Giter Club logo

gdrive_download_dir's Introduction

About

This script aims to allow download shared folders from google drive without authorization.

At Aug 2017 "download all" button in web interface worked buggy:

  1. some files can absent in result zip
  2. zip create endless sometimes
  3. some filenames are mangled

Now (Nov 2022) seems, that "download all" works ok, so this script still exist due to historical reasons, but excessive mangling still applied:

  1. File COM1 will be renamed to _COM1. Similar behaviour for other filenames, that have special meaning in Windows.
  2. if dot/space is last symbol in filename, dot/space will be changed to underscore.
  3. newline will be changed to underscore (at least leading newline, but likely all).
  4. Seems filenames are case-insensitive. Likely this is property of zip creation. So files 'a' and 'A' will be renamed to 'a' and 'a(1)' in zip.
  5. Some other special symbols will be changed to underscore also. You can check this in detail using gen_test_dir.sh script.

How it works

Script emulates browser behavior. It downloads list of files in folder (in JSON format), then download each file by file_id. To get list of files need to use some magic string - need to investigate, what is it and can this string change or not. For downloading big files (those, that can't verified against viruses) used idea from turdus-merula and Andrew Hundt on stackoverflow,

Usage example

./gdrive_download_dir.py 0B0HtNZkqn9bwM0NCRXRmMTdzY1U rename|overwrite|skip

Script creates folder with given folder_id in cwd and place downloaded content there.

Last arg - strategy to resolve conflicts, if dst already contain file with same name:

  • rename - save to new file, whose name will be 'orig_name + file_id'.
  • overwrite - overwrite existing file.
  • skip - do not (re)download file, if file with same name already exist. Default behaviour.

TODO

  • Sometimes can't download any file (connection closed from server side). Possibly this is problem of my connection, because after some time (10-30 min) same code begin to work ok.
  • There is race because of possible interrupt point between checking file existance and creating file. Affect only multy-threaded download and have very low chance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.