Skip to content

Commit

Permalink
Test bring back gdtot
Browse files Browse the repository at this point in the history
  • Loading branch information
vincreator committed Aug 31, 2022
1 parent 8f82511 commit 6ed4bd7
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 53 deletions.
162 changes: 124 additions & 38 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def getConfig(name: str):
with open('.netrc', 'wb+') as f:
f.write(res.content)
else:
log_error(f"Failed to download .netrc {res.status_code}")
log_error(f'Failed to download .netrc {res.status_code}')
except Exception as e:
log_error(f"NETRC_URL: {e}")
log_error(f'NETRC_URL: {e}')
except:
pass
try:
Expand All @@ -55,14 +55,14 @@ def getConfig(name: str):
except:
SERVER_PORT = 80

Popen(f"gunicorn web.wserver:app --bind 0.0.0.0:{SERVER_PORT}", shell=True)
srun(["qbittorrent-nox", "-d", "--profile=."])
Popen(f'gunicorn web.wserver:app --bind 0.0.0.0:{SERVER_PORT}', shell=True)
srun(['qbittorrent-nox', '-d', '--profile=.'])
if not ospath.exists('.netrc'):
srun(["touch", ".netrc"])
srun(["cp", ".netrc", "/root/.netrc"])
srun(["chmod", "600", ".netrc"])
srun(["chmod", "+x", "aria.sh"])
srun("./aria.sh", shell=True)
srun(['touch', '.netrc'])
srun(['cp', '.netrc', '/root/.netrc'])
srun(['chmod', '600', '.netrc'])
srun(['chmod', '+x', 'aria.sh'])
srun('./aria.sh', shell=True)
sleep(0.5)

Interval = []
Expand All @@ -79,14 +79,14 @@ def getConfig(name: str):

aria2 = ariaAPI(
ariaClient(
host="http://localhost",
host='http://localhost',
port=6800,
secret="",
secret='',
)
)

def get_client():
return qbClient(host="localhost", port=8090)
return qbClient(host='localhost', port=8090)

DOWNLOAD_DIR = None
BOT_TOKEN = None
Expand All @@ -113,15 +113,15 @@ def get_client():
BOT_TOKEN = getConfig('BOT_TOKEN')
parent_id = getConfig('GDRIVE_FOLDER_ID')
DOWNLOAD_DIR = getConfig('DOWNLOAD_DIR')
if not DOWNLOAD_DIR.endswith("/"):
if not DOWNLOAD_DIR.endswith('/'):
DOWNLOAD_DIR = DOWNLOAD_DIR + '/'
DOWNLOAD_STATUS_UPDATE_INTERVAL = int(getConfig('DOWNLOAD_STATUS_UPDATE_INTERVAL'))
OWNER_ID = int(getConfig('OWNER_ID'))
AUTO_DELETE_MESSAGE_DURATION = int(getConfig('AUTO_DELETE_MESSAGE_DURATION'))
TELEGRAM_API = getConfig('TELEGRAM_API')
TELEGRAM_HASH = getConfig('TELEGRAM_HASH')
except:
log_error("One or more env variables missing! Exiting now")
log_error('One or more env variables missing! Exiting now')
exit(1)

try:
Expand Down Expand Up @@ -152,39 +152,125 @@ def get_client():
USER_SESSION_STRING = getConfig('USER_SESSION_STRING')
if len(USER_SESSION_STRING) == 0:
raise KeyError
log_info("Creating client from USER_SESSION_STRING")
log_info('Creating client from USER_SESSION_STRING')
app = Client(name='pyrogram', api_id=int(TELEGRAM_API), api_hash=TELEGRAM_HASH, session_string=USER_SESSION_STRING, parse_mode=enums.ParseMode.HTML, no_updates=True)
with app:
IS_PREMIUM_USER = app.me.is_premium
except:
log_info("Creating client from BOT_TOKEN")
log_info('Creating client from BOT_TOKEN')
app = Client(name='pyrogram', api_id=int(TELEGRAM_API), api_hash=TELEGRAM_HASH, bot_token=BOT_TOKEN, parse_mode=enums.ParseMode.HTML, no_updates=True)

try:
RSS_USER_SESSION_STRING = getConfig('RSS_USER_SESSION_STRING')
if len(RSS_USER_SESSION_STRING) == 0:
raise KeyError
log_info("Creating client from RSS_USER_SESSION_STRING")
log_info('Creating client from RSS_USER_SESSION_STRING')
rss_session = Client(name='rss_session', api_id=int(TELEGRAM_API), api_hash=TELEGRAM_HASH, session_string=RSS_USER_SESSION_STRING, parse_mode=enums.ParseMode.HTML, no_updates=True)
except:
rss_session = None

