wkentaro / gdown

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

local variable 'name' referenced before assignment #220

Closed ShadowMitia closed 1 year ago

ShadowMitia commented 1 year ago

Provide environment information

usr/bin/python Python 3.10.6 gdown 4.5.3

What OS are you using?

Ubuntu 22.04.1 LTS

Describe the Bug

I can't download folders using either the python module or the CLI utility.

I keep getting UnboundLocalError: local variable 'name' referenced before assignment

Trace:


Retrieving folder list
Traceback (most recent call last):
  File "/home/dbelopopsky/.local/bin/gdown", line 8, in <module>
    sys.exit(main())
  File "/home/dbelopopsky/.local/lib/python3.10/site-packages/gdown/cli.py", line 138, in main
    filenames = download_folder(
  File "/home/dbelopopsky/.local/lib/python3.10/site-packages/gdown/download_folder.py", line 316, in download_folder
    return_code, gdrive_file = download_and_parse_google_drive_link(
  File "/home/dbelopopsky/.local/lib/python3.10/site-packages/gdown/download_folder.py", line 177, in download_and_parse_google_drive_link
    gdrive_file, id_name_type_iter = parse_google_drive_file(
  File "/home/dbelopopsky/.local/lib/python3.10/site-packages/gdown/download_folder.py", line 128, in parse_google_drive_file
    name=name,
UnboundLocalError: local variable 'name' referenced before assignment

Expected Behavior

Should be getting a folder from google drive. Single files work fine.

To Reproduce

Reproduced with

gdown --folder <id>

and

import gdown
gdown.download(id=my_id, quiet=True, use_cookies=False)
sd-denisoff commented 1 year ago

This is so relevant to me. Any news when they can fix it?

wkentaro commented 1 year ago

If you provide how to reproduce, probably that helps.

sd-denisoff commented 1 year ago

Try this

import gdown
gdown.download_folder("https://drive.google.com/drive/folders/1_Aqgiq7VSO2hieof5CKEOvyYMqOpr8QA")
sd-denisoff commented 1 year ago

@wkentaro

Check download_folder.py. At 120 line seps defined as [" - ", " – "]. But in my case it is \xa0– strange prefix 🤔🤔

image image
madby31 commented 1 year ago

I add a print before splitted. In output i copy a dash whith spaces and change dash in sep.

    for sep in seps:
        print(folder_soup.title.contents[0])
        splitted = folder_soup.title.contents[0].split(sep)

image

After this it work.

sd-denisoff commented 1 year ago

@wkentaro, could you please release an update? The solution is above. Thanks a lot!