From e3adb19880f610351a93959d52e9b5a58b4d4ad4 Mon Sep 17 00:00:00 2001 From: Hafitz Setya <71178188+breakdowns@users.noreply.github.com> Date: Mon, 22 Mar 2021 16:06:32 +0700 Subject: [PATCH] v4.4 (#31) - Fix typo - Automatic stopped after 300 second if dead torrent - Stop clone gdrive link limit --- README.md | 2 +- aria.sh | 2 +- .../mirror_utils/download_utils/aria2_download.py | 2 +- .../mirror_utils/upload_utils/gdriveTools.py | 15 +++++++++------ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d890ba9..31a0309 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ python3 generate_drive_token.py ## Deployment -Give Star & Fork this repo, than upload **token.pickle** to your forks +Give Star & Fork this repo, then upload **token.pickle** to your forks

Deploy to Heroku

diff --git a/aria.sh b/aria.sh index 731d944..9c2728a 100755 --- a/aria.sh +++ b/aria.sh @@ -4,7 +4,7 @@ export MAX_CONCURRENT_DOWNLOADS=7 aria2c --enable-rpc --rpc-listen-all=false --rpc-listen-port 6800 --check-certificate=false\ --max-connection-per-server=10 --rpc-max-request-size=1024M \ - --bt-tracker="[$tracker_list]" --bt-max-peers=0 --seed-time=0.01 --min-split-size=10M \ + --bt-tracker="[$tracker_list]" --bt-max-peers=0 --bt-tracker-connect-timeout=300 --bt-stop-timeout=300 --seed-time=0.01 --min-split-size=10M \ --follow-torrent=mem --split=10 \ --daemon=true --allow-overwrite=true --max-overall-download-limit=$MAX_DOWNLOAD_SPEED \ --max-overall-upload-limit=1K --max-concurrent-downloads=$MAX_CONCURRENT_DOWNLOADS \ diff --git a/bot/helper/mirror_utils/download_utils/aria2_download.py b/bot/helper/mirror_utils/download_utils/aria2_download.py index 56f398f..e259341 100644 --- a/bot/helper/mirror_utils/download_utils/aria2_download.py +++ b/bot/helper/mirror_utils/download_utils/aria2_download.py @@ -63,7 +63,7 @@ class AriaDownloadHelper(DownloadHelper): def __onDownloadStopped(self, api, gid): LOGGER.info(f"onDownloadStop: {gid}") dl = getDownloadByGid(gid) - if dl: dl.getListener().onDownloadError('Download stopped by user!') + if dl: dl.getListener().onDownloadError('Dead torrent!') @new_thread def __onDownloadError(self, api, gid): diff --git a/bot/helper/mirror_utils/upload_utils/gdriveTools.py b/bot/helper/mirror_utils/upload_utils/gdriveTools.py index 5b19155..c3869a1 100644 --- a/bot/helper/mirror_utils/upload_utils/gdriveTools.py +++ b/bot/helper/mirror_utils/upload_utils/gdriveTools.py @@ -269,10 +269,7 @@ class GoogleDriveHelper: if err.resp.get('content-type', '').startswith('application/json'): reason = json.loads(err.content).get('error').get('errors')[0].get('reason') if reason == 'userRateLimitExceeded' or reason == 'dailyLimitExceeded': - if USE_SERVICE_ACCOUNTS: - self.switchServiceAccount() - LOGGER.info(f"Got: {reason}, Trying Again.") - return self.copyFile(file_id,dest_id) + raise err else: raise err @@ -371,7 +368,13 @@ class GoogleDriveHelper: err = err.last_attempt.exception() err = str(err).replace('>', '').replace('<', '') LOGGER.error(err) - return err + if "User rate limit exceeded" in str(err): + msg = "User rate limit exceeded." + elif "File not found" in str(err): + msg = "File not found." + else: + msg = f"Error.\n{err}" + return msg, "" return msg, InlineKeyboardMarkup(buttons.build_menu(2)) def cloneFolder(self, name, local_path, folder_id, parent_id): @@ -501,7 +504,7 @@ class GoogleDriveHelper: spaces='drive', pageSize=200, fields='files(id, name, mimeType, size)', - orderBy='modifiedTime desc').execute() + orderBy='name asc').execute() content_count = 0 if response["files"]: msg += f'

{len(response["files"])} Results : {fileName}



'