def aria2c_init():
try:
log_info("Initializing Aria2c")
link = "https://linuxmint.com/torrents/lmde-5-cinnamon-64bit.iso.torrent"
dire = DOWNLOAD_DIR.rstrip("/")
log_info('Initializing Aria2c')
link = 'https://linuxmint.com/torrents/lmde-5-cinnamon-64bit.iso.torrent'
dire = DOWNLOAD_DIR.rstrip('/')
aria2.add_uris([link], {'dir': dire})
sleep(3)
downloads = aria2.get_downloads()
sleep(20)
for download in downloads:
aria2.remove([download], force=True, files=True)
except Exception as e:
log_error(f"Aria2c initializing error: {e}")
log_error(f'Aria2c initializing error: {e}')
Thread(target=aria2c_init).start()
sleep(1.5)

try:
GDTOT_CRYPT = getConfig('GDTOT_CRYPT')
if len(GDTOT_CRYPT) == 0:
raise KeyError
except KeyError:
GDTOT_CRYPT = None
try:
APPDRIVE_EMAIL = getConfig('APPDRIVE_EMAIL')
APPDRIVE_PASS = getConfig('APPDRIVE_PASS')
if len(APPDRIVE_EMAIL) == 0 or len(APPDRIVE_PASS) == 0:
raise KeyError
except KeyError:
APPDRIVE_EMAIL = None
APPDRIVE_PASS = None
try:
HUBD_CRYPT = getConfig('HUBD_CRYPT')
if len(HUBD_CRYPT) == 0:
log_warning('HubDrive Crypt not provided!')
raise KeyError
except KeyError:
HUBD_CRYPT = None

try:
Sharerpw_XSRF = getConfig('Sharerpw_XSRF')
if len(Sharerpw_XSRF) == 0:
log_warning('Sharerpw XSRF Token not provided!')
raise KeyError
except KeyError:
Sharerpw_XSRF = None

try:
Sharerpw_laravel = getConfig('Sharerpw_laravel')
if len(Sharerpw_laravel) == 0:
log_warning('Sharerpw Laravel Session not provided!')
raise KeyError
except KeyError:
Sharerpw_laravel = None

try:
DB_CRYPT = getConfig('DB_CRYPT')
if len(DB_CRYPT) == 0:
log_warning('DriveBuzz Crypt not provided!')
raise KeyError
except KeyError:
DB_CRYPT = None

try:
kolop_CRYPT = getConfig('kolop_CRYPT')
if len(kolop_CRYPT) == 0:
log_warning('Kolop Crypt not provided!')
raise KeyError
except KeyError:
kolop_CRYPT = None

try:
katdrive_CRYPT = getConfig('katdrive_CRYPT')
if len(katdrive_CRYPT) == 0:
log_warning('KatDrive Crypt not provided!')
raise KeyError
except KeyError:
katdrive_CRYPT = None

try:
drivefire_CRYPT = getConfig('drivefire_CRYPT')
if len(drivefire_CRYPT) == 0:
log_warning('DriveFire Crypt not provided!')
raise KeyError
except KeyError:
drivefire_CRYPT = None

try:
gadrive_CRYPT = getConfig('gadrive_CRYPT')
if len(gadrive_CRYPT) == 0:
log_warning('GaDrive Crypt not provided!')
raise KeyError
except KeyError:
gadrive_CRYPT = None

try:
jiodrive_CRYPT = getConfig('jiodrive_CRYPT')
if len(jiodrive_CRYPT) == 0:
log_warning('JioDrive Crypt not provided!')
raise KeyError
except KeyError:
jiodrive_CRYPT = None

