Skip to content

Commit

Permalink
V1.0.1-x
Browse files Browse the repository at this point in the history
> Remove POSTER var
> Remove GDTOT_CRYPT
> Remove API's
  • Loading branch information
weebzone committed Jun 16, 2023
1 parent ba9e30c commit 180932f
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 60 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ help - All cmds with description
- `SET_COMMANDS`: Automatically set the Bot Commands no need to set from `@botfather`. Default is `False`. `Bool`
- `FSUB_IDS`: Fill chat_id(-100xxxxxx) of groups/channel you want to force subscribe. Separate them by space. Int
- Note: Bot should be added in the filled chat_id as admin
- `BOT_PM`: File/links send to the BOT PM. Default is `False`. `Bool`
</details></li>
<li><details>
<summary><b>GDrive Tools</b></summary>
Expand Down Expand Up @@ -569,8 +570,6 @@ help - All cmds with description
- `IMAGES`: Add multiple telgraph(graph.org) image links that are seperated by spaces.
- `IMG_SEARCH`: Put Keyword to Download Images. Sperarte each name by , like `anime`, `iron man`, `god of war`
- `IMG_PAGE`: Set the page value for downloading a image. Each page have approx 70 images. Deafult is `1`. `Int`
- `POSTER`: Add Movie/Tv-Show poster. `Bool`
- `GDTOT_CRYPT`: Cookie for gdtot google drive link generator. This is `optional`
- `BOT_THEME`: Change the theme of bot. For now theme availabe is `minimal`.
- You can make your own theme checkout this link https://t.ly/9rVXq
</details></li>
Expand Down
11 changes: 1 addition & 10 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
def get_version():
MAJOR = '1'
MINOR = '0'
PATCH = '0'
PATCH = '1'
return f"v{MAJOR}.{MINOR}.{PATCH}-x"


Expand Down Expand Up @@ -394,10 +394,6 @@ def get_version():
DISABLE_DRIVE_LINK = environ.get('DISABLE_DRIVE_LINK', '')
DISABLE_DRIVE_LINK = DISABLE_DRIVE_LINK.lower() == 'true'

GDTOT_CRYPT = environ.get('GDTOT_CRYPT', '')
if len(GDTOT_CRYPT) == 0:
GDTOT_CRYPT = ''

