wkentaro / gdown

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

AttributeError: 'NoneType' object has no attribute 'groups' #291

Closed benscarlson closed 8 months ago

benscarlson commented 8 months ago

Provide environment information

/Users/benc/.pyenv/shims/python Python 3.10.6 gdown 4.7.1

What OS are you using?

macOS Ventura 13.1 (M1)

Describe the Bug

Traceback (most recent call last): File "/Users/benc/.pyenv/versions/3.10.6/bin/gdown", line 8, in sys.exit(main()) File "/Users/benc/.pyenv/versions/3.10.6/lib/python3.10/site-packages/gdown/cli.py", line 143, in main filenames = download_folder( File "/Users/benc/.pyenv/versions/3.10.6/lib/python3.10/site-packages/gdown/download_folder.py", line 303, in download_folder filename = download( File "/Users/benc/.pyenv/versions/3.10.6/lib/python3.10/site-packages/gdown/download.py", line 259, in download filename_from_url = m.groups()[0] AttributeError: 'NoneType' object has no attribute 'groups'

Expected Behavior

It should download the folder

To Reproduce

This is accessing a folder with many large files. I'm sorry the folder can't be shared publically.

ydaniels commented 8 months ago

I can also confirm this issue seems content_disposition does not contain filename so regex failed. Failing back to filename_from_url = osp.basename(url) for now

tmorshed commented 8 months ago

Can confirm that this error arose for us today as well - three different computers (two sessions on GitHub Codespaces and a local computer). gdown version = 4.7.1

Hot fix: Downgrading to 4.6.1 fixes it:

pip install gdown==4.6.1
Bremma commented 8 months ago

Also seeing the same issue with gdown 4.7.1. Used last week without issue on Cygwin via Windows, but now getting the none type error noted above

ILG2021 commented 8 months ago

Same problem, maybe google changed something to block gdown.

KristjanRanna commented 8 months ago

Same problem, maybe google changed something to block gdown.

How would it make any sense for them to decide to block gdown?

But yeah, I am getting the same error.

Dharisd commented 8 months ago

same issue, was relying on this

Randl commented 8 months ago
import gdown
url = "https://drive.google.com/file/d/1jjJ8k3L-BzFKSevoGo6yaJ-jCjc2SCK1/view"
filename = gdown.download(url, quiet=False, fuzzy=True)

When I run the code from jupyter notebook, I get Content-Disposition: attachment; filename="clean_battle_anony_20240109.json" but when I run from file, I get attachment; filename="clean_battle_anony_20240109.json"; filename*=UTF-8''clean_battle_anony_20240109.json so it crashes only from jupyter.

awisbay commented 8 months ago

yes me too, currently face the same issue. Yesterday still working.

alirezaAsadi2018 commented 8 months ago

Same problem here. I use google colab and get this error:

Traceback (most recent call last):
  File "/usr/local/bin/gdown", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/gdown/cli.py", line 156, in main
    filename = download(
  File "/usr/local/lib/python3.10/dist-packages/gdown/download.py", line 259, in download
    filename_from_url = m.groups()[0]
AttributeError: 'NoneType' object has no attribute 'groups'

My gdown version is the latest: v4.7.1.

Quick Fix:

I found out that versions above and equal to v4.6.4 are facing this probem but v4.6.3 is working fine. so all you need to do as a user is to downgrade your version: pip install gdown==v4.6.3

guesalomon commented 8 months ago

I had this issue and also a permission error (“file is not public”). I believe both are connected to the removal of the headers: headers = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36" # NOQA }

I readded them to the latest version and it fixed both issues.

ericspod commented 8 months ago

This does appear to be an issue of a hard-coded assumption about the format of the Content-Disposition header entry which has changed. We've encountered the problem inside and outside notebooks.

ILG2021 commented 8 months ago

Hello, why the developer still don't fix it, gdown is widely used.

Gesthub commented 8 months ago

@guesalomon Where should I add them?

guesalomon commented 8 months ago

@guesalomon Where should I add them?

You can add it on the line 153 of the download.py file:

res = sess.get(url, stream=True, verify=verify)

change to:

headers = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36"  # NOQA } 

res = sess.get(url, stream=True, headers=headers, verify=verify)
    )
ghunkins commented 8 months ago

Quick Fix:

I found out that versions above and equal to v4.6.4 are facing this probem but v4.6.3 is working fine. so all you need to do as a user is to downgrade your version: pip install gdown==v4.6.3

The above fixed it for me. Just downgrade the package to v4.6.3 for now!

pip install gdown==v4.6.3
guesalomon commented 8 months ago

It worked for me also downgrading the version, but I was just giving the author a hint on what fixed it for me!

Gesthub commented 8 months ago

@guesalomon Thank you.

ghost commented 8 months ago

i also face the same issue, but downgrading gdown version is working fine

mikel-brostrom commented 8 months ago

Same issue here:

File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/gdown/download.py", line 248, in download
    filename_from_url = m.groups()[0]
AttributeError: 'NoneType' object has no attribute 'groups'

Downgrading the package to v4.6.3 solved it for me :smile:

rmcpantoja commented 8 months ago

Hi @wkentaro and all, I've fixed these two bugs in #293.

wkentaro commented 8 months ago

Hey guys. Sorry for being late (I missed the notifications), but this should be fixed now via https://github.com/wkentaro/gdown/pull/295 and the latest release.

Bremma commented 8 months ago

v4.7.3 fixed the issue for me! Thank you wkentaro and everyone else who figured out the issue!

clydebailey commented 8 months ago

Hello, why the developer still don't fix it, gdown is widely used.

Please be respectful of the people who built a software that is widely used