Update README

This commit is contained in:
Taras Terletskyi 2022-11-05 22:20:27 +02:00
parent 20d8d55a66
commit 79ff67b410
11 changed files with 23 additions and 17 deletions

View file

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View file

Before

Width:  |  Height:  |  Size: 294 KiB

After

Width:  |  Height:  |  Size: 294 KiB

View file

@ -4,7 +4,7 @@
Dockerfile.base Dockerfile.base
LICENSE LICENSE
README.md README.md
assets .assets
docker-compose.yml docker-compose.yml
pyproject.toml pyproject.toml

View file

@ -1,7 +1,7 @@
## yt-dlp-bot ## yt-dlp-bot
Simple and reliable YouTube Download Telegram Bot. Simple and reliable YouTube Download Telegram Bot.
![frames](assets/download_success.png) ![frames](.assets/download_success.png)
## 😂 Features ## 😂 Features
* Download videos from any [yt-dlp](https://github.com/yt-dlp/yt-dlp) supported website * Download videos from any [yt-dlp](https://github.com/yt-dlp/yt-dlp) supported website
@ -51,11 +51,17 @@ After pasting video URL(s) bot will send you appropriate message whether they we
1. If you want to change `yt-dlp` download options, go to the `worker/ytdl_opts` 1. If you want to change `yt-dlp` download options, go to the `worker/ytdl_opts`
directory, copy content from `default.py` to `user.py` and modify as you wish directory, copy content from `default.py` to `user.py` and modify as you wish
by checking [available options](https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L180). by checking [available options](https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L180).
2. Default max simultaneous video downloads by worker service is 2. Change the `MAX_SIMULTANEOUS_DOWNLOADS`
variable in `envs/.env_worker` to desired value but keep in mind `yt-dlp` may glitch when the value is high.
3. Worker service (particularly the FFmpeg process) makes a JPEG thumbnail from the video. It's needed when
you choose to upload the video to the Telegram chat. By default, it tries to make it on the 10th second
of the video, but if the video is shorter, it will make it on `video length / 2` time point because the FFmpeg
process will error out. Change the `THUMBNAIL_FRAME_SECOND` variable if needed in the `envs/.env_worker` file.
## 🛑 Failed download ## 🛑 Failed download
If your URL can't be downloaded for some reason, you will see this If your URL can't be downloaded for some reason, you will see this
![frames](assets/download_failed.png) ![frames](.assets/download_failed.png)
## Access ## Access
- **API**: default port `1984` and no auth. Port can be changed in `docker-compose.yml` - **API**: default port `1984` and no auth. Port can be changed in `docker-compose.yml`

View file

@ -10,14 +10,14 @@ from core.workers.manager import RabbitWorkerManager
from yt_shared.rabbit import get_rabbitmq from yt_shared.rabbit import get_rabbitmq
from yt_shared.utils.tasks.tasks import create_task from yt_shared.utils.tasks.tasks import create_task
REGEX_NOT_START_WITH_SLASH = r'^[^/]'
class BotLauncher: class BotLauncher:
"""Bot launcher which parses configuration file, creates bot with """Bot launcher which parses configuration file, creates bot with
camera instances and finally starts the bot. camera instances and finally starts the bot.
""" """
REGEX_NOT_START_WITH_SLASH = r'^[^/]'
def __init__(self) -> None: def __init__(self) -> None:
"""Constructor.""" """Constructor."""
self._log = logging.getLogger(self.__class__.__name__) self._log = logging.getLogger(self.__class__.__name__)
@ -45,7 +45,7 @@ class BotLauncher:
cb.on_message, cb.on_message,
filters=filters.user(list(self._bot.allowed_users.keys())) filters=filters.user(list(self._bot.allowed_users.keys()))
& filters.chat(list(self._bot.allowed_users.keys())) & filters.chat(list(self._bot.allowed_users.keys()))
& filters.regex(REGEX_NOT_START_WITH_SLASH), & filters.regex(self.REGEX_NOT_START_WITH_SLASH),
), ),
) )
@ -55,7 +55,7 @@ class BotLauncher:
self._rabbit_mq.register(), self._rabbit_mq.register(),
task_name=task_name, task_name=task_name,
logger=self._log, logger=self._log,
exception_message='Task %s raised an exception', exception_message='Task "%s" raised an exception',
exception_message_args=(task_name,), exception_message_args=(task_name,),
) )
@ -67,7 +67,7 @@ class BotLauncher:
YtdlpNewVersionNotifyTask(bot=self._bot).run(), YtdlpNewVersionNotifyTask(bot=self._bot).run(),
task_name=task_name, task_name=task_name,
logger=self._log, logger=self._log,
exception_message='Task %s raised an exception', exception_message='Task "%s" raised an exception',
exception_message_args=(task_name,), exception_message_args=(task_name,),
) )
@ -75,7 +75,7 @@ class BotLauncher:
"""Start telegram bot and related processes.""" """Start telegram bot and related processes."""
await self._bot.start() await self._bot.start()
self._log.info('Starting %s bot', (await self._bot.get_me()).first_name) self._log.info('Starting "%s" bot', (await self._bot.get_me()).first_name)
await self._bot.send_startup_message() await self._bot.send_startup_message()
await self._start_tasks() await self._start_tasks()
await self._bot.run_forever() await self._bot.run_forever()

