PHP - (Ayuda) remplazar url

 
Vista:

(Ayuda) remplazar url

Publicado por Martin Piotto (3 intervenciones) el 04/03/2018 01:27:19
Hola, gracias necesito su ayuda.

este código php devuelve la ruta /vxfmt=hls/playlist.m3u8 pero necesito que devuelva /vxfmt=hls/var300000/playlist.m3u8
¿Qué línea debo agregar o modificar? Gracias

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php ob_start();
 
function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
 
//-------------------------------------------------------
 
$ch = curl_init('http://tv.vera.com.uy/canal/10425');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
$result1 = curl_exec($ch);
 
preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $result1, $matches1);
$cookies1 = array();
foreach($matches1[1] as $item1) {
parse_str($item1, $cookie1);
$cookies1 = array_merge($cookies1, $cookie1);
}
 
$phpsessid=$cookies1['PHPSESSID'];
$phpsessid='PHPSESSID='.$phpsessid;
$veratv='_veratv='.$cookies1['_veratv'];
 
//-------------------------------------------------------------
 
$cookiestage2 = $phpsessid.";".$veratv;
$ch2 = curl_init('https://login.vera.com.uy/login…');
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_HEADER, 1);
curl_setopt($ch2, CURLINFO_HEADER_OUT, true);
curl_setopt($ch2, CURLOPT_COOKIE, $cookiestage2);
$result2 = curl_exec($ch2);
 
preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $result2, $matches2);
$cookies2 = array();
foreach($matches2[1] as $item2) {
parse_str($item2, $cookie2);
$cookies2 = array_merge($cookies2, $cookie2);
}
 
$jsessionid='JSESSIONID='.$cookies2['JSESSIONID'];
 
//--------------------------------------------------------------
 
$cookiestage3 = $jsessionid.";".$cookiestage2;
$ch3 = curl_init('http://tv.vera.com.uy/canal/10425');
curl_setopt($ch3, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch3, CURLOPT_HEADER, 1);
curl_setopt($ch3, CURLINFO_HEADER_OUT, true);
curl_setopt($ch3, CURLOPT_COOKIE, $cookiestage3);
$result3 = curl_exec($ch3);
 
//-----------------------------------------------------------
 
$urlbox = get_string_between($result3, " $('#iframePlayerContent').attr('src', '", "');");
 
$ch4 = curl_init($urlbox);
curl_setopt($ch4, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch4, CURLOPT_HEADER, 1);
curl_setopt($ch4, CURLINFO_HEADER_OUT, true);
curl_setopt($ch4, CURLOPT_COOKIE, $cookiestage3);
curl_setopt($ch4, CURLOPT_REFERER, 'http://tv.vera.com.uy/canal/10425');
$result4 = curl_exec($ch4);
 
//---------------------------------------------------------------
 
$playlist = get_string_between($result4, 'file: "', '",autostart');
//$parsedurl = explode("/", $playlist);
 
header("Location: $playlist");
 
//$ch5 = curl_init($playlist);
//curl_setopt($ch5, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch5, CURLOPT_HEADER, 0);
//$result5 = curl_exec($ch5);
 
//$master=str_replace("var"," http://".$parsedurl[2]."/".$parsedurl[3]."/".$parsedurl[4]."/var",$result5);
//echo($master);
 
exit;
 
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de santi
Val: 588
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

(Ayuda) remplazar url

Publicado por santi (204 intervenciones) el 07/03/2018 01:33:32
Hola,

prueba a hacer un replace:

1
2
3
$url = /vxfmt=hls/playlist.m3u8;
 
$url = str_replace('/vxfmt=hls/', '/vxfmt=hls/var300000/', $url); //el valor de $url es -> /vxfmt=hls/var300000/playlist.m3u8

;)
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar