mirror of
https://github.com/omg-xtao/ytdlbot.git
synced 2024-11-16 03:45:23 +00:00
parent
3fd51eaef9
commit
f8cfdd3468
@ -43,6 +43,7 @@ You can choose to become 'VIP' if you really need large traffic. And also, you c
|
|||||||
8. support sending as file or streaming as video
|
8. support sending as file or streaming as video
|
||||||
9. supports celery worker distribution - faster than before.
|
9. supports celery worker distribution - faster than before.
|
||||||
10. subscriptions to YouTube Channels
|
10. subscriptions to YouTube Channels
|
||||||
|
11. cache mechanism - for the same video you'll only have to download once.
|
||||||
|
|
||||||
![](assets/2.jpeg)
|
![](assets/2.jpeg)
|
||||||
|
|
||||||
@ -102,7 +103,7 @@ you can configure all the following environment variables:
|
|||||||
* APP_ID: **REQUIRED**, get it from https://core.telegram.org/
|
* APP_ID: **REQUIRED**, get it from https://core.telegram.org/
|
||||||
* APP_HASH: **REQUIRED**
|
* APP_HASH: **REQUIRED**
|
||||||
* TOKEN: **REQUIRED**
|
* TOKEN: **REQUIRED**
|
||||||
* REDIS: **REQUIRED if you need VIP mode** ⚠️ Don't publish your redis server on the internet. ⚠️
|
* REDIS: **REQUIRED if you need VIP mode and cache** ⚠️ Don't publish your redis server on the internet. ⚠️
|
||||||
|
|
||||||
* OWNER: owner username
|
* OWNER: owner username
|
||||||
* QUOTA: quota in bytes
|
* QUOTA: quota in bytes
|
||||||
@ -127,6 +128,7 @@ you can configure all the following environment variables:
|
|||||||
* GOOGLE_API_KEY: YouTube API key, required for YouTube video subscription.
|
* GOOGLE_API_KEY: YouTube API key, required for YouTube video subscription.
|
||||||
* AUDIO_FORMAT: audio format, default is m4a. You can set to any known and supported format for ffmpeg. For
|
* AUDIO_FORMAT: audio format, default is m4a. You can set to any known and supported format for ffmpeg. For
|
||||||
example,`mp3`, `flac`, etc. ⚠️ m4a is the fastest. Other formats may affect performance.
|
example,`mp3`, `flac`, etc. ⚠️ m4a is the fastest. Other formats may affect performance.
|
||||||
|
* ARCHIVE_ID: group or channel id/username. All downloads will send to this group first and then forward to end user.
|
||||||
|
|
||||||
## 3.2 Set up init data
|
## 3.2 Set up init data
|
||||||
|
|
||||||
@ -134,7 +136,7 @@ If you only need basic functionality, you can skip this step.
|
|||||||
|
|
||||||
### 3.2.1 Create MySQL db
|
### 3.2.1 Create MySQL db
|
||||||
|
|
||||||
Required for VIP, settings, YouTube subscription and notification.
|
Required for VIP, settings, YouTube subscription.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
@ -51,4 +51,5 @@ MYSQL_HOST = os.getenv("MYSQL_HOST")
|
|||||||
MYSQL_USER = os.getenv("MYSQL_USER", "root")
|
MYSQL_USER = os.getenv("MYSQL_USER", "root")
|
||||||
MYSQL_PASS = os.getenv("MYSQL_PASS", "root")
|
MYSQL_PASS = os.getenv("MYSQL_PASS", "root")
|
||||||
|
|
||||||
AUDIO_FORMAT = os.getenv("AUDIO_FORMAT", "m4a")
|
AUDIO_FORMAT = os.getenv("AUDIO_FORMAT", "m4a")
|
||||||
|
ARCHIVE_ID = os.getenv("ARCHIVE_ID")
|
||||||
|
@ -26,7 +26,8 @@ from pyrogram import idle
|
|||||||
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
||||||
|
|
||||||
from client_init import create_app
|
from client_init import create_app
|
||||||
from config import AUDIO_FORMAT, BROKER, ENABLE_CELERY, ENABLE_VIP, WORKERS
|
from config import (ARCHIVE_ID, AUDIO_FORMAT, BROKER, ENABLE_CELERY,
|
||||||
|
ENABLE_VIP, WORKERS)
|
||||||
from constant import BotText
|
from constant import BotText
|
||||||
from db import Redis
|
from db import Redis
|
||||||
from downloader import (edit_text, sizeof_fmt, tqdm_progress, upload_hook,
|
from downloader import (edit_text, sizeof_fmt, tqdm_progress, upload_hook,
|
||||||
@ -257,6 +258,8 @@ def ytdl_normal_download(bot_msg, client, url):
|
|||||||
cap = f"`{filename}`\n\n{url}\n\nInfo: {meta['width']}x{meta['height']} {size} {meta['duration']}s" \
|
cap = f"`{filename}`\n\n{url}\n\nInfo: {meta['width']}x{meta['height']} {size} {meta['duration']}s" \
|
||||||
f"\n{remain}\n{worker}"
|
f"\n{remain}\n{worker}"
|
||||||
settings = get_user_settings(str(chat_id))
|
settings = get_user_settings(str(chat_id))
|
||||||
|
if ARCHIVE_ID:
|
||||||
|
chat_id = ARCHIVE_ID
|
||||||
if settings[2] == "document":
|
if settings[2] == "document":
|
||||||
logging.info("Sending as document")
|
logging.info("Sending as document")
|
||||||
res_msg = client.send_document(chat_id, video_path,
|
res_msg = client.send_document(chat_id, video_path,
|
||||||
@ -284,6 +287,8 @@ def ytdl_normal_download(bot_msg, client, url):
|
|||||||
unique = get_unique_clink(clink, settings)
|
unique = get_unique_clink(clink, settings)
|
||||||
red.add_send_cache(unique, res_msg.chat.id, res_msg.message_id)
|
red.add_send_cache(unique, res_msg.chat.id, res_msg.message_id)
|
||||||
red.update_metrics("video_success")
|
red.update_metrics("video_success")
|
||||||
|
if ARCHIVE_ID:
|
||||||
|
client.forward_messages(bot_msg.chat.id, ARCHIVE_ID, res_msg.message_id)
|
||||||
bot_msg.edit_text('Download success!✅')
|
bot_msg.edit_text('Download success!✅')
|
||||||
else:
|
else:
|
||||||
client.send_chat_action(chat_id, 'typing')
|
client.send_chat_action(chat_id, 'typing')
|
||||||
|
Loading…
Reference in New Issue
Block a user