diff --git a/DriveDownloader/netdrives/googledrive.py b/DriveDownloader/netdrives/googledrive.py index 986b4ce..1083d1f 100644 --- a/DriveDownloader/netdrives/googledrive.py +++ b/DriveDownloader/netdrives/googledrive.py @@ -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): @@ -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) diff --git a/DriveDownloader/netdrives/settings.yaml b/DriveDownloader/netdrives/settings.yaml index 1ed4dfc..a4ccfc3 100644 --- a/DriveDownloader/netdrives/settings.yaml +++ b/DriveDownloader/netdrives/settings.yaml @@ -1,3 +1,4 @@ + client_config_backend: settings client_config: client_id: 367116221053-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com @@ -9,4 +10,4 @@ save_credentials_backend: file get_refresh_token: True oauth_scope: - - https://www.googleapis.com/auth/drive \ No newline at end of file + - https://www.googleapis.com/auth/drive diff --git a/README.md b/README.md index 018390d..2cc8ddf 100644 --- a/README.md +++ b/README.md @@ -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.** diff --git a/README_CN.md b/README_CN.md index 83190f9..4b55ecd 100644 --- a/README_CN.md +++ b/README_CN.md @@ -42,7 +42,7 @@ DriveDownloader当前支持: ## 依赖 - - Python 3 + - Python 3.7+ - 请使用`pip install -r requirements.txt`安装依赖。 ## 用例 diff --git a/requirements.txt b/requirements.txt index cefa788..8b241cb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ argparse requests tqdm +rich pysocks requests_random_user_agent google-api-python-client >= 1.12.5 diff --git a/setup.py b/setup.py index 2cab64b..6cc6304 100644 --- a/setup.py +++ b/setup.py @@ -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 = [], diff --git a/tests/test_outputs/hello_gd.txt b/tests/test_outputs/hello_gd.txt new file mode 100644 index 0000000..02a788c --- /dev/null +++ b/tests/test_outputs/hello_gd.txt @@ -0,0 +1,2 @@ +DriveDownloader Test File +-- github @hwfan \ No newline at end of file