try:
MEGA_API_KEY = getConfig('MEGA_API_KEY')
if len(MEGA_API_KEY) == 0:
Expand Down Expand Up @@ -238,15 +324,15 @@ def aria2c_init():
except:
UPTOBOX_TOKEN = None
try:
INDEX_URL = getConfig('INDEX_URL').rstrip("/")
INDEX_URL = getConfig('INDEX_URL').rstrip('/')
if len(INDEX_URL) == 0:
raise KeyError
INDEX_URLS.append(INDEX_URL)
except:
INDEX_URL = None
INDEX_URLS.append(None)
try:
SEARCH_API_LINK = getConfig('SEARCH_API_LINK').rstrip("/")
SEARCH_API_LINK = getConfig('SEARCH_API_LINK').rstrip('/')
if len(SEARCH_API_LINK) == 0:
raise KeyError
except:
Expand Down Expand Up @@ -322,12 +408,12 @@ def aria2c_init():
except:
WEB_PINCODE = False
try:
IGNORE_PENDING_REQUESTS = getConfig("IGNORE_PENDING_REQUESTS")
IGNORE_PENDING_REQUESTS = getConfig('IGNORE_PENDING_REQUESTS')
IGNORE_PENDING_REQUESTS = IGNORE_PENDING_REQUESTS.lower() == 'true'
except:
IGNORE_PENDING_REQUESTS = False
try:
BASE_URL = getConfig('BASE_URL_OF_BOT').rstrip("/")
BASE_URL = getConfig('BASE_URL_OF_BOT').rstrip('/')
if len(BASE_URL) == 0:
raise KeyError
except:
Expand Down Expand Up @@ -359,9 +445,9 @@ def aria2c_init():
with open('token.pickle', 'wb+') as f:
f.write(res.content)
else:
log_error(f"Failed to download token.pickle, link got HTTP response: {res.status_code}")
log_error(f'Failed to download token.pickle, link got HTTP response: {res.status_code}')
except Exception as e:
log_error(f"TOKEN_PICKLE_URL: {e}")
log_error(f'TOKEN_PICKLE_URL: {e}')
except:
pass
try:
Expand All @@ -374,13 +460,13 @@ def aria2c_init():
with open('accounts.zip', 'wb+') as f:
f.write(res.content)
else:
log_error(f"Failed to download accounts.zip, link got HTTP response: {res.status_code}")
log_error(f'Failed to download accounts.zip, link got HTTP response: {res.status_code}')
except Exception as e:
log_error(f"ACCOUNTS_ZIP_URL: {e}")
log_error(f'ACCOUNTS_ZIP_URL: {e}')
raise KeyError
srun(["unzip", "-q", "-o", "accounts.zip"])
srun(["chmod", "-R", "777", "accounts"])
osremove("accounts.zip")
srun(['unzip', '-q', '-o', 'accounts.zip'])
srun(['chmod', '-R', '777', 'accounts'])
osremove('accounts.zip')
except:
pass
try:
Expand All @@ -393,9 +479,9 @@ def aria2c_init():
with open('drive_folder', 'wb+') as f:
f.write(res.content)
else:
log_error(f"Failed to download drive_folder, link got HTTP response: {res.status_code}")
log_error(f'Failed to download drive_folder, link got HTTP response: {res.status_code}')
except Exception as e:
log_error(f"MULTI_SEARCH_URL: {e}")
log_error(f'MULTI_SEARCH_URL: {e}')
except:
pass
try:
Expand All @@ -408,13 +494,13 @@ def aria2c_init():
with open('cookies.txt', 'wb+') as f:
f.write(res.content)
else:
log_error(f"Failed to download cookies.txt, link got HTTP response: {res.status_code}")
log_error(f'Failed to download cookies.txt, link got HTTP response: {res.status_code}')
except Exception as e:
log_error(f"YT_COOKIES_URL: {e}")
log_error(f'YT_COOKIES_URL: {e}')
except:
pass

DRIVES_NAMES.append("Main")
DRIVES_NAMES.append('Main')
DRIVES_IDS.append(parent_id)
if ospath.exists('drive_folder'):
with open('drive_folder', 'r+') as f:
Expand All @@ -423,7 +509,7 @@ def aria2c_init():
try:
temp = line.strip().split()
DRIVES_IDS.append(temp[1])
DRIVES_NAMES.append(temp[0].replace("_", " "))
DRIVES_NAMES.append(temp[0].replace('_', ' '))
except:
pass
try:
Expand Down
4 changes: 2 additions & 2 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def log(update, context):
/{BotCommands.QbUnzipLeechCommand[0]} atau /{BotCommands.QbUnzipLeechCommand[1]}: Mulai leeching menggunakan qBittorrent dan unggah file/folder yang diekstrak dari ekstensi arsip apa pun.
/{BotCommands.YtdlLeechCommand[0]} atau /{BotCommands.YtdlLeechCommand[1]}: Tautan yang didukung Leech yt-dlp.
/{BotCommands.YtdlZipLeechCommand[0]} atau /{BotCommands.YtdlZipLeechCommand[1]}: Lintah yt-dlp mendukung tautan sebagai zip.
/{BotCommands.CloneCommand} [drive_url]: Salin file/folder ke Google Drive.
/{BotCommands.CountCommand} [drive_url]: Menghitung file/folder Google Drive.
/{BotCommands.CloneCommand} [drive_url][gdtot_url]: Salin file/folder ke Google Drive.
/{BotCommands.CountCommand} [drive_url][gdtot_url]: Menghitung file/folder Google Drive.
/{BotCommands.DeleteCommand} [drive_url]: Menghapus file/folder dari Google Drive (Hanya Pemilik & Sudo).
/{BotCommands.LeechSetCommand} [permintaan]: Setelan lintah.
/{BotCommands.SetThumbCommand}: Balas foto untuk mengaturnya sebagai Thumbnail.
Expand Down
6 changes: 5 additions & 1 deletion bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from re import findall as re_findall
from re import findall as re_findall, match as re_match
from threading import Thread, Event
from time import time
from math import ceil
Expand Down Expand Up @@ -227,6 +227,10 @@ def is_url(url: str):
def is_gdrive_link(url: str):
return "drive.google.com" in url

def is_gdtot_link(url: str):
url = re_match(r'https?://.+\.gdtot\.\S+', url)
return bool(url)

def is_mega_link(url: str):
return "mega.nz" in url or "mega.co.nz" in url

Expand Down
Loading

0 comments on commit 6ed4bd7

Please sign in to comment.