Skip to content

Commit

Permalink
fix: e[#126] && d[#111]
Browse files Browse the repository at this point in the history
  • Loading branch information
kalanakt committed Jan 9, 2024
1 parent d2495d0 commit c14eb6a
Show file tree
Hide file tree
Showing 26 changed files with 183 additions and 212 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BOT_TOKEN=
API_ID=
API_HASH=
OWNER_ID=
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ yarn-error.log*
.env.test.local
.env.production.local
.env

*.session
*.session-journal
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/All-Url-Uploader.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added All-Url-Uploader.session
Binary file not shown.
37 changes: 0 additions & 37 deletions Uploader/README.md

This file was deleted.

9 changes: 1 addition & 8 deletions Uploader/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,10 @@
import time
import shutil
import asyncio
import logging
import subprocess

from pyrogram.types import *
from datetime import datetime

from Uploader.utitles import *
if bool(os.environ.get("WEBHOOK")):
from Uploader.config import Config
else:
from sample_config import Config
from config import Config
from Uploader.script import Translation
from Uploader.functions.ran_text import random_char
from Uploader.functions.display_progress import progress_for_pyrogram, humanbytes
Expand Down
9 changes: 1 addition & 8 deletions Uploader/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE

import os
from Uploader.functions.display_progress import progress_for_pyrogram, humanbytes
if bool(os.environ.get("WEBHOOK")):
from Uploader.config import Config
else:
from sample_config import Config
from Uploader.dl_button import ddl_call_back
from Uploader.button import youtube_dl_call_back
from Uploader.script import Translation
from pyrogram import Client, types
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from pyrogram import Client
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
Expand Down
7 changes: 0 additions & 7 deletions Uploader/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE

import os

from pyrogram import Client, filters
from pyrogram.types import Message
from Uploader.script import Translation

if bool(os.environ.get("WEBHOOK")):
from Uploader.config import Config
else:
from sample_config import Config


@Client.on_message(
filters.command("start") & filters.private,
Expand Down
6 changes: 1 addition & 5 deletions Uploader/dl_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@
import time
import aiohttp
import asyncio
import logging

from datetime import datetime

from Uploader.functions.display_progress import progress_for_pyrogram, humanbytes, TimeFormatter
from Uploader.utitles import *
from Uploader.script import Translation
if bool(os.environ.get("WEBHOOK")):
from Uploader.config import Config
else:
from sample_config import Config
from config import Config

logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
Expand Down
11 changes: 1 addition & 10 deletions Uploader/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,25 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE

import os
import time
import json
import asyncio
import logging

from opencc import OpenCC

from pyrogram.types import Thumbnail
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton

if bool(os.environ.get("WEBHOOK")):
from Uploader.config import Config
else:
from sample_config import Config
from config import Config
from Uploader.script import Translation
from Uploader.functions.ran_text import random_char
from Uploader.functions.display_progress import humanbytes
from Uploader.functions.display_progress import humanbytes

logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
logging.getLogger("pyrogram").setLevel(logging.WARNING)

s2tw = OpenCC('s2tw.json').convert


@Client.on_message(filters.private & filters.regex(pattern=".*http.*"))
async def echo(bot, update):
Expand Down
7 changes: 4 additions & 3 deletions Uploader/functions/help_ytdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
# SOFTWARE

import os
import time
import requests
import logging

from urllib.parse import urlparse
Expand All @@ -39,6 +37,9 @@ def get_file_extension_from_url(url):


def get_resolution(info_dict):
width = 0
height = 0

if {"width", "height"} <= info_dict.keys():
width = int(info_dict['width'])
height = int(info_dict['height'])
Expand All @@ -58,4 +59,4 @@ def get_resolution(info_dict):
elif info_dict['height'] == 240:
width = 426
height = 240
return (width, height)
return width, height
5 changes: 1 addition & 4 deletions Uploader/thumbunali.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@

from pyrogram import Client, filters

if bool(os.environ.get("WEBHOOK")):
from Uploader.config import Config
else:
from sample_config import Config
from config import Config


@Client.on_message(filters.photo & filters.incoming & filters.private)
Expand Down
55 changes: 25 additions & 30 deletions Uploader/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,18 @@
# SOFTWARE

import os
from urllib.parse import urlparse
import wget
import asyncio

from opencc import OpenCC
from youtube_dl import YoutubeDL
from pyrogram import Client, filters, enums
from pyrogram import enums
from pyrogram.types import Message
from pyrogram import Client, filters

if bool(os.environ.get("WEBHOOK")):
from Uploader.config import Config
else:
from sample_config import Config
from config import Config

from Uploader.functions.help_ytdl import get_file_extension_from_url, get_resolution

YTDL_REGEX = (r"^((?:https?:)?\/\/)")
s2tw = OpenCC('s2tw.json').convert
YTDL_REGEX = r"^((?:https?:)?\/\/)"


@Client.on_callback_query(filters.regex("^ytdl_audio$"))
Expand Down Expand Up @@ -84,16 +77,35 @@ async def send_audio(message: Message, info_dict, audio_file):
thumb = download_location if os.path.isfile(
download_location) else None
webpage_url = info_dict['webpage_url']
title = s2tw(info_dict['title'])
title = info_dict['title'] or ''
caption = f'<b><a href=\"{webpage_url}\">{title}</a></b>'
duration = int(float(info_dict['duration']))
performer = s2tw(info_dict['uploader'])
performer = info_dict['uploader'] or ''
await message.reply_audio(audio_file, caption=caption, duration=duration, performer=performer, title=title, parse_mode=enums.ParseMode.HTML, thumb=thumb)

os.remove(audio_file)
os.remove(thumbnail_file)


async def send_video(message: Message, info_dict, video_file):
basename = video_file.rsplit(".", 1)[-2]
thumbnail_url = info_dict['thumbnail']
thumbnail_file = f"{basename}.{get_file_extension_from_url(thumbnail_url)}"
download_location = f"{Config.DOWNLOAD_LOCATION}/{message.from_user.id}.jpg"
thumb = download_location if os.path.isfile(
download_location) else None
webpage_url = info_dict['webpage_url']
title = info_dict['title'] or ''
caption = f'<b><a href=\"{webpage_url}\">{title}</a></b>'
duration = int(float(info_dict['duration']))
width, height = get_resolution(info_dict)
await message.reply_video(video_file, caption=caption, duration=duration, width=width, height=height,
parse_mode=enums.ParseMode.HTML, thumb=thumb)

os.remove(video_file)
os.remove(thumbnail_file)


@Client.on_callback_query(filters.regex("^ytdl_video$"))
async def callback_query_ytdl_video(_, callback_query):
try:
Expand Down Expand Up @@ -123,21 +135,4 @@ async def callback_query_ytdl_video(_, callback_query):
except Exception as e:
await message.reply_text(e)
await callback_query.message.reply_to_message.delete()
await callback_query.message.delete()

async def send_video(message: Message, info_dict, video_file):
basename = video_file.rsplit(".", 1)[-2]
thumbnail_url = info_dict['thumbnail']
thumbnail_file = f"{basename}.{get_file_extension_from_url(thumbnail_url)}"
download_location = f"{Config.DOWNLOAD_LOCATION}/{message.from_user.id}.jpg"
thumb = download_location if os.path.isfile(
download_location) else None
webpage_url = info_dict['webpage_url']
title = s2tw(info_dict['title'])
caption = f'<b><a href=\"{webpage_url}\">{title}</a></b>'
duration = int(float(info_dict['duration']))
width, height = get_resolution(info_dict)
await message.reply_video(video_file, caption=caption, duration=duration, width=width, height=height, parse_mode=enums.ParseMode.HTML, thumb=thumb)

os.remove(video_file)
os.remove(thumbnail_file)
await callback_query.message.delete()
Loading

1 comment on commit c14eb6a

@vercel
Copy link

@vercel vercel bot commented on c14eb6a Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

all-url-uploader – ./

all-url-uploader-netronk.vercel.app
all-url-uploader-git-main-netronk.vercel.app
urluploader.vercel.app

Please sign in to comment.