View file

@ -43,7 +43,7 @@ class UserSchema(BaseUserSchema):
return False return False
def change_type(values: list[int]) -> list[BaseUserSchema]: def _change_type(values: list[int]) -> list[BaseUserSchema]:
return [BaseUserSchema(id=id_) for id_ in values] return [BaseUserSchema(id=id_) for id_ in values]
@ -54,7 +54,7 @@ class ApiSchema(RealBaseModel):
silent: StrictBool silent: StrictBool
video_caption: VideoCaptionSchema video_caption: VideoCaptionSchema
_transform_chat_ids = validator('upload_to_chat_ids', pre=True)(change_type) _transform_chat_ids = validator('upload_to_chat_ids', pre=True)(_change_type)
class TelegramSchema(RealBaseModel): class TelegramSchema(RealBaseModel):

View file

@ -50,7 +50,7 @@ class SuccessHandler(AbstractHandler):
).run(), ).run(),
task_name=task_name, task_name=task_name,
logger=self._log, logger=self._log,
exception_message='Task %s raised an exception', exception_message='Task "%s" raised an exception',
exception_message_args=(task_name,), exception_message_args=(task_name,),
) )

View file

@ -154,7 +154,7 @@ class UploadTask(AbstractTask):
self._save_cache_to_db(video), self._save_cache_to_db(video),
task_name=db_cache_task_name, task_name=db_cache_task_name,
logger=self._log, logger=self._log,
exception_message='Task %s raised an exception', exception_message='Task "%s" raised an exception',
exception_message_args=(db_cache_task_name,), exception_message_args=(db_cache_task_name,),
) )

View file

@ -20,6 +20,6 @@ class SuccessResultWorker(AbstractResultWorker):
self.HANDLER_CLS(body=body, bot=self._bot).handle(), self.HANDLER_CLS(body=body, bot=self._bot).handle(),
task_name=task_name, task_name=task_name,
logger=self._log, logger=self._log,
exception_message='Task %s raised an exception', exception_message='Task "%s" raised an exception',
exception_message_args=(task_name,), exception_message_args=(task_name,),
) )

View file

@ -18,5 +18,5 @@ RABBITMQ_PORT=5672
REDIS_HOST=yt_redis REDIS_HOST=yt_redis
LOG_LEVEL=DEBUG LOG_LEVEL=INFO
TMP_DOWNLOAD_PATH=/tmp/download_tmpfs TMP_DOWNLOAD_PATH=/tmp/download_tmpfs

View file

@ -102,7 +102,7 @@ class VideoService:
self._copy_file_to_storage(video), self._copy_file_to_storage(video),
task_name=task_name, task_name=task_name,
logger=self._log, logger=self._log,
exception_message='Task %s raised an exception', exception_message='Task "%s" raised an exception',
exception_message_args=(task_name,), exception_message_args=(task_name,),
) )
@ -113,7 +113,7 @@ class VideoService:
MakeThumbnailTask(thumb_path, file_path, duration=duration).run(), MakeThumbnailTask(thumb_path, file_path, duration=duration).run(),
task_name=MakeThumbnailTask.__class__.__name__, task_name=MakeThumbnailTask.__class__.__name__,
logger=self._log, logger=self._log,
exception_message='Task %s raised an exception', exception_message='Task "%s" raised an exception',
exception_message_args=(MakeThumbnailTask.__class__.__name__,), exception_message_args=(MakeThumbnailTask.__class__.__name__,),
) )