Skip to content

Instantly share code, notes, and snippets.

@gowrizrh
Created October 5, 2025 03:54
Show Gist options
  • Select an option

  • Save gowrizrh/972a99bff5726bb20a1942ce0ed0eb75 to your computer and use it in GitHub Desktop.

Select an option

Save gowrizrh/972a99bff5726bb20a1942ce0ed0eb75 to your computer and use it in GitHub Desktop.
Save to Telegram
import os
import requests
class PostVideoToTelegram:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"filenames": ("VHS_FILENAMES",),
"api_url": ("STRING", {"default": ""}),
"chat_id": ("STRING", {"default": ""})
}
}
RETURN_TYPES = ("VHS_FILENAMES",)
RETURN_NAMES = ("filenames",)
FUNCTION = "post_videos"
CATEGORY = "Post/Telegram"
OUTPUT_NODE = True
def post_videos(self, filenames, api_url, chat_id):
path = filenames[-1][1]
print(f"[PostVideoToTelegram] Uploading {path} to Telegram...")
try:
with open(path, "rb") as f:
resp = requests.post(
f"{api_url}/sendVideo",
data={"chat_id": chat_id},
files={"video": f},
timeout=60
)
print(f"[PostVideoToTelegram] Done, status={resp.status_code}, response={resp.text[:200]}")
except Exception as e:
print(f"[PostVideoToTelegram] ERROR: {e}")
return (filenames,)
NODE_CLASS_MAPPINGS = {
"PostVideoToTelegram": PostVideoToTelegram
}
NODE_DISPLAY_NAME_MAPPINGS = {
"PostVideoToTelegram": "Post Video to Telegram"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment