Skip to content

Commit

Permalink
Update V4.2.0
Browse files Browse the repository at this point in the history
- Added More Scrapper skymovieshd.boats, animekaizoku.com, moviesmod.com
- Added ouo scrape on DDL
- New UI on User Settings
- Added Suffix, Prefix, Remname on Mirror/Clone
- Minor Fix & Stable

Co-authored-by: Karan Adhikari <[email protected]>
  • Loading branch information
SilentDemonSD and weebzone authored Dec 6, 2022
1 parent 68a88e2 commit d5b8eea
Show file tree
Hide file tree
Showing 21 changed files with 651 additions and 670 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
RUN apt-get update && apt-get upgrade -y
RUN apt -qq update --fix-missing && \
apt -qq install -y \
mediainfo
apt -qq install -y mediainfo

COPY . .

Expand Down
6 changes: 4 additions & 2 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

LOGGER = getLogger(__name__)

TIME_GAP_STORE = {}

load_dotenv('config.env', override=True)

Interval = []
Expand All @@ -42,6 +40,7 @@
user_data = {}
aria2_options = {}
qbit_options = {}
TIME_GAP_STORE = {}
GLOBAL_EXTENSION_FILTER = ['.aria2']

try:
Expand Down Expand Up @@ -477,6 +476,9 @@
if len(SHORTENER) == 0 or len(SHORTENER_API) == 0:
SHORTENER = ''
SHORTENER_API = ''
SHORTENER = (SHORTENER.replace("'", '').replace('"', '').replace('[', '').replace(']', '').replace(",", "")).split()
SHORTENER_API = (SHORTENER_API.replace("'", '').replace('"', '').replace('[', '').replace(']', '').replace(",", "")).split()


UNIFIED_EMAIL = environ.get('UNIFIED_EMAIL', '')
if len(UNIFIED_EMAIL) == 0:
Expand Down
30 changes: 17 additions & 13 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ def bot_help(update, context):

def main():

version = "4.1.75"

if config_dict['WALLCRAFT_CATEGORY']:
for page in range(1,20):
r2 = rget(f"https://wallpaperscraft.com/catalog/{config_dict['WALLCRAFT_CATEGORY']}/1280x720/page{page}")
Expand Down Expand Up @@ -422,22 +424,20 @@ def main():
if ospath.isfile(".restartmsg"):
with open(".restartmsg") as f:
chat_id, msg_id = map(int, f)
msg = f"😎Restarted successfully❗\n"
msg += f"📅DATE: {date}\n"
msg += f"⌚TIME: {time}\n"
msg += f"🌐TIMEZONE: {timez}\n"
msg = f"😎 Restarted Successfully❗\n"
else:
msg = f"😎Bot Restarted!\n"
msg += f"📅DATE: {date}\n"
msg += f"⌚TIME: {time}\n"
msg += f"🌐TIMEZONE: {timez}"
msg = f"😎 Bot Restarted!\n"
msg += f"📅 DATE: {date}\n"
msg += f"⌚ TIME: {time}\n"
msg += f"🌐 TIMEZONE: {timez}\n"
msg += f"🤖 VERSION: {version}"

for tag, links in data.items():
msg += f"\n{tag}: "
for index, link in enumerate(links, start=1):
msg += f" <a href='{link}'>{index}</a> |"
if len(msg.encode()) > 4000:
if '😎Restarted successfully❗' in msg and cid == chat_id:
if '😎 Restarted Successfully❗' in msg and cid == chat_id:
try:
bot.editMessageText(msg, chat_id, msg_id, parse_mode='HTML', disable_web_page_preview=True)
except:
Expand All @@ -449,7 +449,7 @@ def main():
except Exception as e:
LOGGER.error(e)
msg = ''
if '😎Restarted successfully❗' in msg and cid == chat_id:
if '😎 Restarted Successfully❗' in msg and cid == chat_id:
try:
bot.editMessageText(msg, chat_id, msg_id, parse_mode='HTML', disable_web_page_preview=True)
except:
Expand All @@ -465,10 +465,14 @@ def main():
with open(".restartmsg") as f:
chat_id, msg_id = map(int, f)
try:
msg = f"😎Restarted successfully❗\n📅DATE: {date}\n⌚TIME: {time}\n🌐TIMEZONE: {timez}\n"
msg = f"😎 Restarted Successfully❗\n"
msg += f"📅 DATE: {date}\n"
msg += f"⌚ TIME: {time}\n"
msg += f"🌐 TIMEZONE: {timez}\n"
msg += f"🤖 VERSION: {version}"
bot.edit_message_text(msg, chat_id, msg_id)
except:
pass
except Exception as e:
LOGGER.info(e)
osremove(".restartmsg")


Expand Down
82 changes: 81 additions & 1 deletion bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from re import match as re_match, findall as re_findall
from os import path as ospath, rename as osrename
from threading import Thread, Event
from time import time
from datetime import datetime
Expand Down Expand Up @@ -443,6 +444,85 @@ def get_content_type(link: str) -> str:
content_type = None
return content_type

