Skip to content

Commit

Permalink
v3.6 (breakdowns#13)
Browse files Browse the repository at this point in the history
- Added extra buttons
  • Loading branch information
breakdowns authored Mar 5, 2021
1 parent df192e4 commit 4d59931
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 27 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
COPY . .
COPY .netrc /root/.netrc
RUN chmod +x aria.sh

CMD ["bash","start.sh"]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ Fork this repo, than upload credentials.json and token.pickle to your forks
## Features supported:
- Mirroring direct download links to Google Drive
- Mirroring Mega.nz links to google drive (In development stage)
- Download progress
- Upload progress
- Copy files/folder from someone's drive to your drive
- Download/upload progress
- Download/upload speeds and ETAs
- Docker support
- Uploading To Team Drives.
- Index Link support
- Copy files/folder from someone's drive to your drive
- Service account support
- Mirror all youtube-dl supported links
- Mirror telegram files
Expand All @@ -48,6 +47,7 @@ Fork this repo, than upload credentials.json and token.pickle to your forks
- Nyaa.si and Sukebei Torrent search
- Shell and Executor
- Shortener support
- Custom Buttons
- Speedtest with picture results
- Extract these filetypes and uploads to google drive
> ZIP, RAR, TAR, 7z, ISO, WIM, CAB, GZIP, BZIP2,
Expand Down
30 changes: 27 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
"required": false
},
"USE_SERVICE_ACCOUNTS": {
"description": "Whether to use service accounts or not. For this to work see 'Using service accounts' section below.",
"description": "Whether to use service accounts or not. For this to work see 'Using service accounts' in repo.",
"required": false
},
"AUTHORIZED_CHATS": {
"description": "Put User ID and Chat ID of you want to authorize.",
"description": "Fill User ID and Chat ID of you want to authorize.",
"required": false
},
"INDEX_URL": {
Expand Down Expand Up @@ -83,12 +83,36 @@
"required": false
},
"SHORTENER": {
"description": "if you want to use shortener in Gdrive and index link.",
"description": "If you want to use shortener in Gdrive and index link.",
"required": false
},
"SHORTENER_API": {
"description": "Fill your shortener api key if you are using shortener.",
"required": false
},
"BUTTON_THREE_NAME": {
"description": "Extra buttons (optional).",
"required": false
},
"BUTTON_THREE_URL": {
"description": "Fill your URL if you are using extra buttons.",
"required": false
},
"BUTTON_FOUR_NAME": {
"description": "Extra buttons (optional).",
"required": false
},
"BUTTON_FOUR_URL": {
"description": "Fill your URL if you are using extra buttons.",
"required": false
},
"BUTTON_FIVE_NAME": {
"description": "Extra buttons (optional).",
"required": false
},
"BUTTON_FIVE_URL": {
"description": "Fill your URL if you are using extra buttons.",
"required": false
}
}
}
27 changes: 24 additions & 3 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,30 @@ def getConfig(name: str):
INDEX_URL = None
except KeyError:
INDEX_URL = None
try:
BUTTON_THREE_NAME = getConfig('BUTTON_THREE_NAME')
BUTTON_THREE_URL = getConfig('BUTTON_THREE_URL')
if len(BUTTON_THREE_NAME) == 0 or len(BUTTON_THREE_URL) == 0:
raise KeyError
except KeyError:
BUTTON_THREE_NAME = None
BUTTON_THREE_URL = None
try:
BUTTON_FOUR_NAME = getConfig('BUTTON_FOUR_NAME')
BUTTON_FOUR_URL = getConfig('BUTTON_FOUR_URL')
if len(BUTTON_FOUR_NAME) == 0 or len(BUTTON_FOUR_URL) == 0:
raise KeyError
except KeyError:
BUTTON_FOUR_NAME = None
BUTTON_FOUR_URL = None
try:
BUTTON_FIVE_NAME = getConfig('BUTTON_FIVE_NAME')
BUTTON_FIVE_URL = getConfig('BUTTON_FIVE_URL')
if len(BUTTON_FIVE_NAME) == 0 or len(BUTTON_FIVE_URL) == 0:
raise KeyError
except KeyError:
BUTTON_FIVE_NAME = None
BUTTON_FIVE_URL = None
try:
IS_TEAM_DRIVE = getConfig('IS_TEAM_DRIVE')
if IS_TEAM_DRIVE.lower() == 'true':
Expand All @@ -144,7 +168,6 @@ def getConfig(name: str):
IS_TEAM_DRIVE = False
except KeyError:
IS_TEAM_DRIVE = False

