Skip to content

Commit

Permalink
repair google drive
Browse files Browse the repository at this point in the history
  • Loading branch information
hwfan committed Jun 25, 2022
1 parent 91fd49e commit f250436
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 9 deletions.
28 changes: 23 additions & 5 deletions DriveDownloader/netdrives/googledrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
import sys
from rich.console import Console

googleauthdata = '''
client_config_backend: settings
client_config:
client_id: 367116221053-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com
client_secret: 1qsNodXNaWq1mQuBjUjmvhoO
save_credentials: True
save_credentials_backend: file
get_refresh_token: True
oauth_scope:
- https://www.googleapis.com/auth/drive
'''

console = Console()
class GoogleDriveSession(DriveSession):
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -39,13 +54,16 @@ def connect(self, url, custom_filename=''):
DriveSession.connect(self, replaced_url, custom_filename=custom_filename)
except:
info = '''+-------------------------------------------------------------------------------------------+
|Warning: The default request is forbidden by GoogleDrive due to the frequent downloading, |
|and DriveDownloader is now using the backup downloader. If this is the first time you meet |
|the problem, please follow the instructions to login your Google Account. Once this action |
|is performed, the downloading procedure will automatically start for all the time. |
+-------------------------------------------------------------------------------------------+'''
|Warning: The default request is forbidden by GoogleDrive due to the frequent downloading, |
|and DriveDownloader is now using the backup downloader. If this is the first time you meet |
|the problem, please follow the instructions to login your Google Account. Once this action |
|is performed, the downloading procedure will automatically start for all the time. |
+-------------------------------------------------------------------------------------------+'''
console.print(info)
settings_file_path = os.path.join(os.path.dirname(__file__), 'settings.yaml')
if not os.path.exists(settings_file_path):
with open(settings_file_path, "w") as f:
f.write(googleauthdata)
gauth = GoogleAuth(settings_file=settings_file_path)
gauth.CommandLineAuth()
drive = GoogleDrive(gauth)
Expand Down
3 changes: 2 additions & 1 deletion DriveDownloader/netdrives/settings.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

client_config_backend: settings
client_config:
client_id: 367116221053-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com
Expand All @@ -9,4 +10,4 @@ save_credentials_backend: file
get_refresh_token: True

oauth_scope:
- https://www.googleapis.com/auth/drive
- https://www.googleapis.com/auth/drive
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ DriveDownloader now supports:

## Requirements

- Python 3
- Python 3.7+
- Use `pip install -r requirements.txt` to install the packages.
- Proxy server if necessary. **We don't provide proxy service for DriveDownloader.**

Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ DriveDownloader当前支持:

## 依赖

- Python 3
- Python 3.7+
- 请使用`pip install -r requirements.txt`安装依赖。

## 用例
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
argparse
requests
tqdm
rich
pysocks
requests_random_user_agent
google-api-python-client >= 1.12.5
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
packages = find_packages(),
include_package_data = True,
platforms = "any",
install_requires = ['argparse', 'requests', 'tqdm', 'pysocks', 'requests_random_user_agent',
install_requires = ['argparse', 'requests', 'tqdm', 'rich', 'pysocks', 'requests_random_user_agent',
"google-api-python-client >= 1.12.5", "six >= 1.13.0", "oauth2client >= 4.0.0",
"PyYAML >= 3.0", "pyOpenSSL >= 19.1.0"],
scripts = [],
Expand Down
2 changes: 2 additions & 0 deletions tests/test_outputs/hello_gd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DriveDownloader Test File
-- github @hwfan

0 comments on commit f250436

Please sign in to comment.