PW Akshay

Generation

generate functionTue, 06 Dec 2022

live stream m3u8 to youtube in python using rtmpy

import subprocess import time import sys from rtmpy import RTMPClient import urllib.request import re url = str(sys.argv[1]) while True: print("updating...") response = urllib.request.urlopen(url) data = response.read() text = data.decode('utf-8') m3u8 = re.search('(?P<url>https?://[^\s]+)', text).group("url") print(m3u8) client = RTMPClient(app="live", host="rtmp://x.rtmp.youtube.com/live2", rtmp_timeout=15) client.connect() client.publish(m3u8) client.close() time.sleep(5)

Questions about programming?Chat with your personal AI assistant