def change_filename(file_, user_id_, dirpath=None, up_path=None, all_edit=True, mirror_type=False):
user_dict = user_data.get(user_id_, False)
if mirror_type:
PREFIX = user_dict.get('mprefix') if user_dict and user_dict.get('mprefix') else ''
REMNAME = user_dict.get('mremname') if user_dict and user_dict.get('mremname') else ''
SUFFIX = user_dict.get('msuffix') if user_dict and user_dict.get('msuffix') else ''
else:
PREFIX = user_dict.get('prefix') if user_dict and user_dict.get('prefix') else ''
REMNAME = user_dict.get('remname') if user_dict and user_dict.get('remname') else ''
SUFFIX = user_dict.get('suffix') if user_dict and user_dict.get('suffix') else ''

FSTYLE = user_dict.get('cfont')[1] if user_dict and user_dict.get('cfont') else ''
CAPTION = user_dict.get('caption') if user_dict and user_dict.get('caption') else ''

#MysteryStyle ~ Tele-LeechX
if file_.startswith('www'):
file_ = ' '.join(file_.split()[1:])
if REMNAME:
if not REMNAME.startswith('|'):
REMNAME = f"|{REMNAME}"
slit = REMNAME.split("|")
__newFileName = file_
for rep in range(1, len(slit)):
args = slit[rep].split(":")
if len(args) == 3:
__newFileName = __newFileName.replace(args[0], args[1], int(args[2]))
elif len(args) == 2:
__newFileName = __newFileName.replace(args[0], args[1])
elif len(args) == 1:
__newFileName = __newFileName.replace(args[0], '')
file_ = __newFileName
LOGGER.info("Remname : "+file_)
if PREFIX:
if not file_.startswith(PREFIX):
file_ = f"{PREFIX}{file_}"
if SUFFIX and not mirror_type:
sufLen = len(SUFFIX)
fileDict = file_.split('.')
_extIn = 1 + len(fileDict[-1])
_extOutName = '.'.join(fileDict[:-1]).replace('.', ' ').replace('-', ' ')
_newExtFileName = f"{_extOutName}{SUFFIX}.{fileDict[-1]}"
if len(_extOutName) > (64 - (sufLen + _extIn)):
_newExtFileName = (
_extOutName[: 64 - (sufLen + _extIn)]
+ f"{SUFFIX}.{fileDict[-1]}"
)
file_ = _newExtFileName
elif SUFFIX:
file_ = f"{ospath.splitext(file_)[0]}{SUFFIX}{ospath.splitext(file_)[1]}"

if (PREFIX or REMNAME or SUFFIX) and all_edit:
new_path = ospath.join(dirpath, file_)
osrename(up_path, new_path)
up_path = new_path

cap_mono = ""
cfont = config_dict['CAPTION_FONT'] if not FSTYLE else FSTYLE
if CAPTION and all_edit:
CAPTION = CAPTION.replace('\|', '%%')
slit = CAPTION.split("|")
cap_mono = slit[0].format(
filename = file_,
size = get_readable_file_size(ospath.getsize(up_path))
)
if len(slit) > 1:
for rep in range(1, len(slit)):
args = slit[rep].split(":")
if len(args) == 3:
cap_mono = cap_mono.replace(args[0], args[1], int(args[2]))
elif len(args) == 2:
cap_mono = cap_mono.replace(args[0], args[1])
elif len(args) == 1:
cap_mono = cap_mono.replace(args[0], '')
cap_mono = cap_mono.replace('%%', '|')
elif all_edit:
cap_mono = file_ if FSTYLE == 'r' else f"<{cfont}>{file_}</{cfont}>"

return up_path, file_, cap_mono

def update_user_ldata(id_, key, value):
if id_ in user_data:
user_data[id_][key] = value
Expand All @@ -462,7 +542,7 @@ def is_paid(user_id):
ndate = datetime.today()
if odate.year <= ndate.year:
if odate.month <= ndate.month:
if odate.day <= ndate.day:
if odate.day < ndate.day:
return False
return True
else: return False
Expand Down
16 changes: 6 additions & 10 deletions bot/helper/ext_utils/shortenurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@

from bot import LOGGER, config_dict