try:
USE_SERVICE_ACCOUNTS = getConfig('USE_SERVICE_ACCOUNTS')
if USE_SERVICE_ACCOUNTS.lower() == 'true':
Expand All @@ -153,7 +176,6 @@ def getConfig(name: str):
USE_SERVICE_ACCOUNTS = False
except KeyError:
USE_SERVICE_ACCOUNTS = False

try:
BLOCK_MEGA_LINKS = getConfig('BLOCK_MEGA_LINKS')
if BLOCK_MEGA_LINKS.lower() == 'true':
Expand All @@ -162,7 +184,6 @@ def getConfig(name: str):
BLOCK_MEGA_LINKS = False
except KeyError:
BLOCK_MEGA_LINKS = False

try:
SHORTENER = getConfig('SHORTENER')
SHORTENER_API = getConfig('SHORTENER_API')
Expand Down
6 changes: 3 additions & 3 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def stats(update, context):
f'<b>Total disk space:</b> {total}\n' \
f'<b>Used:</b> {used} ' \
f'<b>Free:</b> {free}\n\n' \
f'<b>Data Usage</b>\n<b>Upload:</b> {sent}\n' \
f'📊Data Usage📊\n<b>Upload:</b> {sent}\n' \
f'<b>Down:</b> {recv}\n\n' \
f'<b>CPU:</b> {cpuUsage}%\n' \
f'<b>RAM:</b> {memory}%\n' \
f'<b>CPU:</b> {cpuUsage}% ' \
f'<b>RAM:</b> {memory}% ' \
f'<b>Disk:</b> {disk}%'
sendMessage(stats, context.bot, update)

Expand Down
30 changes: 21 additions & 9 deletions bot/helper/mirror_utils/upload_utils/gdriveTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from bot.helper.telegram_helper import button_build
from telegraph import Telegraph
from bot import parent_id, DOWNLOAD_DIR, IS_TEAM_DRIVE, INDEX_URL, \
USE_SERVICE_ACCOUNTS, download_dict, telegraph_token, SHORTENER, SHORTENER_API
USE_SERVICE_ACCOUNTS, download_dict, telegraph_token, BUTTON_THREE_NAME, BUTTON_THREE_URL, BUTTON_FOUR_NAME, BUTTON_FOUR_URL, BUTTON_FIVE_NAME, BUTTON_FIVE_URL, SHORTENER, SHORTENER_API
from bot.helper.ext_utils.bot_utils import *
from bot.helper.ext_utils.fs_utils import get_mime_type, get_path_size

Expand Down Expand Up @@ -322,26 +322,32 @@ def clone(self, link):
buttons = button_build.ButtonMaker()
if SHORTENER is not None and SHORTENER_API is not None:
surl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, durl)).text
buttons.buildbutton("Drive Link", surl)
buttons.buildbutton("Drive Link", surl)
else:
buttons.buildbutton("Drive Link", durl)
buttons.buildbutton("Drive Link", durl)
if INDEX_URL is not None:
url = requests.utils.requote_uri(f'{INDEX_URL}/{meta.get("name")}/')
if SHORTENER is not None and SHORTENER_API is not None:
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
buttons.buildbutton("Index Link", siurl)
buttons.buildbutton("Index Link", siurl)
else:
buttons.buildbutton("⚡Index Link⚡", url)
buttons.buildbutton("Index Link", url)
if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None:
buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}")
if BUTTON_FOUR_NAME is not None and BUTTON_FOUR_URL is not None:
buttons.buildbutton(f"{BUTTON_FOUR_NAME}", f"{BUTTON_FOUR_URL}")
if BUTTON_FIVE_NAME is not None and BUTTON_FIVE_URL is not None:
buttons.buildbutton(f"{BUTTON_FIVE_NAME}", f"{BUTTON_FIVE_URL}")
else:
file = self.copyFile(meta.get('id'), parent_id)
msg += f'<b>Filename : </b><code>{file.get("name")}</code>'
durl = self.__G_DRIVE_BASE_DOWNLOAD_URL.format(file.get("id"))
buttons = button_build.ButtonMaker()
if SHORTENER is not None and SHORTENER_API is not None:
surl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, durl)).text
buttons.buildbutton("Drive Link ", surl)
buttons.buildbutton("Drive Link ", surl)
else:
buttons.buildbutton("Drive Link", durl)
buttons.buildbutton("Drive Link", durl)
try:
msg += f'\n<b>Size : </b><code>{get_readable_file_size(int(meta.get("size")))}</code>'
except TypeError:
Expand All @@ -350,9 +356,15 @@ def clone(self, link):
url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}')
if SHORTENER is not None and SHORTENER_API is not None:
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text
buttons.buildbutton("Index Link", siurl)
buttons.buildbutton("Index Link", siurl)
else:
buttons.buildbutton("⚡Index Link⚡", url)
buttons.buildbutton("Index Link", url)
if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None:
buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}")
if BUTTON_FOUR_NAME is not None and BUTTON_FOUR_URL is not None:
buttons.buildbutton(f"{BUTTON_FOUR_NAME}", f"{BUTTON_FOUR_URL}")
if BUTTON_FIVE_NAME is not None and BUTTON_FIVE_URL is not None:
buttons.buildbutton(f"{BUTTON_FIVE_NAME}", f"{BUTTON_FIVE_URL}")
except Exception as err:
if isinstance(err, RetryError):
LOGGER.info(f"Total Attempts: {err.last_attempt.attempt_number}")
Expand Down
16 changes: 11 additions & 5 deletions bot/modules/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from telegram.ext import CommandHandler, run_async
from telegram import InlineKeyboardMarkup

