add search step 1

This commit is contained in:
BennyThink 2022-04-19 03:28:20 +08:00
parent c15348b14a
commit c33e4eece1
No known key found for this signature in database
GPG Key ID: 6CD0DBDA5235D481
3 changed files with 34 additions and 13 deletions

View File

@ -43,7 +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
9. supports celery worker distribution - faster than before.
10. subscriptions to YouTube Channels
11. cache mechanism - download once for the same video.
11. cache mechanism - download once for the same video.
![](assets/2.jpeg)
@ -128,8 +128,8 @@ you can configure all the following environment variables:
* 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
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.
**Inline button will be lost during the forwarding.**
* ARCHIVE_ID: group or channel id/username. All downloads will send to this group first and then forward to end user.
**Inline button will be lost during the forwarding.**
## 3.2 Set up init data
@ -255,6 +255,10 @@ https://www.youtube.com/playlist?list=PL1Hdq7xjQCJxQnGc05gS4wzHWccvEJy0w
https://dmesg.app/m3u8/prog_index.m3u8
## test twitter
https://twitter.com/nitori_sayaka/status/1526199729864200192
https://twitter.com/BennyThinks/status/1475836588542341124
# Donation
* [Buy me a coffee](https://www.buymeacoffee.com/bennythink)

View File

@ -1,21 +1,22 @@
pyrogram==1.4.15
pyrogram==1.4.16
tgcrypto==1.2.3
yt-dlp==2022.4.8
yt-dlp==2022.5.18
APScheduler==3.9.1
beautifultable==1.0.1
beautifultable==1.1.0
ffmpeg-python==0.2.0
PyMySQL==1.0.2
celery==5.2.6
filetype==1.0.10
filetype==1.0.13
flower==1.0.0
psutil==5.9.0
influxdb==5.3.1
beautifulsoup4==4.11.1
fakeredis==1.7.1
fakeredis==1.7.5
supervisor==4.2.4
tgbot-ping==1.0.4
redis==4.1.4
requests==2.27.1
tqdm==4.64.0
requests-toolbelt==0.9.1
ffpb==0.4.1
ffpb==0.4.1
youtube-search-python==1.6.5

View File

@ -15,7 +15,7 @@ import time
import traceback
import typing
from io import BytesIO
from youtubesearchpython import VideosSearch
import pyrogram.errors
from apscheduler.schedulers.background import BackgroundScheduler
from pyrogram import Client, filters, types
@ -268,8 +268,24 @@ def download_handler(client: "Client", message: "types.Message"):
logging.info("start %s", url)
if not re.findall(r"^https?://", url.lower()):
red.update_metrics("bad_request")
message.reply_text("I think you should send me a link.", quote=True)
red.update_metrics("search_request")
# TODO
result = VideosSearch(url, limit=5).result().get("result", [])
text = ""
count = 1
buttons = []
for item in result:
text += f"{count}. {item['title']} - {item['link']}\n\n"
buttons.append(
InlineKeyboardButton(
f"{count}",
callback_data=f"search_{item['id']}"
)
)
count += 1
markup = InlineKeyboardMarkup([buttons])
client.send_message(chat_id, text, disable_web_page_preview=True, reply_markup=markup)
return
if re.findall(r"^https://www\.youtube\.com/channel/", VIP.extract_canonical_link(url)):
@ -359,7 +375,7 @@ if __name__ == '__main__':
scheduler.add_job(auto_restart, 'interval', seconds=5)
scheduler.add_job(InfluxDB().collect_data, 'interval', seconds=60)
# default quota allocation of 10,000 units per day,
scheduler.add_job(periodic_sub_check, 'interval', seconds=60 * 30)
scheduler.add_job(periodic_sub_check, 'interval', seconds=60 * 60)
scheduler.start()
banner = f"""