Skip to content
The Chat Archive
gpt-3.5-turbo-0613· OpenAI WildChat-4.8M (AI2)

Make a python function that will accept as a parameter the name of a video and will…

  1. User

    Make a python function that will accept as a parameter the name of a video and will upload it to the telegram channel i have. Use this info:

    Bot token='5696051763:AAHRAx_OwR-VNsEIITYC8fToKPJIbMZjigU'

    chat_id = '805373846'

  2. Assistant

    import requests

    def upload_video_to_channel(video_name): bot_token = '5696051763:AAHRAx_OwR-VNsEIITYC8fToKPJIbMZjigU' chat_id = '805373846'

    url = f"https://api.telegram.org/bot{bot_token}/sendVideo"
    files = {'video': open(video_name, 'rb')}
    data = {'chat_id': chat_id}
    
    response = requests.post(url, data=data, files=files)
    
    if response.status_code == 200:
        print(f"Video '{video_name}' uploaded successfully to the channel.")
    else:
        print("Upload failed.")
        print(response.json())
    

    Usage example

    upload_video_to_channel('my_video.mp4')