BOT_THEME = environ.get('BOT_THEME', '')
if len(BOT_THEME) == 0:
BOT_THEME = 'minimal'
Expand Down Expand Up @@ -476,9 +472,6 @@ def get_version():
<b>Description</b>: <i>{description}</i>'''

POSTER = environ.get('POSTER', '')
POSTER = POSTER.lower() == 'true'

config_dict = {'ANIME_TEMPLATE': ANIME_TEMPLATE,
'AS_DOCUMENT': AS_DOCUMENT,
'AUTHORIZED_CHATS': AUTHORIZED_CHATS,
Expand Down Expand Up @@ -508,7 +501,6 @@ def get_version():
'LEECH_LOG_ID': LEECH_LOG_ID,
'BOT_PM': BOT_PM,
'DISABLE_DRIVE_LINK': DISABLE_DRIVE_LINK,
'GDTOT_CRYPT': GDTOT_CRYPT,
'BOT_THEME': BOT_THEME,
'IMAGES': IMAGES,
'IMG_SEARCH': IMG_SEARCH,
Expand All @@ -518,7 +510,6 @@ def get_version():
'AUTHOR_URL': AUTHOR_URL,
'TITLE_NAME': TITLE_NAME,
'GD_INFO': GD_INFO,
'POSTER': POSTER,
'EQUAL_SPLITS': EQUAL_SPLITS,
'EXTENSION_FILTER': EXTENSION_FILTER,
'GDRIVE_ID': GDRIVE_ID,
Expand Down
12 changes: 0 additions & 12 deletions bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,18 +586,6 @@ def extra_btns(buttons):
buttons.ubutton(btn_name, btn_url)
return buttons


async def poster(query):
api = "https://algorithms-routine-unavailable-writer.trycloudflare.com"
if config_dict['POSTER']:
try:
async with httpx.AsyncClient() as client:
res = await client.get(f"{api}/poster", params={"query": query})
data = res.json()
return data["url"]
except Exception as e:
LOGGER.info(f"An error occurred: {e}")

async def set_commands(client):
if config_dict['SET_COMMANDS']:
await client.set_bot_commands([
Expand Down
2 changes: 0 additions & 2 deletions bot/helper/ext_utils/help_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@
'AUTHOR_URL': 'Author URL for Telegraph page',
'TITLE_NAME': 'Title name for Telegraph pages (while using /list command)',
'GD_INFO': 'Description of file uploaded to gdrive using bot',
'POSTER': 'Add Movie/Tv-Show poster',
'BOT_THEME': 'Change the theme of bot. For now theme availabe is minimal. You can make your own theme checkout this link https://t.ly/9rVXq',
'GDTOT_CRYPT': 'Cookie for gdtot google drive link generator. This is optional',
'USER_MAX_TASKS': 'Limit the Maximum task for users of group at a time. use the Int',
'DAILY_TASK_LIMIT': 'Maximum task a user can do in one day. use the Int',
'DISABLE_DRIVE_LINK': 'Disable drive link button. Default is False. Bool',
Expand Down
8 changes: 2 additions & 6 deletions bot/helper/listeners/tasks_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from bot import Interval, aria2, DOWNLOAD_DIR, download_dict, download_dict_lock, LOGGER, bot_name, DATABASE_URL, \
MAX_SPLIT_SIZE, config_dict, status_reply_dict_lock, user_data, non_queued_up, non_queued_dl, queued_up, \
queued_dl, queue_dict_lock, bot, GLOBAL_EXTENSION_FILTER
from bot.helper.ext_utils.bot_utils import extra_btns, poster, sync_to_async, get_readable_file_size
from bot.helper.ext_utils.bot_utils import extra_btns, sync_to_async, get_readable_file_size
from bot.helper.ext_utils.fs_utils import get_base_name, get_path_size, clean_download, clean_target, \
is_first_archive_split, is_archive, is_archive_split, join_files
from bot.helper.ext_utils.leech_utils import split_file
Expand Down Expand Up @@ -344,15 +344,11 @@ async def onUploadComplete(self, link, size, files, folders, mime_type, name, rc
await DbManger().rm_complete_task(self.message.link)
user_id = self.message.from_user.id
user_dict = user_data.get(user_id, {})
poster_url = await poster(escape(name))
photo = self.random_pic
msg = BotTheme('NAME', Name=escape(name))
msg += BotTheme('SIZE', Size=get_readable_file_size(size))
LOGGER.info(f'Task Done: {name}')
buttons = ButtonMaker()
if poster_url:
photo = poster_url
else:
photo = self.random_pic
if self.isLeech:
msg += BotTheme('L_TOTAL_FILES', Files=folders)
if mime_type != 0:
Expand Down
101 changes: 85 additions & 16 deletions bot/helper/mirror_utils/download_utils/direct_link_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ def direct_link_generator(link: str):
elif any(x in domain for x in ['sbembed.com', 'watchsb.com', 'streamsb.net', 'sbplay.org']):
return sbembed(link)
elif is_share_link(link):
if 'gdtot' in domain or 'gdflix' in domain:
return gcloud(link)
if 'gdtot' in domain:
return gdtot(link)
elif 'filepress' in domain:
return filepress(link)
else:
return sharer_scraper(link)
elif 'zippyshare.com' in domain:
raise DirectDownloadLinkException('ERROR: R.I.P Zippyshare')
else:
Expand Down Expand Up @@ -551,22 +553,89 @@ def filepress(url):
return f'https://drive.google.com/uc?id={res["data"]}&export=download'


def gcloud(url):
api = "https://algorithms-routine-unavailable-writer.trycloudflare.com"
domain = urlparse(url).hostname
def gdtot(url):
cget = create_scraper().request
try:
if 'gdtot' in domain:
try:
res = requests.get(f"{api}/gdtot?url={url}")
except Exception as error:
res = requests.get(
f"{api}/gdtot?url={url}&crypt={config_dict['GDTOT_CRYPT']}")
elif 'gdflix' in domain:
res = requests.get(f"{api}/share?url={url}")
data = res.json()
return(data["drive_link"])
res = cget('GET', f'https://gdbot.xyz/file/{url.split("/")[-1]}')
except Exception as e:
raise DirectDownloadLinkException(f'ERROR: {e.__class__.__name__}')
token_url = etree.HTML(res.content).xpath(
"//a[contains(@class,'inline-flex items-center justify-center')]/@href")
if not token_url:
try:
url = cget('GET', url).url
p_url = urlparse(url)
res = cget(
"GET", f"{p_url.scheme}://{p_url.hostname}/ddl/{url.split('/')[-1]}")
except Exception as e:
raise DirectDownloadLinkException(f'ERROR: {e.__class__.__name__}')
if (drive_link := findall(r"myDl\('(.*?)'\)", res.text)) and "drive.google.com" in drive_link[0]:
return drive_link[0]
else:
raise DirectDownloadLinkException(
'ERROR: Drive Link not found, Try in your broswer')
token_url = token_url[0]
try:
token_page = cget('GET', token_url)
except Exception as e:
raise DirectDownloadLinkException(
f'ERROR: {e.__class__.__name__} with {token_url}')
path = findall('\("(.*?)"\)', token_page.text)
if not path:
raise DirectDownloadLinkException('ERROR: Cannot bypass this')
path = path[0]
raw = urlparse(token_url)
final_url = f'{raw.scheme}://{raw.hostname}{path}'
return sharer_scraper(final_url)


def sharer_scraper(url):
cget = create_scraper().request
try:
url = cget('GET', url).url
raw = urlparse(url)
header = {
"useragent": "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/7.0.548.0 Safari/534.10"}
res = cget('GET', url, headers=header)
except Exception as e:
raise DirectDownloadLinkException(f'ERROR: {e.__class__.__name__}')
key = findall('"key",\s+"(.*?)"', res.text)
if not key:
raise DirectDownloadLinkException("ERROR: Key not found!")
key = key[0]
if not etree.HTML(res.content).xpath("//button[@id='drc']"):
raise DirectDownloadLinkException(
"ERROR: This link don't have direct download button")
boundary = uuid4()
headers = {
'Content-Type': f'multipart/form-data; boundary=----WebKitFormBoundary{boundary}',
'x-token': raw.hostname,
'useragent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/7.0.548.0 Safari/534.10'
}

data = f'------WebKitFormBoundary{boundary}\r\nContent-Disposition: form-data; name="action"\r\n\r\ndirect\r\n' \
f'------WebKitFormBoundary{boundary}\r\nContent-Disposition: form-data; name="key"\r\n\r\n{key}\r\n' \
f'------WebKitFormBoundary{boundary}\r\nContent-Disposition: form-data; name="action_token"\r\n\r\n\r\n' \
f'------WebKitFormBoundary{boundary}--\r\n'
try:
res = cget("POST", url, cookies=res.cookies,
headers=headers, data=data).json()
except Exception as e:
raise DirectDownloadLinkException(f'ERROR: {e.__class__.__name__}')
if "url" not in res:
raise DirectDownloadLinkException(
'ERROR: Drive Link not found, Try in your broswer')
if "drive.google.com" in res["url"]:
return res["url"]
try:
res = cget('GET', res["url"])
except Exception as e:
LOGGER.info(f"An error occurred: {e}")
raise DirectDownloadLinkException(f'ERROR: {e.__class__.__name__}')
if (drive_link := etree.HTML(res.content).xpath("//a[contains(@class,'btn')]/@href")) and "drive.google.com" in drive_link[0]:
return drive_link[0]
else:
raise DirectDownloadLinkException(
'ERROR: Drive Link not found, Try in your broswer')

def wetransfer(url):
cget = create_scraper().request
Expand Down
11 changes: 1 addition & 10 deletions bot/modules/bot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
'TITLE_NAME': 'WeebZone-X',
'GD_INFO': 'Uploaded by WZML-X',
}
bool_vars = ['AS_DOCUMENT', 'BOT_PM', 'STOP_DUPLICATE', 'SET_COMMANDS', 'SAVE_MSG', 'POSTER',
bool_vars = ['AS_DOCUMENT', 'BOT_PM', 'STOP_DUPLICATE', 'SET_COMMANDS', 'SAVE_MSG',
'IS_TEAM_DRIVE', 'USE_SERVICE_ACCOUNTS', 'WEB_PINCODE', 'EQUAL_SPLITS', 'DISABLE_DRIVE_LINK']


Expand Down Expand Up @@ -356,10 +356,6 @@ async def load_config():
DISABLE_DRIVE_LINK = environ.get('DISABLE_DRIVE_LINK', '')
DISABLE_DRIVE_LINK = DISABLE_DRIVE_LINK.lower() == 'true'

GDTOT_CRYPT = environ.get('GDTOT_CRYPT', '')
if len(GDTOT_CRYPT) == 0:
GDTOT_CRYPT = ''

BOT_THEME = environ.get('BOT_THEME', '')
if len(BOT_THEME) == 0:
BOT_THEME = 'minimal'
Expand Down Expand Up @@ -437,9 +433,6 @@ async def load_config():
<b>Description</b>: <i>{description}</i>'''

