wkentaro / gdown

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

unable to download the complete file #355

Open luoyuchenmlcv opened 4 months ago

luoyuchenmlcv commented 4 months ago

Provide environment information

Python 3.9.19 gdown 5.1.0

What OS are you using?

Ubuntu 20.04.4

Describe the Bug

https://drive.google.com/file/d/1ZrvSHklXiGYhpiVoxUH8FWc5k0fv2xVZ/view

https://drive.usercontent.google.com/download?id=1ZrvSHklXiGYhpiVoxUH8FWc5k0fv2xVZ&export=download&authuser=0

image image

Expected Behavior

The file is 15Gb, however only 3.81k is downloaded and shown as complete.

To Reproduce

gdown https://drive.google.com/file/d/1ZrvSHklXiGYhpiVoxUH8FWc5k0fv2xVZ/view

gdown https://drive.usercontent.google.com/download?id=1ZrvSHklXiGYhpiVoxUH8FWc5k0fv2xVZ&export=download&authuser=0

luoyuchenmlcv commented 4 months ago

the downloaded file is HTML file, how can I download this file using gdown==5.1.0

sergeevabc commented 4 months ago

Aggrrhh.

$ gdown https://drive.google.com/file/d/0B0d9ZiqAgFkiOHR1NTJhWVJMNEU/view?resourcekey=0-3WcVUCySTS9ajn1UWHrmtA

\Python\Lib\site-packages\gdown\parse_url.py:48: UserWarning: You specified a Google Drive link that is not the correct link to download a file. You might want to try `--fuzzy` option or the following url: https://drive.google.com/uc?id=0B0d9ZiqAgFkiOHR1NTJhWVJMNEU
  warnings.warn(
Error:

        [Errno 22] Invalid argument:
        'view?resourcekey=0-3WcVUCySTS9ajn1UWHrmtAjxnrt18ytmp'

$ gdown https://drive.google.com/file/d/0B4FkkLP2MB8kMDRiNDkxOGEtMDhmNC00NzJjLThkNzQtZDc0MDNlNWVhZjk1/view?resourcekey=0-k2XR2jyQonn-pTD8ndivgA

Error:

        [Errno 22] Invalid argument: 'view?resourcekey=0-k2XR2jyQonn-
        pTD8ndivgA4cqishhttmp'
lefteryx commented 4 months ago
def get_download_link(URL):
    file_id = URL.split('/')[-2]
    download_link = f"https://drive.google.com/uc?id={file_id}"
    return download_link

Use this function to obtain a direct-downloadable link and feed this to gdown.