(2018-05-18, 03:19)Payam30 Wrote: Hi,Thanks for your respose. Could you please explain it to me. can you make an example with the link I provided? do O make such file for each channel?
I know it's an old post, but I came across it trying to solve a similar issue myself, trying to get a stream from a webcam with a changing token. I've probably taken way too many detours, but here's how I solved it:
1. On my PHP server, I created a .php file to get the current working URL for the stream. In my case, the video url is always
https://url_of_the_videostream?token= followed by a long token string. This script (with a big thank you to
http://scraping.pro/scraping-in-php-with-curl/) gets the webpage which has the embedded webcam url with current token string, uses a bit of regex to find that token, and puts it together with the fixed part of the url to make the currently working url:
php:
<?php
$curl = curl_init('https://www.url with the embedded code for the webcam/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$page = curl_exec($curl);
$stream_name = "Webcam";
if(curl_errno($curl)) // check for execution errors
{
echo 'Scraper error: ' . curl_error($curl);
exit;
}
curl_close($curl);
$regex = '/token=(.*?)"/';
if ( preg_match($regex, $page, $match) )
$stream_url = "https://url_of_the_videostream?token=".$match[1];
else ($stream_url = "error");
header('Content-Type: application/octet-stream');
echo "#EXTM3U\n";
echo "#EXTINF:-1," . $stream_name . "\n";
echo $stream_url;
?>
2. Because Kodi won't play a .php file, I added this line to my .htaccess, so this .php file that already has the content of a .m3u, now also has the right filename:
html:
RewriteRule webcam\.m3u /webcam.php
3. So far, that's all on my PHP server. On the storage attached to my Kodi, I created a
webcam.strm file with just the URL of the (non existant) .m3u:
html:
http://root_of_my_web_server/webcam.m3u
And then when you play that .strm file, it calls on the .m3u which is really a .php!
Hope that helps someone!