from bot import Interval, INDEX_URL, BLOCK_MEGA_LINKS
from bot import Interval, INDEX_URL, BUTTON_THREE_NAME, BUTTON_THREE_URL, BUTTON_FOUR_NAME, BUTTON_FOUR_URL, BUTTON_FIVE_NAME, BUTTON_FIVE_URL, BLOCK_MEGA_LINKS
from bot import dispatcher, DOWNLOAD_DIR, DOWNLOAD_STATUS_UPDATE_INTERVAL, download_dict, download_dict_lock, SHORTENER, SHORTENER_API
from bot.helper.ext_utils import fs_utils, bot_utils
from bot.helper.ext_utils.bot_utils import setInterval
Expand Down Expand Up @@ -143,19 +143,25 @@ def onUploadComplete(self, link: str, size):
buttons = button_build.ButtonMaker()
if SHORTENER is not None and SHORTENER_API is not None:
surl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, link)).text
buttons.buildbutton("Drive Link", surl)
buttons.buildbutton("Drive Link", surl)
else:
buttons.buildbutton("Drive Link", link)
buttons.buildbutton("Drive Link", link)
LOGGER.info(f'Done Uploading {download_dict[self.uid].name()}')
if INDEX_URL is not None:
share_url = requests.utils.requote_uri(f'{INDEX_URL}/{download_dict[self.uid].name()}')
if os.path.isdir(f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}'):
share_url += '/'
if SHORTENER is not None and SHORTENER_API is not None:
siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, share_url)).text
buttons.buildbutton("Index Link", siurl)
buttons.buildbutton("Index Link", siurl)
else:
buttons.buildbutton("⚡Index Link⚡", share_url)
buttons.buildbutton("Index Link", share_url)
if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None:
buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}")
if BUTTON_FOUR_NAME is not None and BUTTON_FOUR_URL is not None:
buttons.buildbutton(f"{BUTTON_FOUR_NAME}", f"{BUTTON_FOUR_URL}")
if BUTTON_FIVE_NAME is not None and BUTTON_FIVE_URL is not None:
buttons.buildbutton(f"{BUTTON_FIVE_NAME}", f"{BUTTON_FIVE_URL}")
if self.message.from_user.username:
uname = f"@{self.message.from_user.username}"
else:
Expand Down
8 changes: 8 additions & 0 deletions config_sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ MEGA_PASSWORD = ""
BLOCK_MEGA_LINKS = ""
SHORTENER = ""
SHORTENER_API = ""
# Add more buttons (two buttons are already added of file link and index link, you can add extra buttons too, these are optional)
# If you don't know what are below entries, simply leave them, Don't fill anything in them.
BUTTON_THREE_NAME = ""
BUTTON_THREE_URL = ""
BUTTON_FOUR_NAME = ""
BUTTON_FOUR_URL = ""
BUTTON_FIVE_NAME = ""
BUTTON_FIVE_URL = ""

0 comments on commit 4d59931

Please sign in to comment.