Hello everyone,
Use the code below as simple reference to build your own custom playlist from your xtream-codes server.
Change the $url and $port values with your main server domain and port values.
<?php
$url = "domain.com";
$port = 1234;
$protocol = "http";
$pls_header = "#EXTM3U";
$json = json_decode(file_get_contents("{$protocol}://{$url}:{$port}/panel_api.php?username={$_GET['username']}&password={$_GET['password']}"), true);
$link = "{$protocol}://{$json['server_info']['url']}:{$json['server_info']['port']}";
if(!isset($_GET['type']) || empty($_GET['type'])){
$extension = 'ts';
}else{
$extension = $_GET['type'];
}
$playlist = [[]];
$i = 0;
$id = 1;
foreach ($json['available_channels'] as $channel) {
$playlist[$i]['name'] = "#EXTINF:0 channel-id=\"{$id}\" tvg-id=\"{$channel['name']}\" tvg-logo=\"{$channel['stream_icon']}\" channel-id=\"{$channel['name']}\" group-title=\"{$channel['category_name']}|{$channel['stream_type']}\",{$channel['name']}";
$playlist[$i]['url'] = $link."/{$channel['stream_type']}/{$json['user_info']['username']}/{$json['user_info']['password']}/".$channel['stream_id'].".".$extension;
$id++;
$i++;
}
$playlist_final = $pls_header."\n";
foreach($playlist as $line){
$playlist_final .= "{$line['name']}\n"."{$line['url']}\n";
}
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename={$_GET['name']}");
echo $playlist_final;
Display More
Use the code below in .htaccess file to setup pretty url:
# AddType application/x-httpd-php53 .php
php_flag magic_quotes_gpc Off
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /GetChannelsList.php?username=$1&password=$2&type=$3&name=$4 [L
Depending of how you name your php file, adjust in the above code the filename, change GetChannelsList to the filename you place in the php code.
If your apache server is configured to use mode rewrite, then you should not be worried.
Otherwise, see http://www.generateit.net/mod-rewrite/index.php for further instructions.
The request will look like: http://domain.com/user/pass/hls/name.m3u8
the response will be an m3u8 file with a content similar to:
#EXTM3U
#EXTINF:0 channel-id="1" tvg-id="XXX SCT" tvg-logo="http://domain.com/picons/scthq.png" channel-id="XXX SCT" group-title="Adult|live",XXX SCT
http://domain.com:1234/live/user/pass/6743.m3u8
#EXTINF:0 channel-id="2" tvg-id="PrivateTV" tvg-logo="http://domain.com/picons/filthxxx.png" channel-id="PrivateTV" group-title="Adult|live",PrivateTV
http://domain.com:1234/live/user/pass/9372.m3u8
#EXTINF:0 channel-id="3" tvg-id="XxX: SuperOne HD" tvg-logo="http://domain.com/picons/xxx18anddirty.png" channel-id="XxX: SuperOne HD" group-title="Adult|live",XxX: SuperOne HD
http://domain.com:1234/live/user/pass/8218.m3u8
#EXTINF:0 channel-id="4" tvg-id="XxX: REDLIGHT HD" tvg-logo="http://domain.com/picons/redlight1.png" channel-id="XxX: REDLIGHT HD" group-title="Adult|live",XxX: REDLIGHT HD
http://domain.com:1234/live/user/pass/9332.m3u8
#EXTINF:0 channel-id="5" tvg-id="XxX: HUSTLER HD" tvg-logo="http://domain.com/picons/hustlertvhd.png" channel-id="XxX: HUSTLER HD" group-title="Adult|live",XxX: HUSTLER HD
http://domain.com:1234/live/user/pass/7868.m3u8
#EXTINF:0 channel-id="6" tvg-id="xxx: Dorcel TV HD" tvg-logo="http://domain.com/picons/dorcelhd.png" channel-id="xxx: Dorcel TV HD" group-title="Adult|live",xxx: Dorcel TV HD
http://domain.com:1234/live/user/pass/7866.m3u8
#EXTINF:0 channel-id="7" tvg-id="RO: Eroxxx" tvg-logo="" channel-id="RO: Eroxxx" group-title="Adult|live",RO: Eroxxx
http://domain.com:1234/live/user/pass/11917.m3u8
#EXTINF:0 channel-id="8" tvg-id="RU: Ночной Клуб XXX" tvg-logo="" channel-id="RU: Ночной Клуб XXX" group-title="MOLDOVA|live",RU: Ночной Клуб XXX
http://domain.com:1234/live/user/pass/12115.m3u8
#EXTINF:0 channel-id="9" tvg-id="XXX: Brazzers TV Europe" tvg-logo="http://domain.com/picons/brazzerstv.png" channel-id="XXX: Brazzers TV Europe" group-title="Adult|live",XXX: Brazzers TV Europe
http://domain.com:1234/live/user/pass/8665.m3u8
#EXTINF:0 channel-id="10" tvg-id="XxX: Penthouse" tvg-logo="http://domain.com/picons/penthousehd.png" channel-id="XxX: Penthouse" group-title="Adult|live",XxX: Penthouse
http://domain.com:1234/live/user/pass/7902.m3u8
#EXTINF:0 channel-id="11" tvg-id="XXX: Meiden Holland Hard" tvg-logo="http://domain.com/picons/playboytvcy.png" channel-id="XXX: Meiden Holland Hard" group-title="Adult|live",XXX: Meiden Holland Hard
http://domain.com:1234/live/user/pass/7867.m3u8
#EXTINF:0 channel-id="12" tvg-id="XxX: PENTHOUSE HD" tvg-logo="http://domain.com/picons/penthousehd.png" channel-id="XxX: PENTHOUSE HD" group-title="Adult|live",XxX: PENTHOUSE HD
http://domain.com:1234/live/user/pass/621.m3u8
#EXTINF:0 channel-id="13" tvg-id="XXX Eroxxx" tvg-logo="http://domain.com/picons/adultchannel.png" channel-id="XXX Eroxxx" group-title="Adult|live",XXX Eroxxx
http://domain.com:1234/live/user/pass/619.m3u8
#EXTINF:0 channel-id="14" tvg-id="XXX Playboy" tvg-logo="http://domain.com/picons/adultchannel.png" channel-id="XXX Playboy" group-title="Adult|live",XXX Playboy
http://domain.com:1234/live/user/pass/613.m3u8
Display More
For more custom PHP coding, contact me in private.
PS: this is a basic version of custom playlist generator. Is fully functional, however improvements can be done. Let me know what you'd like to have in the future versions.
