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

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="+sys.argv[1], headers=headers).content

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


#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.popen ("sudo -S /home/pi/bitkodi/emitir1 "+re5+" &", 'w').write("kalixtik10293847")
#os.popen ("sudo -S /home/pi/bitkodi/emitir2 "+re5+" &", 'w').write("kalixtik10293847")

os.system ("/home/pi/bitkodi/emitir3 "+re5)

