0

I have a script that gathers a session id, puts it together with a URL and then redirects to the URL. This works perfectly in the browser and mx player for Android. But on kodi, there seems to be an error. Kodi seems to use my server as the host of the file. So instead of using: streamsite.com/index.m3u8, it uses MYSERVER.com/index.m3u8. This is driving me crazy since I do not even know how to code. This is my script:

<?php



$url = link.tojson
$cURL = curl_init();
curl_setopt($cURL,CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_HTTPGET, true);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Accept: application/json' )); 

$result = curl_exec($cURL); 
curl_close($cURL);

$json=json_decode($result,true);

$pre=$json[0]['id'];


$stream='streamsite.com/index.m3u8?&sessionId='.$pre. '';

ini_set('user_agent', 'Mozilla/5.0 (Linux; Android 6.0; en-US; Nexus 5 Build/Veneno ROM) MXPlayer/1.8.3
');

header("Location:$stream");
die();




?>
miken32
  • 42,008
  • 16
  • 111
  • 154
Bruhbruh
  • 11
  • 2

1 Answers1

1

Try using a proper URL:

$stream="http://streamsite.com/index.m3u8?sessionId=$pre";
header("Location:$stream");

Also I don't know what you think that call to ini_set() will accomplish, but it won't.

miken32
  • 42,008
  • 16
  • 111
  • 154
  • Thanks for your reply, reason the link isn't proper is cause I'm only allowed to post to links as a new user. – Bruhbruh Feb 03 '16 at 22:43
  • Yes they are. If i could somehow make my server save /index.m3u8 as a directory that links directly to the full link, i think it would fix the issue. – Bruhbruh Feb 03 '16 at 23:13
  • The only reason the local server name would be used is if you're providing a relative URL, or you have a broken client. – miken32 Feb 03 '16 at 23:19
  • Sorry, not too good with code. What is a relative URL and what would make a client broken? – Bruhbruh Feb 03 '16 at 23:21
  • A relative URL does not have http at the beginning. A broken client is one that doesn't follow redirects properly. – miken32 Feb 03 '16 at 23:22
  • Thank you so much for your help. My links all have the http at the beginning, however, I find that when the redirect occurs at the header("Location: $stream:); part, i find that the http:// is dropped as it is an ip address. so the header is supposed to link to http://ipaddress but instead it redirects to ipaddress. Anything I can do about that? – Bruhbruh Feb 03 '16 at 23:26
  • PHP does not arbitrarily "drop" pieces of strings. Either you're not adding it, or your client is ignoring it. – miken32 Feb 03 '16 at 23:28
  • I found a link to a kodi thread that talks about relative urls and how it affects playback. I find that the issue stated in the second post is similar to mine. The user seemed to save the url into a .strm file( which is basically a file that holds text and is readable by kodi). How would I make php, save $stream as text into a .strm file? Is that even possible? Thanks again. THis is the link http://forum.kodi.tv/showthread.php?tid=194844 Edit: I also have another question, would it be possible to have my php script modify the mime type of the stream? I have a feeling thats why kodi wont work. – Bruhbruh Feb 03 '16 at 23:33