Hello:
When I create a mux in an Automatic IPTV network, with a URL like this:
pipe://opt/bin/streamlink https://pluto.tv/es/live-tv/60218baa464ef900073168c1 best --stdout
It Works.
But when I use a script similar to yours:
/storage/videos/plutotv.py
with this code:
#!/opt/bin/python
import requests
from datetime import datetime, timedelta, timezone
import xml.etree.ElementTree as ET
import socket
import io
# CONFIG #############################################################################################
SOCKET = "/storage/.kodi/userdata/addon_data/service.tvheadend43/epggrab/xmltv.sock" # Path to your UNIX socket
######################################################################################################
now = datetime.now(timezone.utc)
start_time = now - timedelta(
minutes=now.minute % 30, seconds=now.second, microseconds=now.microsecond
)
stop_time = start_time + timedelta(hours=8)
epg_begin = start_time.strftime("%Y-%m-%dT%H:%M:%S-00:00")
epg_end = stop_time.strftime("%Y-%m-%dT%H:%M:%S-00:00")
data = requests.get(
f"https://api.pluto.tv/v2/channels?start={epg_begin}&stop={epg_end}"
).json()
m3u = "#EXTM3U\n"
root = ET.Element("tv")
programmes = []
for channel in data:
channel_element = ET.SubElement(root, "channel", id="pluto-" + channel["_id"])
ET.SubElement(channel_element, "display-name").text = channel["name"]
ET.SubElement(channel_element, "channel-number").text = str(channel["number"])
ET.SubElement(channel_element, "icon").text = channel.get("colorLogoPNG", {}).get(
"path", ""
)
m3u += f'#EXTINF:-1 tvg-ID="{"pluto-" + channel["_id"]}" tvg-chno="{channel["number"]}" tvg-name="{channel["name"]}" tvg-logo="{channel.get("colorLogoPNG", {}).get("path", "")}", {channel["name"]}\n'
m3u += (
f"pipe:///opt/bin/streamlink 'https://pluto.tv/live-tv/{channel['_id']}' best --stdout\n"
)
for programme in channel["timelines"]:
programme_data = {
"start": programme["start"],
"stop": programme["stop"],
"channel": "pluto-" + channel["_id"],
"title": programme["title"],
"episode": programme.get("episode", {}),
}
programmes.append(programme_data)
for programme in programmes:
start_time = datetime.fromisoformat(programme["start"]).strftime(
"%Y%m%d%H%M%S +0000"
)
stop_time = datetime.fromisoformat(programme["stop"]).strftime("%Y%m%d%H%M%S +0000")
programme_element = ET.SubElement(
root,
"programme",
start=start_time,
stop=stop_time,
channel=programme["channel"],
)
ET.SubElement(programme_element, "title").text = programme.get("title", "Untitled")
ET.SubElement(programme_element, "sub-title").text = programme["episode"].get(
"name", ""
)
ET.SubElement(programme_element, "desc").text = programme["episode"].get(
"description", ""
)
ET.SubElement(programme_element, "episode-num").text = (
f'S{programme["episode"].get("season", 0)}E{programme["episode"].get("number", 0)}'
)
ET.SubElement(programme_element, "category").text = programme["episode"].get(
"genre", ""
)
ET.SubElement(programme_element, "category").text = programme["episode"].get(
"subGenre", ""
)
ET.SubElement(programme_element, "category").text = programme.get("category", "")
tree = ET.ElementTree(root)
ET.indent(tree, space="\t", level=0)
xml_bytes = io.BytesIO()
tree.write(xml_bytes, encoding="UTF-8", xml_declaration=True)
try:
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
s.connect(SOCKET)
xml_bytes.seek(0)
s.sendall(xml_bytes.read())
except:
pass
# with open("pluto.xmltv", "wb") as file:
# tree.write(file, encoding="utf-8", xml_declaration=True)
print(m3u)
And I try to scan the automatic IPTV network:
pipe:///storage/videos/plutotv.py
tvheadend says:
2024-12-06 22:30:25.271 spawn: Executing "/storage/videos/plutotv.py"
2024-12-06 22:30:25.520 iptv: unknown playlist format for network 'Pluto'

My system:
- CoreELEC 21.1.1 (Kodi-linux system)
- Tvheadend addon for CoreELEC
- SOCKET is here for tvheadend CoreELEC addon: "/storage/.kodi/userdata/addon_data/service.tvheadend43/epggrab/xmltv.sock" # Path to your UNIX socket
- streamlink installed using:
opkg install python3-pip
pip3 install streamlink
Streamlink works, so I suppose that I should change something in the plutotv.py, but I don't know what.
Thanks in advance and kind regards