Skip to content

Commit

Permalink
Merge pull request X-Gorn#8 from X-Gorn/master-update
Browse files Browse the repository at this point in the history
Added Mediafire, Zippyshare, Hxfile, Anonfiles, Antfiles URL Support using LK21
  • Loading branch information
X-Gorn authored Jul 30, 2021
2 parents 7177fb6 + 1a78310 commit b919bda
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 12 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Telegram RoBot to Upload Links.

👉 Upload HTTP/HTTPS as File/Video to Telegram.

👉 Upload Mediafire, Zippyshare, Hxfile, Anonfiles, Antfiles URL using LK21

**For Devs**:

👉 [X-URL-Uploader-dev](https://github.com/X-Gorn/X-URL-Uploader/tree/dev)
Expand Down
98 changes: 88 additions & 10 deletions plugins/youtube_dl_echo.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Shrimadhav U K
# (c) Shrimadhav U K | X-Noid

# the logging things
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)

import asyncio
import json
import math
import os
import time
import lk21, urllib.parse, filetype, shutil, time, tldextract, asyncio, json, math, os, requests
from PIL import Image
# the secret configuration specific things
if bool(os.environ.get("WEBHOOK", False)):
Expand All @@ -25,12 +20,14 @@

import pyrogram
logging.getLogger("pyrogram").setLevel(logging.WARNING)

from helper_funcs.display_progress import humanbytes
from helper_funcs.help_uploadbot import DownLoadFile

from helper_funcs.display_progress import progress_for_pyrogram
from hachoir.metadata import extractMetadata
from hachoir.parser import createParser
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from pyrogram.errors import UserNotParticipant, UserBannedInChannel
from pyrogram.errors import UserNotParticipant


@pyrogram.Client.on_message(pyrogram.filters.regex(pattern=".*http.*"))
async def echo(bot, update):
Expand All @@ -40,6 +37,87 @@ async def echo(bot, update):
youtube_dl_username = None
youtube_dl_password = None
file_name = None
folder = f'./lk21/{update.from_user.id}/'
bypass = ['zippyshare', 'hxfile', 'mediafire', 'anonfiles', 'antfiles']
ext = tldextract.extract(url)
if ext.domain in bypass:
pablo = await update.reply_text('LK21 link detected')
time.sleep(2.5)
if os.path.isdir(folder):
await update.reply_text("Don't spam, wait till your previous task done.")
await pablo.delete()
return
os.makedirs(folder)
await pablo.edit_text('Downloading...')
bypasser = lk21.Bypass()
xurl = bypasser.bypass_url(url)
if ' | ' in url:
url_parts = url.split(' | ')
url = url_parts[0]
file_name = url_parts[1]
else:
if xurl.find('/'):
urlname = xurl.rsplit('/', 1)[1]
file_name = urllib.parse.unquote(urlname)
dldir = f'{folder}{file_name}'
r = requests.get(xurl, allow_redirects=True)
open(dldir, 'wb').write(r.content)
try:
file = filetype.guess(dldir)
xfiletype = file.mime
except AttributeError:
xfiletype = file_name
if xfiletype in ['video/mp4', 'video/x-matroska', 'video/webm', 'audio/mpeg']:
metadata = extractMetadata(createParser(dldir))
if metadata is not None:
if metadata.has("duration"):
duration = metadata.get('duration').seconds
await pablo.edit_text('Uploading...')
start_time = time.time()
if xfiletype in ['video/mp4', 'video/x-matroska', 'video/webm']:
await bot.send_video(
chat_id=update.chat.id,
video=dldir,
caption=file_name,
duration=duration,
reply_to_message_id=update.message_id,
progress=progress_for_pyrogram,
progress_args=(
Translation.UPLOAD_START,
pablo,
start_time
)
)
elif xfiletype == 'audio/mpeg':
await bot.send_audio(
chat_id=update.chat.id,
audio=dldir,
caption=file_name,
duration=duration,
reply_to_message_id=update.message_id,
progress=progress_for_pyrogram,
progress_args=(
Translation.UPLOAD_START,
pablo,
start_time
)
)
else:
await bot.send_document(
chat_id=update.chat.id,
document=dldir,
caption=file_name,
reply_to_message_id=update.message_id,
progress=progress_for_pyrogram,
progress_args=(
Translation.UPLOAD_START,
pablo,
start_time
)
)
await pablo.delete()
shutil.rmtree(folder)
return
if "|" in url:
url_parts = url.split("|")
if len(url_parts) == 2:
Expand Down
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
aiohttp
beautifulsoup4
git+git://github.com/google/chatbase-python.git
hachoir
numpy
Pillow
pyrogram
requests
tgcrypto
youtube-dl
olefile
olefile
lk21
filetype
tldextract

0 comments on commit b919bda

Please sign in to comment.