Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset EXTGRP tag when a channel URL is read from M3U Playlist #784

Merged
merged 4 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ http://path-to-stream/live/channel-z.ts
- `media-dir`: An optional directory path which should specifiy where in the hierarchy this media entry should be represented. The path separator is `/`.
- `media-size`: An optional size of the media entry in bytes. Note: this is not usually available for VOD libraries.
- `realtime`: Live streams in PVR disable features such as passthrough by default. Set this item to "false" to bypass this behaviour if the stream should not be treated like VOD/Media in the UI.
- `#EXTGRP`: A semi-colon separted list of channel groups that this channel belongs to.
- `#EXTGRP`: A semi-colon separted list of channel groups. Note that this is a begin directive, i.e. all channels following this directive will have these groups until an empty `#EXTGRP` directive is reached. These groupings wil also be reset by any `group-title` tag for an `#EXTINF` channel directive.
- `#KODIPROP`: A single property in the format `key=value` that can be passed to Kodi. Multiple can be passed each on a separate line.
- `#EXTVLCOPT`: A single property in the format `key=value` that can be passed to Kodi. Multiple can be passed each on a separate line. Note that if either a `http-user-agent` or a `http-referrer` property is found it will added to the URL as a HTTP header as `user-agent` or `referrer` respectively if not already provided in the URL. These two fields specifically will be dropped as properties whether or not they are added as header values. They will be added in the same format as the `URL` below.
- `#EXT-X-PLAYLIST-TYPE`: If this element is present with a value of `VOD` (Video on Demand) the stream is marked as not being live.
Expand Down
2 changes: 1 addition & 1 deletion pvr.iptvsimple/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.iptvsimple"
version="20.12.0"
version="20.13.0"
name="IPTV Simple Client"
provider-name="nightik and Ross Nicholson">
<requires>@ADDON_DEPENDS@
Expand Down
5 changes: 5 additions & 0 deletions pvr.iptvsimple/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

v20.13.0
- Only reset channel group list when a channel URL is read from M3U playlist
- Modify EXTGRP behaviour so it is a begin directive for channels groups, i.e. it carries across channels unless reset by an empty EXTGRP directive or any group-title tag for a EXTINF channel directive

v20.12.0
- Extract season from medis title for path if not available
- Set default to include media Group name in path if no dir present
Expand Down
17 changes: 14 additions & 3 deletions src/iptvsimple/PlaylistLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ bool PlaylistLoader::LoadPlayList()
std::vector<int> currentChannelGroupIdList;
bool channelHadGroups = false;
bool xeevCatchup = false;
bool groupsFromBeginDirective = false; //From EXTGRP begin directive

Channel tmpChannel{m_settings};
MediaEntry tmpMediaEntry{m_settings};
Expand Down Expand Up @@ -170,7 +171,6 @@ bool PlaylistLoader::LoadPlayList()
if (StringUtils::StartsWith(line, M3U_INFO_MARKER)) //#EXTINF
{
tmpChannel.SetChannelNumber(m_channels.GetCurrentChannelNumber());
currentChannelGroupIdList.clear();

isMediaEntry = line.find(MEDIA) != std::string::npos ||
line.find(MEDIA_DIR) != std::string::npos ||
Expand All @@ -179,11 +179,12 @@ bool PlaylistLoader::LoadPlayList()

overrideRealTime = GetOverrideRealTime(line);

const std::string groupNamesListString = ParseIntoChannel(line, tmpChannel, tmpMediaEntry, currentChannelGroupIdList, epgTimeShift, catchupCorrectionSecs, xeevCatchup);
const std::string groupNamesListString = ParseIntoChannel(line, tmpChannel, tmpMediaEntry, epgTimeShift, catchupCorrectionSecs, xeevCatchup);

if (!groupNamesListString.empty())
{
ParseAndAddChannelGroups(groupNamesListString, currentChannelGroupIdList, tmpChannel.IsRadio());
groupsFromBeginDirective = false;
channelHadGroups = true;
}
}
Expand All @@ -201,10 +202,15 @@ bool PlaylistLoader::LoadPlayList()
}
else if (StringUtils::StartsWith(line, M3U_GROUP_MARKER)) //#EXTGRP:
{
//Clear any previous Group Ids
currentChannelGroupIdList.clear();
groupsFromBeginDirective = false;

const std::string groupNamesListString = ReadMarkerValue(line, M3U_GROUP_MARKER);
if (!groupNamesListString.empty())
{
ParseAndAddChannelGroups(groupNamesListString, currentChannelGroupIdList, tmpChannel.IsRadio());
groupsFromBeginDirective = true;
channelHadGroups = true;
}
}
Expand Down Expand Up @@ -249,6 +255,11 @@ bool PlaylistLoader::LoadPlayList()
overrideRealTime = false;
isMediaEntry = false;
channelHadGroups = false;

// We want to clear the groups if they came from a 'group-title' tag from a channel
// But if it's from an EXTGRP tag we don't as that's a begin directive.
if (!groupsFromBeginDirective)
currentChannelGroupIdList.clear();
}
}

Expand Down Expand Up @@ -277,7 +288,7 @@ bool PlaylistLoader::LoadPlayList()
return true;
}

std::string PlaylistLoader::ParseIntoChannel(const std::string& line, Channel& channel, MediaEntry& mediaEntry, std::vector<int>& groupIdList, int epgTimeShift, int catchupCorrectionSecs, bool xeevCatchup)
std::string PlaylistLoader::ParseIntoChannel(const std::string& line, Channel& channel, MediaEntry& mediaEntry, int epgTimeShift, int catchupCorrectionSecs, bool xeevCatchup)
{
size_t colonIndex = line.find(':');
size_t commaIndex = line.rfind(','); //default to last comma on line in case we don't find a better match
Expand Down
2 changes: 1 addition & 1 deletion src/iptvsimple/PlaylistLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace iptvsimple
static std::string ReadMarkerValue(const std::string& line, const std::string& markerName);
static void ParseSinglePropertyIntoChannel(const std::string& line, iptvsimple::data::Channel& channel, const std::string& markerName);

std::string ParseIntoChannel(const std::string& line, iptvsimple::data::Channel& channel, data::MediaEntry& mediaEntry, std::vector<int>& groupIdList, int epgTimeShift, int catchupCorrectionSecs, bool xeevCatchup);
std::string ParseIntoChannel(const std::string& line, iptvsimple::data::Channel& channel, data::MediaEntry& mediaEntry, int epgTimeShift, int catchupCorrectionSecs, bool xeevCatchup);
void ParseAndAddChannelGroups(const std::string& groupNamesListString, std::vector<int>& groupIdList, bool isRadio);

std::string m_m3uLocation;
Expand Down
Loading