-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0481b6c
commit 4938f09
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
''' | ||
gda.py - Python script for Google Drive download (large files) with the help of aria2 | ||
Copyright @raspiduino 2020 | ||
Date created 25/12/2020 - Christmas | ||
''' | ||
|
||
import requests | ||
import os | ||
import sys | ||
|
||
helpstring = ''' | ||
gda.py - Python script for Google Drive download (large files) with the help of aria2 | ||
Copyright @raspiduino 2020 | ||
Date created 25/12/2020 - Christmas | ||
Usage: | ||
gda.py file/help fileid | ||
fileid : Paste in the file/folder id, for example if the link is https://drive.google.com/file/d/abc | ||
please type in abc | ||
Note: + By default this python script will download at max speed using aria2 '-x16 -s16 -j5' option. You | ||
can remove it if you don't want to. | ||
+ You can add more command line to aria2 if you want | ||
''' | ||
|
||
if sys.argv != [""]: | ||
# Download a single file | ||
if sys.argv[1] != "": | ||
# Get the cookies | ||
session = requests.Session() | ||
session.get("https://drive.google.com/uc?export=download&id=" + sys.argv[1]) | ||
cookiename = list(session.cookies.get_dict().keys())[0] | ||
cookieval = list(session.cookies.get_dict().values()) | ||
|
||
# Execute the aria2c command | ||
errorcode = -1 | ||
while errorcode != 0: | ||
# Run until there is no error | ||
# Restart if error occur | ||
errorcode = os.system('aria2c -x16 -s16 -j5 --header="Cookie: ' + cookiename + '=' + cookieval[0] + '" --header="Cookie: NID=' + cookieval[1].replace("=", "%22") + '" "https://drive.google.com/uc?export=download&confirm=' + cookieval[0] + '&id=' + sys.argv[1] + '"') | ||
|
||
elif sys.argv[1] == "help": | ||
print(helpstring) | ||
|
||
else: | ||
print("Please enter a file id!") | ||
print(helpstring) | ||
|