issue with spaces in m3u list without tvg-id
I have m3u list generated by some plugin with channel names only like this:
#EXTM3U
#EXTINF:-1,TVP 1 HD
plugin://plugin.video.pilot.wp?action=PLAY&channel=3
#EXTINF:-1,TVP 2 HD
plugin://plugin.video.pilot.wp?action=PLAY&channel=5
#EXTINF:-1,Polsat
plugin://plugin.video.pilot.wp?action=PLAY&channel=9
The names are correct and match the id and display name in xmltv file:
...<?xml version="1.0" encoding="UTF-8"?>
<tv generator-info-name="WebGrab+Plus/w MDB & REX Postprocess -- version V2.1.5 -- Jan van Straaten" generator-info-url="http://www.webgrabplus.com">
<channel id="TVP 1 HD">
<display-name lang="pl">TVP 1 HD</display-name>
<icon src="https://i.iplsc.com/-/0004NCS70UBYWOOF-C120.jpg" />
<url>http://www.programtv.interia.pl</url>
</channel>
<channel id="TVP 2 HD">
<display-name lang="pl">TVP 2 HD</display-name>
<icon src="https://i.iplsc.com/-/0004NCS92YQSRH44-C120.jpg" />
<url>http://www.programtv.interia.pl</url>
</channel>
<channel id="Polsat">
<display-name lang="pl">Polsat</display-name>
<icon src="https://i.iplsc.com/-/0001AEVS25LL77FJ-C120.jpg" />
<url>http://www.programtv.interia.pl</url>
</channel>
After the import only the channels without space show program and can record it. For other channels it shows error that channel was not found.
When I run sql command to show all the streams I see only tvg-id assigned in channels that have no space:
sqlite> SELECT * FROM streams LIMIT 3;
1|TVP+1+HD|TVP+1+HD||||plugin://plugin.video.pilot.wp?action=PLAY&channel=3
2|TVP+2+HD|TVP+2+HD||||plugin://plugin.video.pilot.wp?action=PLAY&channel=5
3|Polsat|Polsat|Polsat|||plugin://plugin.video.pilot.wp?action=PLAY&channel=9
I think the problem is when it tries to find missing streams and update them from channel names. It doesn't find any match as the stream tvg_name is escaped and channel names are not. I'm not sure what the best solution would be, maybe try search first with escaped name and if there is not match try to unescape the string and search again?
The cause of it is somewhere around the lines below, where it escapes the name and assigns it to tvg_name if that tag doesn't exist:
name = channel[0].rsplit(',', 1)[-1].strip()
name = name.encode("utf8")
name = urllib.quote_plus(name)
tvg_name = re.search('tvg-name="(.*?)"', channel[0])
if tvg_name:
tvg_name = tvg_name.group(1)
else:
tvg_name = name
It could be around the missing_streams section where it tries to guess a tvg-id if it is missing. https://github.com/primaeval/plugin.video.iptv.recorder/blob/master/main.py#L2670
Yeah, but to do that it uses tvg_name which can be escaped or not depending if tvg-name tag was found or not. When it's used later in missing streams section it needs to apply the same logic, either un-escape or use plain tvg_name however there is no any info it was escaped or not. I think adding simple flag whether it was escaped or not could resolve that issue. In general I suggest to store original values in DB and escape them only when needed (i.e. creating URLs etc...), it would simplify code and make it more easy to change.
The reason I added the escaping was for the script that gets launched from IPTV Simple Client. If you can come up with a better way to do it I'll add it in.
I've added in a few tests now that cover some of the situations with missing data. All the channels get loaded up by IPTV Simple Client but not with IPTV Recorder.
The code that IPTV Simple Client uses to load up the data is here. https://github.com/kodi-pvr/pvr.iptvsimple/blob/master/src/PVRIptvData.cpp