LSHORTENER_API = config_dict['SHORTENER_API'].split(' ')
LSHORTENER = config_dict['SHORTENER'].split(' ')
def short_url(longurl):
if len(LSHORTENER) == 0 and len(LSHORTENER_API) == 0:
return longurl
SHORTENER = choice(LSHORTENER)
ind = LSHORTENER.index(SHORTENER)
try:
SHORTENER_API = LSHORTENER_API[ind]
except IndexError:
LOGGER.error(f"{SHORTENER}'s API Key Not Found")
API_LIST = config_dict['SHORTENER_API']
SHORT_LIST = config_dict['SHORTENER']
if len(SHORT_LIST) == 0 and len(API_LIST) == 0:
return longurl
SHORTENER = choice(SHORT_LIST)
try: SHORTENER_API = API_LIST[SHORT_LIST.index(SHORTENER)]
except IndexError: LOGGER.error(f"{SHORTENER}'s API Key Not Found"); return longurl
try:
cget = create_scraper().get
try:
Expand Down
81 changes: 28 additions & 53 deletions bot/helper/mirror_utils/download_utils/aria2_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,66 +54,41 @@ def __onDownloadStarted(api, gid):
except:
sname = None
if sname is not None:
if config_dict['TELEGRAPH_STYLE']:
smsg, button = GoogleDriveHelper().drive_list(sname, True)
if smsg:
listener.onDownloadError('Someone already mirrored it for you !\n\n')
api.remove([download], force=True, files=True)
return sendMarkup("Here you go:", listener.bot, listener.message, button)
else:
cap, f_name = GoogleDriveHelper().drive_list(sname, True)
if cap:
listener.onDownloadError('File/Folder already available in Drive.')
api.remove([download], force=True, files=True)
cap = f"Here are the search results:\n\n{cap}"
sendFile(listener.bot, listener.message, f_name, cap)
return
smsg, button = GoogleDriveHelper().drive_list(sname, True)
if smsg:
listener.onDownloadError("File/Folder is already available in Drive.")
api.remove([download], force=True, files=True)
if config_dict['TELEGRAPH_STYLE']:
return sendMarkup("Here are the search results:", listener.bot, listener.message, button)
else:
return sendFile(listener.bot, listener.message, f_name, f"Here are the search results:\n\n{smsg}")

user_id = listener.message.from_user.id
if any([ZIP_UNZIP_LIMIT, LEECH_LIMIT, TORRENT_DIRECT_LIMIT, STORAGE_THRESHOLD]) and user_id != OWNER_ID and not is_sudo(user_id) and not is_paid(user_id):
sleep(1)
limit = None
size = download.total_length
arch = any([listener.isZip, listener.isLeech, listener.extract])
if config_dict['PAID_SERVICE']:
if STORAGE_THRESHOLD is not None:
acpt = check_storage_threshold(size, arch, True)
# True if files allocated, if allocation disabled remove True arg
if not acpt:
msg = f'You must leave {STORAGE_THRESHOLD}GB free storage.'
msg += f'\nYour File/Folder size is {get_readable_file_size(size)}'
if STORAGE_THRESHOLD is not None:
acpt = check_storage_threshold(size, arch, True)
if not acpt:
msg = f'You must leave {STORAGE_THRESHOLD}GB free storage.'
msg += f'\nYour File/Folder size is {get_readable_file_size(size)}'
if config_dict['PAID_SERVICE'] is True:
msg += f'\n#Buy Paid Service'
listener.onDownloadError(msg)
return api.remove([download], force=True, files=True)
if ZIP_UNZIP_LIMIT is not None and arch:
mssg = f'Zip/Unzip limit is {ZIP_UNZIP_LIMIT}GB'
mssg += f'\n#Buy Paid Service'
limit = ZIP_UNZIP_LIMIT
if LEECH_LIMIT is not None and arch:
mssg = f'Leech limit is {LEECH_LIMIT}GB'
mssg += f'\n#Buy Paid Service'
limit = LEECH_LIMIT
elif TORRENT_DIRECT_LIMIT is not None:
mssg = f'Torrent/Direct limit is {TORRENT_DIRECT_LIMIT}GB'
mssg += f'\n#Buy Paid Service'
limit = TORRENT_DIRECT_LIMIT
else:
if STORAGE_THRESHOLD is not None:
acpt = check_storage_threshold(size, arch, True)
# True if files allocated, if allocation disabled remove True arg
if not acpt:
msg = f'You must leave {STORAGE_THRESHOLD}GB free storage.'
msg += f'\nYour File/Folder size is {get_readable_file_size(size)}'
listener.onDownloadError(msg)
return api.remove([download], force=True, files=True)
if ZIP_UNZIP_LIMIT is not None and arch:
mssg = f'Zip/Unzip limit is {ZIP_UNZIP_LIMIT}GB'
limit = ZIP_UNZIP_LIMIT
if LEECH_LIMIT is not None and arch:
mssg = f'Leech limit is {LEECH_LIMIT}GB'
limit = LEECH_LIMIT
elif TORRENT_DIRECT_LIMIT is not None:
mssg = f'Torrent/Direct limit is {TORRENT_DIRECT_LIMIT}GB'
limit = TORRENT_DIRECT_LIMIT
listener.onDownloadError(msg)
return api.remove([download], force=True, files=True)
if ZIP_UNZIP_LIMIT is not None and arch:
mssg = f'Zip/Unzip limit is {ZIP_UNZIP_LIMIT}GB'
limit = ZIP_UNZIP_LIMIT
if LEECH_LIMIT is not None and arch:
mssg = f'Leech limit is {LEECH_LIMIT}GB'
limit = LEECH_LIMIT
elif TORRENT_DIRECT_LIMIT is not None:
mssg = f'Torrent/Direct limit is {TORRENT_DIRECT_LIMIT}GB'
limit = TORRENT_DIRECT_LIMIT
if config_dict['PAID_SERVICE'] is True:
mssg += f'\n#Buy Paid Service'
if limit is not None:
LOGGER.info('Checking File/Folder Size...')
if size > limit * 1024**3:
Expand Down
Loading

0 comments on commit d5b8eea

Please sign in to comment.