wkentaro / gdown

Google Drive Public File Downloader when Curl/Wget Fails
MIT License
4.21k stars 348 forks source link

Add skip_download option to download_folder to return the list of files without download #317

Closed wkentaro closed 8 months ago

wkentaro commented 8 months ago

Close https://github.com/wkentaro/gdown/pull/310 Close https://github.com/wkentaro/gdown/discussions/309

Why?

In https://github.com/wkentaro/gdown/discussions/309, @o-laurent explained an interesting use case where he wants to select which file to download in a Google Drive folder based on its file name.

What is this?

If you pass skip_download=True to download_folder, you can get list of files as list of tuple of (id, path, local_path). After that you can just use gdown.download to download the ones you want.

# Example:
files = gdown.download_folder(..., skip_download=True)
for file in files:
    if file.path.endswith(".txt"):
        gdown.download(id=file.id, output=file.local_path)