How to reload m3u list without restarting Kodi!
#1
Hello everyone,
I use a remote m3u list that is updated every 2 hours. I need IPTV Simple Client to refresh that list every 2 hours, otherwise the links in the list do not work.
I wonder if there's a way to refresh this list automatically without restarting Kodi.
I have try to disable and enable IPTV Simple Client with a script and that seems to work, however randomly, by disabling the IPTV Simple Client with the script, it will crash Kodi and I will have to enable and disable Live TV from the menu for it to works again.

Here is the script that I'm using right now!
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","params":{"addonid":"pvr.iptvsimple","enabled":"toggle"},"id":1}' http://localhost:8080/jsrpc

Im looking for an alternative.

Thanks in advance
Reply
#2
What about executing xbmc-send in console?

xbmc-send --action="XBMC.StopPVRManager"
xbmc-send --action="XBMC.StartPVRManager"
Reply
#3
Hi, I'm also interested in this. I have openelec on rpi3 and I'm new to all of this so can you help telling me where i need to put this script? I found this on some site but do not know how and where to put this:

Here is a script that will reload IPTV Simple Client channel lists without restarting Kodi. This script is for linux although you could download the cUrl utility for windows or for Cygwin. You will need to adapt the script for windows but i will try to make one available in the future.

This script simply calls Kodi's JSON API to disable and then enable IPTV Simple Client, which has as side effect to reload the channel list. This also has the advantage of being transparent, meaning your current stream, would you be watching one, will not be stopped by this process.

For those of you knowing JSON, here is the request.

