mikf / gallery-dl

Command-line program to download image galleries and collections from several image hosting sites
GNU General Public License v2.0
11.5k stars 942 forks source link

support Google Drive by transforming view/edit/etc URLs to download URLs #1735

Open pabs3 opened 3 years ago

pabs3 commented 3 years ago

When the user is trying to view an image like this URL:

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

The URL can be transformed to this URL to download the image:

https://drive.google.com/uc?export=download&id=1nxCfRCSQFjgDuc_jhlC24Y1Lrydg46zg

There are some additional details when dealing with very large images or files that haven't yet been virus scanned, a confirmation parameter and temporary cookies are needed:

https://stackoverflow.com/questions/48133080/how-to-download-a-google-drive-url-via-curl-or-wget

Google Drive URLs can also contain folders, but I'm not sure how to transform those to a download URL:

https://drive.google.com/drive/folders/0By-NOo-lCyxBREtydWtzR0VvcWc

Hrxn commented 3 years ago

What exactly is the request here? You cannot get stuff on Google Drive without an access link, and links cannot be "transformed" to evade the sharing settings.

If something is shared (viewable) via a public link, you can access everything, copy it to your own Drive, use a handy download link etc.

But you can't access anything that was not meant to be shared, if that was the implicated question here?

pabs3 commented 3 years ago

Sorry for not being clear in my initial request.

If I have a Google Drive link that is publicly shareable, gallery-dl currently cannot download it:

$ gallery-dl https://drive.google.com/file/d/1nxCfRCSQFjgDuc_jhlC24Y1Lrydg46zg/view
[gallery-dl][error] No suitable extractor found for 'https://drive.google.com/file/d/1nxCfRCSQFjgDuc_jhlC24Y1Lrydg46zg/view'
$ echo $?
64

Adding support for that would be fairly simple (the URL transform mentioned above).

gphg commented 3 years ago

Google Drive is too general for gallery-dl usage. I recommends: https://github.com/prasmussen/gdrive/ (required auth)

This sounds like youtube-dl, an optional tools to download video. I suggest to have gdrive as optional tool to download gallery from Google Drive. There are case when Danbooru's external source are from Google Drive, for example these ones: https://safebooru.donmai.us/posts?tags=source%3Ahttps%3A%2F%2Fdrive.google.com*+status%3Aany

pabs3 commented 3 years ago

Thanks for the pointer to gdrive, but it seems like overkill to require a separate program when a couple of lines in gallery-dl could do what is needed. Also, you say gdrive requires auth, which shouldn't be needed for the gallery-dl use-case. Also, gdrive can't auto-open the download files in an image viewer like gallery-dl can.

-- bye, pabs

https://bonedaddy.net/pabs3/

108EAA0A commented 2 years ago

Sometimes fanbox and patreon only post preview images, and the full version is a link to Google Drive (or Dropbox, MEGA, etc.). It is desirable to work with the extractor.fanbox.embeds option to complete the download with gallery-dl alone.