V4.3 (#30)
- Fixed Zippyshare. Thanks to UsergeTeam, BianSepang, usmanmughalji - Update cloning log
This commit is contained in:
parent
101505752c
commit
227420d790
|
|
@ -26,7 +26,7 @@ python3 generate_drive_token.py
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
Fork this repo, than upload credentials.json and token.pickle to your forks
|
Fork this repo, than upload **token.pickle** to your forks
|
||||||
|
|
||||||
<p><a href="https://heroku.com/deploy"> <img src="https://www.herokucdn.com/deploy/button.svg" alt="Deploy to Heroku" /></a></p>
|
<p><a href="https://heroku.com/deploy"> <img src="https://www.herokucdn.com/deploy/button.svg" alt="Deploy to Heroku" /></a></p>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,30 +43,37 @@ def direct_link_generator(link: str):
|
||||||
else:
|
else:
|
||||||
raise DirectDownloadLinkException(f'No Direct link function found for {link}')
|
raise DirectDownloadLinkException(f'No Direct link function found for {link}')
|
||||||
|
|
||||||
|
""" Zippy-Share up-to-date plugin from https://github.com/UsergeTeam/Userge-Plugins/blob/master/plugins/zippyshare.py """
|
||||||
|
""" Thanks to all contributors @aryanvikash, rking32, @BianSepang """
|
||||||
|
|
||||||
|
link = r'https://www(\d{1,3}).zippyshare.com/v/(\w{8})/file.html'
|
||||||
|
regex_result = (
|
||||||
|
r'var a = (\d{6});\s+var b = (\d{6});\s+document\.getElementById'
|
||||||
|
r'\(\'dlbutton\'\).omg = "f";\s+if \(document.getElementById\(\''
|
||||||
|
r'dlbutton\'\).omg != \'f\'\) {\s+a = Math.ceil\(a/3\);\s+} else'
|
||||||
|
r' {\s+a = Math.floor\(a/3\);\s+}\s+document.getElementById\(\'d'
|
||||||
|
r'lbutton\'\).href = "/d/[a-zA-Z\d]{8}/\"\+\(a \+ \d{6}%b\)\+"/('
|
||||||
|
r'[\w%-.]+)";'
|
||||||
|
)
|
||||||
|
|
||||||
def zippy_share(url: str) -> str:
|
def zippy_share(url: str) -> str:
|
||||||
""" ZippyShare direct links generator
|
|
||||||
Based on https://github.com/LameLemon/ziggy"""
|
|
||||||
dl_url = ''
|
|
||||||
try:
|
|
||||||
link = re.findall(r'\bhttps?://.*zippyshare\.com\S+', url)[0]
|
|
||||||
except IndexError:
|
|
||||||
raise DirectDownloadLinkException("`No ZippyShare links found`\n")
|
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
base_url = re.search('http.+.com', link).group()
|
with session as ses:
|
||||||
response = session.get(link)
|
match = re.match(link, url)
|
||||||
page_soup = BeautifulSoup(response.content, "lxml")
|
if not match:
|
||||||
scripts = page_soup.find_all("script", {"type": "text/javascript"})
|
raise ValueError("Invalid URL: " + str(url))
|
||||||
for script in scripts:
|
server, id_ = match.group(1), match.group(2)
|
||||||
if "getElementById('dlbutton')" in script.text:
|
res = ses.get(url)
|
||||||
url_raw = re.search(r'= (?P<url>\".+\" \+ (?P<math>\(.+\)) .+);',
|
res.raise_for_status()
|
||||||
script.text).group('url')
|
match = re.search(regex_result, res.text, re.DOTALL)
|
||||||
math = re.search(r'= (?P<url>\".+\" \+ (?P<math>\(.+\)) .+);',
|
if not match:
|
||||||
script.text).group('math')
|
raise ValueError("Invalid Response!")
|
||||||
dl_url = url_raw.replace(math, '"' + str(eval(math)) + '"')
|
val_1 = int(match.group(1))
|
||||||
break
|
val_2 = math.floor(val_1 / 3)
|
||||||
dl_url = base_url + eval(dl_url)
|
val_3 = int(match.group(2))
|
||||||
name = urllib.parse.unquote(dl_url.split('/')[-1])
|
val = val_1 + val_2 % val_3
|
||||||
|
name = match.group(3)
|
||||||
|
dl_url = "https://www{}.zippyshare.com/d/{}/{}/{}".format(server, id_, val, name)
|
||||||
return dl_url
|
return dl_url
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,32 @@ from bot.helper.telegram_helper.message_utils import *
|
||||||
from bot.helper.telegram_helper.filters import CustomFilters
|
from bot.helper.telegram_helper.filters import CustomFilters
|
||||||
from bot.helper.telegram_helper.bot_commands import BotCommands
|
from bot.helper.telegram_helper.bot_commands import BotCommands
|
||||||
from bot.helper.ext_utils.bot_utils import new_thread
|
from bot.helper.ext_utils.bot_utils import new_thread
|
||||||
from bot import dispatcher
|
from bot import dispatcher, LOGGER
|
||||||
|
|
||||||
|
|
||||||
@new_thread
|
@new_thread
|
||||||
def cloneNode(update,context):
|
def cloneNode(update,context):
|
||||||
|
if update.message.from_user.last_name:
|
||||||
|
last_name = f" {update.message.from_user.last_name}"
|
||||||
|
else:
|
||||||
|
last_name = ""
|
||||||
|
if update.message.from_user.username:
|
||||||
|
username = f"@{update.message.from_user.username}"
|
||||||
|
else:
|
||||||
|
username = ""
|
||||||
|
name = f'<a href="tg://user?id={update.message.from_user.id}">{update.message.from_user.first_name}{last_name}</a>'
|
||||||
|
|
||||||
args = update.message.text.split(" ",maxsplit=1)
|
args = update.message.text.split(" ",maxsplit=1)
|
||||||
if len(args) > 1:
|
if len(args) > 1:
|
||||||
link = args[1]
|
link = args[1]
|
||||||
msg = sendMessage(f"Cloning: <code>{link}</code>",context.bot,update)
|
msg = f'Cloning...\n' \
|
||||||
|
f'User: {username}\n' \
|
||||||
|
f'Link: <a href="{link}">{link}</a>'
|
||||||
|
sendMessage(msg, context.bot, update)
|
||||||
gd = GoogleDriveHelper()
|
gd = GoogleDriveHelper()
|
||||||
result, button = gd.clone(link)
|
result, button = gd.clone(link)
|
||||||
deleteMessage(context.bot,msg)
|
LOGGER.info('ID: {} - Username: {} - Message: {}'.format(update.message.chat.id,update.message.chat.username,update.message.text))
|
||||||
|
# deleteMessage(context.bot,msg)
|
||||||
sendMarkup(result,context.bot,update,button)
|
sendMarkup(result,context.bot,update,button)
|
||||||
else:
|
else:
|
||||||
sendMessage("Provide G-Drive Shareable Link to Clone.",context.bot,update)
|
sendMessage("Provide G-Drive Shareable Link to Clone.",context.bot,update)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue