How to download Google Drive files using the command line

How to download Google Drive files using command line in Linux system

  When we need to download data sets and other resources through files shared on Google Drive, it is often not feasible to use the downloader that comes with the browser. Take the Safari browser as an example.
Insert image description here
  You can see that "the network connection has been interrupted" will appear, and when we download the task again, the task will start again, so we need to find other ways to download.

  One possible method is to download it through the IDM plug-in of the Chrome browser, but it requires a fee.

  The solution given in this article is to download through the command line.
In Linux system, download the gdown tool through the following command

pip install gdown

  Then enter the following command in the command line to download the resources of Google Drive

#gdown + https://drive.google.com/uc?id= +需要下载的FileID
#下面举一个例子
gdown https://drive.google.com/uc?id=1H73TfV5gQ9ot7slSed_l-lim9X7pMRiU
#本例中FileID=1H73TfV5gQ9ot7slSed_l-lim9X7pMRiU

  How to get FileID:
Insert image description here
  Click to get the link, then click to copy the link, as shown in the picture, there will be the following link

https://drive.google.com/file/d/1ftesnmlh7NU3m5MuXGQ6OCJkylTsBOjU/view?usp=share_link

  We just take the 1ftesnmlh7NU3m5MuXGQ6OCJkylTsBOjU part as our FileID.

  In addition, you can continue the last interrupted download by adding the -c command, which can avoid the trouble of network connection interruption. For example, if we want to (continue) download the FileID is a>1ftesnmlh7NU3m5MuXGQ6OCJkylTsBOjU file, you only need the following command

gdown -c https://drive.google.com/uc?id=1ftesnmlh7NU3m5MuXGQ6OCJkylTsBOjU

  The final effect is shown in the picture below
Insert image description here
  You can see that although we interrupted at 36%, the downloaded file became smaller when we executed the command for the second time, that is, When the program is downloaded again, it will start downloading from where it was last interrupted. ^ _ ^

  If the download is interrupted multiple times, an error will be reported: Too many users have viewed or downloaded this file recently. Please try accessing the file again later. If the file you are trying to access is particularly large or is shared with many people, it may take up to 24 hours to be able to view or download the file. If you still can't access a file after 24 hours, contact your domain administrator. , we can continue downloading our task through curl, Reference Link.

  There is also a metaphysical method. If the file we download is less than 15G, we can copy the file shared by others to our cloud space. We can directly download a copy of the file we just copied. The process is the same as before. Get the link to download. After using this method, I have never interrupted the download through the command line gdown, and the speed can be greatly improved. It is not a dream to jump from 20KB to 1MB! ! !

Guess you like

Origin blog.csdn.net/lzq6261/article/details/130032780