POSTER = environ.get('POSTER', '')
POSTER = POSTER.lower() == 'true'

DRIVES_IDS.clear()
DRIVES_NAMES.clear()
INDEX_URLS.clear()
Expand Down Expand Up @@ -510,7 +503,6 @@ async def load_config():
'LEECH_LOG_ID': LEECH_LOG_ID,
'BOT_PM': BOT_PM,
'DISABLE_DRIVE_LINK': DISABLE_DRIVE_LINK,
'GDTOT_CRYPT': GDTOT_CRYPT,
'BOT_THEME': BOT_THEME,
'IMAGES': IMAGES,
'IMG_SEARCH': IMG_SEARCH,
Expand All @@ -520,7 +512,6 @@ async def load_config():
'AUTHOR_URL': AUTHOR_URL,
'TITLE_NAME': TITLE_NAME,
'GD_INFO': GD_INFO,
'POSTER': POSTER,
'EQUAL_SPLITS': EQUAL_SPLITS,
'EXTENSION_FILTER': EXTENSION_FILTER,
'GDRIVE_ID': GDRIVE_ID,
Expand Down
3 changes: 1 addition & 2 deletions config_sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ USE_SERVICE_ACCOUNTS = "False"
SAVE_MSG = "False"
SET_COMMANDS = "False"
FSUB_IDS = ""
BOT_PM = ""

# GDrive Tools
GDRIVE_ID = ""
Expand Down Expand Up @@ -107,8 +108,6 @@ AUTHOR_URL = "https://t.me/WZML_X"
IMAGES = ""
IMG_SEARCH = ""
IMG_PAGE = ""
POSTER = ""
GDTOT_CRYPT = "" # OPTIONAL
BOT_THEME = "minimal"

# Token system
Expand Down

0 comments on commit 180932f

Please sign in to comment.