IPTV simply client + youtube live broadcast
#1
Hi all,
I am trying to put youtube live broadcast channels into IPTV client, i know it is not support right now. (or other live stream website)

I am still a noob, but i am trying to put the IPTV simple client and youtube addon together, anyone has clue i should i start ? Or some genius already did that ?


Thanks a millions

Regards
SImon
Reply
#2
Me too Nod
Reply
#3
At that point you probably want to use the Pseudo TV Live add-on instead.
Reply
#4
Requirements:
  • HTTP Web server in your home network (free web hosting doesn’t work);
  • Notepad-like text editor;

  1. Install http web server (apache, nginx, etc.) with PHP support somewhere in your home network behind the same router (this is very important). The web server is needed for simulating standard web browser in youtube or other website, with the same public IP as all your home KODI devices.
  2. With the Notepad-like text editor (Notepad++ for example) edit and save this PHP sample: http://pastie.org/private/ngzyevnbvckz7b5mgasgkq
  3. On the line 17 is the youtube live tv url; on the line 33 is the backup stream (not youtube, but direct url if is needed); on the line 28 the stream quality must be set manually (see examples on line 26).
  4. Save the PHP file in the webserver htdocs directory and open this address: http://serverip_or_hostname/name_of_the_file.php This is the play url for Kodi, VLC or any other video player. For every YouTube live channel/event is needed separate PHP file on the server.

Image

That's all!
Reply
#5
Thanks Both~! Will try on both method this weekend ~

Smile
Reply
#6
(2015-05-20, 19:31)Majide Wrote: Requirements:
  • HTTP Web server in your home network (free web hosting doesn’t work);
  • Notepad-like text editor;

  1. Install http web server (apache, nginx, etc.) with PHP support somewhere in your home network behind the same router (this is very important). The web server is needed for simulating standard web browser in youtube or other website, with the same public IP as all your home KODI devices.
  2. With the Notepad-like text editor (Notepad++ for example) edit and save this PHP sample: http://pastie.org/private/ngzyevnbvckz7b5mgasgkq
  3. On the line 17 is the youtube live tv url; on the line 33 is the backup stream (not youtube, but direct url if is needed); on the line 28 the stream quality must be set manually (see examples on line 26).
  4. Save the PHP file in the webserver htdocs directory and open this address: http://serverip_or_hostname/name_of_the_file.php This is the play url for Kodi, VLC or any other video player. For every YouTube live channel/event is needed separate PHP file on the server.

Image

That's all!

hi friend,

can you send me the php sample ? (the link doesn't work)
Reply
#7
PHP Script for YouTube with manual quality setting
PHP Code:
<?PHP
$channelid 
$_GET["id"];
ini_set("user_agent","facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)");
/* gets the data from a URL */
function get_data($url) {
    
$ch curl_init();
    
$timeout 5;
    
curl_setopt($chCURLOPT_URL$url);
    
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
    
curl_setopt($chCURLOPT_USERAGENT"facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)");
    
curl_setopt($chCURLOPT_REFERER"http://facebook.com");
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_CONNECTTIMEOUT$timeout);
    
$data curl_exec($ch);
    
curl_close($ch);
    return 
$data;
}
$string get_data('https://www.youtube.com/watch?v=' $channelid);
preg_match_all('/(hlsvp.*m3u8)/',$string,$matchesPREG_PATTERN_ORDER);
$var1=$matches[1][0];
$var1 substr($var18);
$var1=str_replace("\/""/"$var1);
#Quality Settings
/* 96=1920x1080, 95=1280x720, 94=854x480, 93=640x360 */
$man get_data($var1);
preg_match_all('/(https:\/.*\/95\/.*index.m3u8)/U',$man,$matchesPREG_PATTERN_ORDER);
$var2=$matches[1][0];
header("Content-type: application/vnd.apple.mpegurl");
header("Location: $var2");
?>
Video quality is set to 720p - You can reset it by changing number 95 to 96 for 1080p or 94 for 480p. Save the script with filename youtube.php in www (server) directory. Example PVR IPTV Simple entry looks like this:
Code:
#EXTINF:-1,NASA [B][COLOR limegreen]HD[/B][/COLOR]
http://server/youtube.php?id=UdmHHpAsMVw|User-Agent=stagefright
Reply
#8
(2016-10-07, 17:55)Majide Wrote: PHP Script for YouTube with manual quality setting
PHP Code:
<?PHP
$channelid 
$_GET["id"];
ini_set("user_agent","facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)");
/* gets the data from a URL */
function get_data($url) {
    
$ch curl_init();
    
$timeout 5;
    
curl_setopt($chCURLOPT_URL$url);
    
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
    
curl_setopt($chCURLOPT_USERAGENT"facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)");
    
curl_setopt($chCURLOPT_REFERER"http://facebook.com");
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_CONNECTTIMEOUT$timeout);
    
$data curl_exec($ch);
    
curl_close($ch);
    return 
$data;
}
$string get_data('https://www.youtube.com/watch?v=' $channelid);
preg_match_all('/(hlsvp.*m3u8)/',$string,$matchesPREG_PATTERN_ORDER);
$var1=$matches[1][0];
$var1 substr($var18);
$var1=str_replace("\/""/"$var1);
#Quality Settings
/* 96=1920x1080, 95=1280x720, 94=854x480, 93=640x360 */
$man get_data($var1);
preg_match_all('/(https:\/.*\/95\/.*index.m3u8)/U',$man,$matchesPREG_PATTERN_ORDER);
$var2=$matches[1][0];
header("Content-type: application/vnd.apple.mpegurl");
header("Location: $var2");
?>
Video quality is set to 720p - You can reset it by changing number 95 to 96 for 1080p or 94 for 480p. Save the script with filename youtube.php in www (server) directory. Example PVR IPTV Simple entry looks like this:
Code:
#EXTINF:-1,NASA [B][COLOR limegreen]HD[/B][/COLOR]
http://server/youtube.php?id=UdmHHpAsMVw|User-Agent=stagefright

