#!/usr/bin/env python
import os
import requests
import re
import time

cookie_value=""
user_agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"

headers = {"Cookie": "beget=begetok; %s" % (cookie_value),"User-Agent": "%s" % (user_agent)}

embed2 = requests.get("http://lodejo.ru/futbolgratis-kodi.php?busqueda=PHILADELPHIA", headers=headers).content

re5=re.findall('acestream\:\/\/(.*?)\"', embed2.decode('utf-8'))[0]
print (re5)

os.popen("sudo -S pkill acestream", 'w').write("kalixtik10293847")

#os.system("sudo pkill acestream")
time.sleep(5)
#os.system("sudo /opt/acestream/acestream.start &")
os.popen("sudo -S /opt/acestream/acestream.start &", 'w').write("kalixtik10293847")


#while 1==1:
#os.system ("ffmpeg -re -i http://applive.online:25461/live/Fran0083/12340007/9056.m3u8 -c:v libx264 -sample_rate 44100 -acodec aac -f flv 'rtmp://pubucaster.com/live/Prueba_canal_rtmp_4?key=f4b6d511&id=85006'")
os.system ("/home/pi/bitkodi/emitir "+re5)

