Bonjour Hizo
Je voudrais utiliser zenitor pour rendre plus convivial un programme, qui est
http://darbycrash.altervista.org/PHP/WilmaaTV.php.txt
Moi je peux faire
php wilmaa.php
mais pour certains de mes proches ce n'est guère pratique.
J'ai modifié le programme pour passer juste le numéro de la chaine, par exemple
php wilmaa.php 38
lance la RTS1 (TV suisse)
Le programme
<?php
/*
Filename: WilmaaTV.php. Copyright 2013/2014, Darby_Crash - kihol@inwind.it
This Program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This Program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Many thanks to mitm for his help !!
*/
$version = "4.0";
error_reporting(0);
class cURL {
var $headers ;
var $user_agent ;
var $compression ;
var $cookie_file ;
var $proxy ;
function cURL ( $cookies = TRUE , $cookie = 'cookies.txt' , $compression = '' , $proxy = '' ) {
$this -> headers [] = 'X-Forwarded-For: 195.186.145.47' ;
$this -> user_agent = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16' ;
$this -> compression = $compression ;
$this -> proxy = $proxy ;
$this -> cookies = $cookies ;
if ( $this -> cookies == TRUE ) $this -> cookie ( $cookie );
}
function cookie ( $cookie_file ) {
if ( file_exists ( $cookie_file )) {
$this -> cookie_file = $cookie_file ;
} else {
fopen ( $cookie_file , 'w' ) or $this -> error ( 'The cookie file could not be opened. Make sure this directory has the correct permissions' );
$this -> cookie_file = $cookie_file ;
fclose ( $this -> cookie_file );
}
}
function get ( $url ) {
$process = curl_init ( $url );
curl_setopt ( $process , CURLOPT_HTTPHEADER , $this -> headers );
curl_setopt ( $process , CURLOPT_HEADER , 0 );
curl_setopt ( $process , CURLOPT_USERAGENT , $this -> user_agent );
if ( $this -> cookies == TRUE ) curl_setopt ( $process , CURLOPT_COOKIEFILE , $this -> cookie_file );
if ( $this -> cookies == TRUE ) curl_setopt ( $process , CURLOPT_COOKIEJAR , $this -> cookie_file );
curl_setopt ( $process , CURLOPT_ENCODING , $this -> compression );
curl_setopt ( $process , CURLOPT_TIMEOUT , 30 );
if ( $this -> proxy ) curl_setopt ( $process , CURLOPT_PROXY , $this -> proxy );
curl_setopt ( $process , CURLOPT_RETURNTRANSFER , 1 );
curl_setopt ( $process , CURLOPT_FOLLOWLOCATION , 0 );
$return = curl_exec ( $process );
curl_close ( $process );
return $return ;
}
}
strncasecmp(php_uname('s'), "Win", 3) == 0 ? $windows = true : $windows = false;
if ($windows)
{
if (file_exists("C:\\progra~2\\VideoLAN\\VLC\\vlc.exe"))
$vlc = "C:\\progra~2\\VideoLAN\\VLC\\vlc.exe";
else
$vlc = "C:\\progra~1\\VideoLAN\\VLC\\vlc.exe";
}
else
{
$vlc = "vlc";
}
$cc = new cURL ();
$out = "tmp.ts";
unlink($out);
$canali = array("http://pebbles112-lh.akamaihd.net/i/daserste_1@97481/master.m3u8","http://pebbles112-lh.akamaihd.net/i/zdf_1@97483/master.m3u8","http://pebbles114-lh.akamaihd.net/i/wdr_1@97490/master.m3u8","http://pebbles107-lh.akamaihd.net/i/sat1_1@97461/master.m3u8","http://pebbles106-lh.akamaihd.net/i/rtl_1@97459/master.m3u8","http://pebbles107-lh.akamaihd.net/i/rtl2_1@97460/master.m3u8","http://pebbles106-lh.akamaihd.net/i/prosieben_1@97456/master.m3u8","http://pebbles108-lh.akamaihd.net/i/vox_1@97466/master.m3u8","http://pebbles105-lh.akamaihd.net/i/kabeleins_1@97453/master.m3u8","http://pebbles104-lh.akamaihd.net/i/dmax_1@97398/master.m3u8","http://pebbles107-lh.akamaihd.net/i/sixx_1@97462/master.m3u8","http://pebbles104-lh.akamaihd.net/i/dasvierte_1@97396/master.m3u8","http://pebbles105-lh.akamaihd.net/i/nickcc_1@97455/master.m3u8","http://pebbles107-lh.akamaihd.net/i/superrtl_1@97463/master.m3u8","http://pebbles105-lh.akamaihd.net/i/viva_1@97493/master.m3u8","http://pebbles108-lh.akamaihd.net/i/sport1_1@97464/master.m3u8","http://pebbles104-lh.akamaihd.net/i/n24_1@97406/master.m3u8","http://pebbles104-lh.akamaihd.net/i/ntv_1@97405/master.m3u8","http://pebbles113-lh.akamaihd.net/i/kika_1@97487/master.m3u8","http://pebbles110-lh.akamaihd.net/i/sf1_1@97474/master.m3u8","http://pebbles110-lh.akamaihd.net/i/sf2_1@97475/master.m3u8","http://pebbles113-lh.akamaihd.net/i/orf1_1@97573/master.m3u8","http://pebbles113-lh.akamaihd.net/i/orf2_1@97574/master.m3u8","http://pebbles114-lh.akamaihd.net/i/3plus_1@97489/master.m3u8","http://pebbles107-lh.akamaihd.net/i/artede_1@97463/master.m3u8","http://pebbles104-lh.akamaihd.net/i/sfinfo_1@97408/master.m3u8","http://pebbles112-lh.akamaihd.net/i/3sat_1@97480/master.m3u8","http://pebbles111-lh.akamaihd.net/i/zdfneo_1@97479/master.m3u8","http://pebbles113-lh.akamaihd.net/i/swr_1@97485/master.m3u8","http://pebbles107-lh.akamaihd.net/i/br3_1@97517/master.m3u8","http://pebbles111-lh.akamaihd.net/i/phoenix_1@97476/master.m3u8","http://pebbles105-lh.akamaihd.net/i/eurosportde_1@97452/master.m3u8","http://pebbles118-lh.akamaihd.net/i/joiz_1@135266/master.m3u8","http://pebbles119-lh.akamaihd.net/i/tzurich_1@135275/master.m3u8","http://pebbles119-lh.akamaihd.net/i/tsudost_1@135274/master.m3u8","http://pebbles104-lh.akamaihd.net/i/euronewsde_1@97402/master.m3u8","http://pebbles105-lh.akamaihd.net/i/cnn_1@97501/master.m3u8","http://pebbles105-lh.akamaihd.net/i/bbcworld_1@97498/master.m3u8","http://pebbles109-lh.akamaihd.net/i/rts1_1@97469/master.m3u8","http://pebbles109-lh.akamaihd.net/i/rts2_1@97470/master.m3u8","http://pebbles103-lh.akamaihd.net/i/tv5monde_1@97380/master.m3u8","http://pebbles101-lh.akamaihd.net/i/france2_1@97347/master.m3u8","http://pebbles100-lh.akamaihd.net/i/france3_1@97329/master.m3u8","http://pebbles102-lh.akamaihd.net/i/france5_1@97351/master.m3u8","http://pebbles102-lh.akamaihd.net/i/rtl9_1@97354/master.m3u8","http://pebbles109-lh.akamaihd.net/i/tf1_1@97468/master.m3u8","http://pebbles108-lh.akamaihd.net/i/m6_1@97467/master.m3u8","http://pebbles101-lh.akamaihd.net/i/artefr_1@97346/master.m3u8","http://pebbles110-lh.akamaihd.net/i/rsila1_1@97472/master.m3u8","http://pebbles110-lh.akamaihd.net/i/rsila2_1@97473/master.m3u8","http://pebbles103-lh.akamaihd.net/i/rai1_1@97382/master.m3u8","http://pebbles102-lh.akamaihd.net/i/rouge_1@97359/master.m3u8","http://pebbles106-lh.akamaihd.net/i/rtlnitro_1@97458/master.m3u8","http://pebbles114-lh.akamaihd.net/i/servus_1@97488/master.m3u8","http://pebbles114-lh.akamaihd.net/i/atv_1@97491/master.m3u8","http://pebbles100-lh.akamaihd.net/i/cn_1@97368/master.m3u8","http://pebbles100-lh.akamaihd.net/i/latele_1@97375/master.m3u8","http://pebbles117-lh.akamaihd.net/i/c9_1@135252/master.m3u8","http://pebbles117-lh.akamaihd.net/i/caju_1@135253/master.m3u8","http://pebbles118-lh.akamaihd.net/i/t1_1@135267/master.m3u8","http://pebbles108-lh.akamaihd.net/i/tm1w_1@135269/master.m3u8","http://pebbles120-lh.akamaihd.net/i/tttg_1@135278/master.m3u8","http://pebbles119-lh.akamaihd.net/i/ttzh_1@135271/master.m3u8","http://pebbles120-lh.akamaihd.net/i/ttsh_1@135279/master.m3u8","http://pebbles118-lh.akamaihd.net/i/tost_1@135270/master.m3u8","http://pebbles118-lh.akamaihd.net/i/tm1o_1@135268/master.m3u8","http://pebbles117-lh.akamaihd.net/i/cane_1@135254/master.m3u8","http://pebbles117-lh.akamaihd.net/i/tticino_1@135255/master.m3u8","http://pebbles119-lh.akamaihd.net/i/tbasel_1@135273/master.m3u8","http://pebbles105-lh.akamaihd.net/i/e4_1@97502/master.m3u8","http://pebbles102-lh.akamaihd.net/i/lemanbleu_1@97356/master.m3u8","http://pebbles106-lh.akamaihd.net/i/film4_1@97503/master.m3u8","http://pebbles119-lh.akamaihd.net/i/tbarn_1@135272/master.m3u8","http://pebbles120-lh.akamaihd.net/i/tbielingue_1@135280/master.m3u8");
$chn = array();
for ($i=0;$i<count($canali);$i++){
$xxx = explode("/", $canali[$i]);
$xxx = explode("_", $xxx[4]);
$chn[] = strtoupper($xxx[0]);
}
/*
for ($i=0; $i<count($chn); $i++){
echo "$i) " . $chn [$i] . ( (( $i + 1 )% 4 == 0 ) ? "\r\n" : str_repeat ( ' ' , 17- strlen ($chn [$i]. $i )) ); // thanks to omepiet
}
*/
$inp = $argv[1];
$quality = "1300";
$temp = $canali[$inp];
$chname = $chn[$inp];
$uri = $cc->get($temp);
echo "\r\n\r\nPlaying " . $chname . "\r\n";
preg_match("|http://(.*)|", $uri, $tmp);
$url = preg_replace("|/index_200_|", "/index_${quality}_", $tmp[0]);
$m3u8man = $cc->get($url);
preg_match("/TARGETDURATION:(.*)/", $m3u8man, $match);
$piecedur = trim($match[1]);
preg_match("/MEDIA-SEQUENCE:(.*)/", $m3u8man, $match);
$pieceseq = trim($match[1]);
preg_match("|http://(.*)|", $m3u8man, $tmp);
$piecepat = preg_replace("/$pieceseq/", '###', $tmp[0]);
function dump_stream($pieceseq, $piecepat, $out) {
$pezzo = preg_replace("/###/", "$pieceseq", $piecepat);
$cc = new cURL ();
$fragment = $cc->get($pezzo);
file_put_contents("$out", $fragment, FILE_APPEND);
}
$ciclo = "0";
while(1) {
$sleep = $piecedur;
$ciclo++;
if ($ciclo == 5) {
if (filesize("$out") == 0) {
echo "\r\n\r\nNo available stream\r\n\r\n";
break;
} else {
$cmd = $vlc . " --quiet --meta-title=\"" . $chname . " by Darby_Crash\" " . $out;
if ($windows) {
pclose(popen("start /B ". $cmd, "r")); // thanks to jairoxyz
} else {
shell_exec($cmd . " > /dev/null 2>/dev/null &");
}
}
} else if ($ciclo < 5) {
$sleep = 0;
}
$bef = time();
dump_stream($pieceseq, $piecepat, $out);
$aft = time();
$delta = $aft - $bef;
$to = $sleep - $delta;
$pieceseq++;
echo "\r\nDltime " . $delta . " sec\r\nSleeping " . $to . " sec\r\n";
sleep($to);
}
?>
Je veux créer une liste avec les options
DASERSTE
ZDF
WDR
...
et si la personne clique sur (par exemple) DASERSTE, cela envoie
php wilmaa.php 0
et si elle clique sur WDR, alors
php wilmaa.php 2
J'ai installé zenitor sans problème, sélectionné liste et tableaux, mais je sèche sur comment rentrer mes options.
Merci pour ton temps.