Spaces:
Runtime error
Runtime error
Create telegram/parse.py
Browse files- bot/telegram/parse.py +16 -0
bot/telegram/parse.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PATH: bot/telegram/parse.py
|
| 2 |
+
from hydrogram.types import Message
|
| 3 |
+
|
| 4 |
+
def extract_media_message(m: Message):
|
| 5 |
+
# video/document supported
|
| 6 |
+
if m.video:
|
| 7 |
+
return m.video, "video"
|
| 8 |
+
if m.document:
|
| 9 |
+
return m.document, "document"
|
| 10 |
+
return None, ""
|
| 11 |
+
|
| 12 |
+
def extract_title_description(m: Message, file_name: str) -> tuple[str, str]:
|
| 13 |
+
caption = (m.caption or "").strip()
|
| 14 |
+
title = (file_name or "video").rsplit(".", 1)[0].strip()[:95] or "video"
|
| 15 |
+
desc = caption[:4900] if caption else ""
|
| 16 |
+
return title, desc
|