hi,
thank you for your help, but I don't succeed to make it work.
I have apache server on linux. I save the script with filename youtube.php in /var/www folder and try the m3u file in vlc player

Code:
#EXTM3U

#EXTINF:-1,NASA [B][COLOR limegreen]HD[/B][/COLOR]
http://myserver_ip/youtube.php?id=UdmHHpAsMVw|User-Agent=stagefright
Reply
#9
Please do not quote previous opinions when answering!

If you want to use this php script in VLC or other non-Kodi players, remove user-agent parameter:
Code:
#EXTINF:-1,NASA [B][COLOR limegreen]HD[/B][/COLOR]
http://myserver_ip/youtube.php?id=UdmHHpAsMVw
Reply
#10
Test with user-agent settings for particular player. In Kodi's IPTV Simple Addon with stagefright user-agent it's working fine.
Reply
#11
I think that if the script will can to detect the user agent, it is will work.
now set in that script:
Code:
ini_set("user_agent","facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)");

I found a function that can do it but I don't know how to use it.
PHP Code:
<?php 
function get_user_browser() 

    
$u_agent $_SERVER['HTTP_USER_AGENT']; 
    
$ub ''
    if(
preg_match('/MSIE/i',$u_agent)) 
    { 
        
$ub "ie"
    } 
    elseif(
preg_match('/Firefox/i',$u_agent)) 
    { 
        
$ub "firefox"
    } 
    elseif(
preg_match('/Safari/i',$u_agent)) 
    { 
        
$ub "safari"
    } 
    elseif(
preg_match('/Chrome/i',$u_agent)) 
    { 
        
$ub "chrome"
    } 
    elseif(
preg_match('/Flock/i',$u_agent)) 
    { 
        
$ub "flock"
    } 
    elseif(
preg_match('/Opera/i',$u_agent)) 
    { 
        
$ub "opera"
    } 
    
    return 
$ub

?>
Reply
#12
hi,

maybe can you give me the original script that you give first.

or give me a script that can fetch the current url of the channel from live tv sites.

I have a tvheadend server and I want add live tv channels as an iptv input. because of the url of the channel changeing every hour I need a script that fetch the current url of the channel when I want to watch this channel and my tvheadend server activate this script ( I need a script that only give me the url of the channel when I activate it.)

thank you for your help
Reply
#13
Hi,

Thank you for your help , i tired your method but didn't work ,

I am trying to add youtube live link: https://www.youtube.com/watch?v=qgT518eDJ6I



1- i edit my youtube.php file as follow :

______________________________________________________________

PHP Code:
<?PHP
ini_set
("user_agent","facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)");
/* gets the data from a URL */
function get_data($url) {
    
$ch curl_init();
    
$timeout 5;
    
curl_setopt($chCURLOPT_URL$url);
    
curl_setopt($chCURLOPT_USERAGENT"facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)");
    
curl_setopt($chCURLOPT_REFERER"http://youtube.com");
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_CONNECTTIMEOUT$timeout);
    
$data curl_exec($ch);
    
curl_close($ch);
    return 
$data;

}
$string get_data('https://www.youtube.com/watch?v=qgT518eDJ6I');
#print $string;
#http://regex101.com
#https://manifest.googlevideo.com/api/manifest/hls_variant/source/yt_live_broadcast/ ... index.m3u8
preg_match_all('/(hlsvp.*m3u8)/',$string,$matchesPREG_PATTERN_ORDER);
$var1=$matches[1][0]; #vurni samo parviq (nulev index) resultat
$var1 substr($var18); #Iztriy parvite 9 znaka ot stringa 
$var1=str_replace("\/""/"$var1); #zamenq dvete 4erti s edna

/* 95=1280x720 */
$man get_data($var1);
preg_match_all('/(http:\/.*\/95\/.*index.m3u8)/U',$man,$matchesPREG_PATTERN_ORDER);
$var2=$matches[1][0]; #vurni samo parviq (nulev index) resultat

// Evaluates to true if $var2 is empty
if (empty($var2)) {
    
$var2='';
}

       
#$chunks = get_data($var2);
       
header("Content-type: application/vnd.apple.mpegurl");
       
#print $var2;
       
header("Location: $var2");
?>


______________________________________________________________


2- I save the script with filename youtube.php in /var/www folder


3- Created test.m3u file / as well another test2.m3u8 file

I edited the file as follow :

______________________________________________________________

Code:
#EXTINF:-1,Bedaya TV
http://mydomain.com/youtube.php?id=qgT518eDJ6I


______________________________________________________________


Both files test.m3u / test.m3u8 didn't work on VLC .

Could you please tell me how to make it work ?

Thanks
Reply
#14
Hey guys, the method works fine but i would like to know if it is possible to make it work with real IP localhost outside. Forgive the english writing bad. Bye
Reply
#15
I tried this but doesn't seems to be working.
Do you need any special modules installed in apache?
Reply

Logout Mark Read Team Forum Stats Members Help
IPTV simply client + youtube live broadcast0