tgbot-collection / ytdlbot

Download videos from Youtube and other platforms through a Telegram Bot
Apache License 2.0
578 stars 541 forks source link

Search for links throughout whole message #430

Open PROger4ever opened 1 month ago

PROger4ever commented 1 month ago

Problem

When you share youtube-video from mobile app to telegram, it has name in the beginning like:

Respect💯 Greatest Save🦸‍♂️ #shorts #short #status #humanity #viral
https://youtube.com/shorts/1K1pMdQzV1M?si=uze3jaacXuKeWDNG

But ytdlbot searches for link in message begininng: https://github.com/tgbot-collection/ytdlbot/blob/dd3e42ff911d388755b9e4014bf7503689349c29/ytdlbot/ytdl_bot.py#L593

This doesn't let me to share the video from youtube app to a friend using the bot in a simple way.

Proposal

Let's parse links using (probably not) rfc-compliant pattern like:

/https?:\/\/[^\s\/]+(\/\S*)?/g

In search of the perfect URL validation regex Maybe we should validate host in the link not to be local-addresses like localhost, 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 and so on.

SanujaNS commented 1 month ago

Hello @PROger4ever ,

Thank you for taking the time to share your valuable suggestions with us. We will carefully review your input and assess the feasibility of incorporating these ideas into our project. From the first look of this, it appears that this change may impact the bot's current YouTube search functionality. One possible solution could be to limit YouTube searches to instances where the /search command is specifically invoked. We would appreciate your thoughts on this approach and any other ideas you may have. Please allow us some time to thoroughly evaluate your suggestions. We will get back to you as soon as we have a clear understanding of how to proceed.

Thank you.