{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","params":{"addonid":"pvr.iptvsimple","enabled":"toggle"},"id":1}
1#reloadiptv.sh
2curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","params":{"addonid":"pvr.iptvsimple","enabled":"toggle"},"id":1}' http://localhost:8080/jsonrpc
3curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","params":{"addonid":"pvr.iptvsimple","enabled":"toggle"},"id":1}' http://localhost:8080/jsonrpc
Reply
#4
Hello,
I am bumping this topic, as of Krypton v17 using tinostp's solution sometimes works on Kodi on PC. While on Kodi on raspberry pi, behavior is different, stream watching is stopped.
I checked API http://kodi.wiki/view/JSON-RPC_API/v8#PVR.GetChannels but this function reads only the current cached database.
Is there someway to issue API call to PVR Manager "Clear Data" ? Maybe that will be best ?

UPDATE:
Very dirty hack that works for me.
I have achieved successful results of reloading channels on Stop of channel or switch of channel both trigger CloseLiveStream() function from PVRIptvData.cpp which is part of pvr.iptvsimple.
The instructions suppose you are using Kodi v18 "Leia" nightly at the time of writing, with time code will be updated and latest development version will be different.

To build pvr.iptvsimple for:
git clone https://github.com/xbmc/xbmc.git
git clone https://github.com/kodi-pvr/pvr.iptvsimple
cd pvr.iptvsimple && mkdir build && cd build
cmake -DADDONS_TO_BUILD=pvr.iptvsimple -DADDON_SRC_PREFIX=../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../xbmc/addons -DPACKAGE_ZIP=1 ../../xbmc/cmake/addons
make

Built addon is located in "xbmc/addons/pvr.iptvsimple", replace with "/Applications/Kodi.app/Contents/Resources/Kodi/addons/pvr.iptvsimple" on MacOS

Before executing make, make sure you patch two files in "src" dir of pvr.iptvsimple, "client.cpp" and "PVRIptvData.cpp":

client.cpp replace CloseLiveStream function with the following:
void CloseLiveStream(void)
{
if (m_data)
{
m_data->ReloadPlayList("http://your_source/path1/path2/path3/MyListOfChannels.m3u");
}
m_bIsPlaying = false;
}

PVRIptvData.cpp replace ReloadPlayList function with the following:
void PVRIptvData::ReloadPlayList(const char * strNewPath)
{

m_strM3uUrl = strNewPath;
m_channels.clear();

if (LoadPlayList())
{
PVR->TriggerChannelUpdate();
PVR->TriggerChannelGroupsUpdate();
}
}

It is hardcoded url which is not good practice, but you can extend from there easily. Hope it helps someone.
Reply
#5
Hello...someone on other forum gave a solution.

1. you must have own server (it can be on some free hosting)
2. Create m3u and put it into server or localy. The m3u data will be fixed...will not change.
m3u must look like:
#EXTM3U
#EXTINF:-1 group-title="film" tvg-id="HBO" tvg-name="HBO" tvg-logo="HBO.png",[COLOR sandybrown]HBO[/COLOR]
http://myserver.ml/tv/HBO.php
#EXTINF:-1 group-title="film" tvg-id="HBO1" tvg-name="HBO1" tvg-logo="HBO1.png",[COLOR sandybrown]HBO1[/COLOR]
http://myserver.ml/tv/HBO1.php
#EXTINF:-1 group-title="film" tvg-id="HBO2" tvg-name="HBO2" tvg-logo="HBO2.png",[COLOR sandybrown]HBO2[/COLOR]
http://myserver.ml/tv/HBO.php
.....
Put insede m3u the php links...
3. on your server make folder (I made folder called "tv") insede you put php files for every channel
php must look like:
<?php
header("Location:http://HBO_stream.m3u8");
?>
4. How to automate whole proces?
I made master php which is trigered every hour from cron jobs. That master php update every links in all php files. It look like:
<?php
$programi = array ("HBO","HBO1","HBO2");
$links = array ( ##actual stream links for every channel ##); //put actual links in array for every channel

//loop over all channels
for ($i = 1; $i <= 3; $i++)
{   
// prepare the structure to put it into every php file
    $text1= '<?php' . PHP_EOL .
    'header("Location:' . $links[$i] .'");' . PHP_EOL .
    '?>';

//open every channel php file in folder "tv" and change the content with actual data (when you run the master php first time it create all php for every channel
    $myfile = fopen("tv/". $programi[$i] .".php", "w") or die("Unable to open file!");
    fwrite($myfile, $text1);
    fclose($myfile);
}
echo 'Done';
?>

conclusion:
Put the master php file into cron jobs and automaticly change data every (hour, day, as you want).
m3u file is not changing. I use free domain name on freenom.com and free hosting on 000webhost.com but you can use others.
If someone want more information just ask.
Reply
#6
(2017-05-07, 11:27)ivopz Wrote: Hello,
I am bumping this topic, as of Krypton v17 using tinostp's solution sometimes works on Kodi on PC. While on Kodi on raspberry pi, behavior is different, stream watching is stopped.
I checked API http://kodi.wiki/view/JSON-RPC_API/v8#PVR.GetChannels but this function reads only the current cached database.
Is there someway to issue API call to PVR Manager "Clear Data" ? Maybe that will be best ?

UPDATE:
Very dirty hack that works for me.
I have achieved successful results of reloading channels on Stop of channel or switch of channel both trigger CloseLiveStream() function from PVRIptvData.cpp which is part of pvr.iptvsimple.
The instructions suppose you are using Kodi v18 "Leia" nightly at the time of writing, with time code will be updated and latest development version will be different.

To build pvr.iptvsimple for:
git clone https://github.com/xbmc/xbmc.git
git clone https://github.com/kodi-pvr/pvr.iptvsimple
cd pvr.iptvsimple && mkdir build && cd build
cmake -DADDONS_TO_BUILD=pvr.iptvsimple -DADDON_SRC_PREFIX=../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../xbmc/addons -DPACKAGE_ZIP=1 ../../xbmc/cmake/addons
make

Built addon is located in "xbmc/addons/pvr.iptvsimple", replace with "/Applications/Kodi.app/Contents/Resources/Kodi/addons/pvr.iptvsimple" on MacOS

Before executing make, make sure you patch two files in "src" dir of pvr.iptvsimple, "client.cpp" and "PVRIptvData.cpp":

client.cpp replace CloseLiveStream function with the following:
void CloseLiveStream(void)
{
if (m_data)
{
m_data->ReloadPlayList("http://your_source/path1/path2/path3/MyListOfChannels.m3u");
}
m_bIsPlaying = false;
}

PVRIptvData.cpp replace ReloadPlayList function with the following:
void PVRIptvData::ReloadPlayList(const char * strNewPath)
{

m_strM3uUrl = strNewPath;
m_channels.clear();

if (LoadPlayList())
{
PVR->TriggerChannelUpdate();
PVR->TriggerChannelGroupsUpdate();
}
}

It is hardcoded url which is not good practice, but you can extend from there easily. Hope it helps someone.

Hi! Great job!
Is this way work in 18.5 version? Because I can't find ReloadPlayList function in PVRIptvData.cpp. This function is not declared in  PVRIptvData.cpp and I find it in this file as : 
Code:
m_playlistLoader.ReloadPlayList();
Such a function is declared in PlaylistLoader.cpp, but looks like: 
Code:
void PlaylistLoader::ReloadPlayList()
{
  m_m3uLocation = Settings::GetInstance().GetM3ULocation();

  m_channels.Clear();
  m_channelGroups.Clear();

  if (LoadPlayList())
  {
    PVR->TriggerChannelUpdate();
    PVR->TriggerChannelGroupsUpdate();
  }
}
 and I'm not sure how to modify it. Could you please help me?
Reply
#7
That code is from the kodi 19 "Matrix" version. There is no reload in Kodi 18 as far as I'm aware.
Maintainer of Enigma2 PVR addon: repo, docschangelog
How to create a full debug: here
Reply

Logout Mark Read Team Forum Stats Members Help
How to reload m3u list without restarting Kodi!0