Skip to content

Commit 7692a85

Browse files
authored
Merge pull request #545 from phunkyfish/fix-episode-num
Fix episode num
2 parents c277bf8 + 2253c09 commit 7692a85

File tree

9 files changed

+72
-12
lines changed

9 files changed

+72
-12
lines changed

pvr.iptvsimple/addon.xml.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<addon
33
id="pvr.iptvsimple"
4-
version="7.6.9"
4+
version="7.6.10"
55
name="PVR IPTV Simple Client"
66
provider-name="nightik and Ross Nicholson">
77
<requires>@ADDON_DEPENDS@
@@ -21,6 +21,12 @@
2121
<icon>icon.png</icon>
2222
</assets>
2323
<news>
24+
v7.6.10
25+
- Fixed: Fix episode number when there is no season
26+
- Fixed: Return server error if channels or groups could not be loaded due to missing file so they are not cleared in Kodi
27+
- Translations updates from Weblate
28+
- id_id, ko_kr, pl_pl
29+
2430
v7.6.9
2531
- Translations updates from Weblate
2632
- pl_pl
@@ -30,7 +36,7 @@ v7.6.8
3036
- zh_cn
3137

3238
v7.6.7
33-
Translations updates from Weblate
39+
- Translations updates from Weblate
3440
- id_id, lt_lt
3541

3642
v7.6.6

pvr.iptvsimple/changelog.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
v7.6.10
2+
- Fixed: Fix episode number when there is no season
3+
- Fixed: Return server error if channels or groups could not be loaded due to missing file so they are not cleared in Kodi
4+
- Translations updates from Weblate
5+
- id_id, ko_kr, pl_pl
6+
17
v7.6.9
28
- Translations updates from Weblate
39
- pl_pl

src/PVRIptvData.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,13 @@ ADDON_STATUS PVRIptvData::Create()
6565
Settings::GetInstance().ReadFromAddon(kodi::GetBaseUserPath(), kodi::GetAddonPath());
6666

6767
m_channels.Init();
68+
m_channelGroups.Init();
6869
m_playlistLoader.Init();
69-
m_playlistLoader.LoadPlayList();
70+
if (!m_playlistLoader.LoadPlayList())
71+
{
72+
m_channels.ChannelsLoadFailed();
73+
m_channelGroups.ChannelGroupsLoadFailed();
74+
}
7075
m_epg.Init(EpgMaxPastDays(), EpgMaxFutureDays());
7176

7277
kodi::Log(ADDON_LOG_INFO, "%s Starting separate client update thread...", __FUNCTION__);

src/iptvsimple/ChannelGroups.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,16 @@ using namespace iptvsimple::utilities;
1919

2020
ChannelGroups::ChannelGroups(const Channels& channels) : m_channels(channels) {}
2121

22+
bool ChannelGroups::Init()
23+
{
24+
Clear();
25+
return true;
26+
}
27+
2228
void ChannelGroups::Clear()
2329
{
2430
m_channelGroups.clear();
31+
m_channelGroupsLoadFailed = false;
2532
}
2633

2734
int ChannelGroups::GetChannelGroupsAmount() const
@@ -31,6 +38,9 @@ int ChannelGroups::GetChannelGroupsAmount() const
3138

3239
PVR_ERROR ChannelGroups::GetChannelGroups(kodi::addon::PVRChannelGroupsResultSet& results, bool radio) const
3340
{
41+
if (m_channelGroupsLoadFailed)
42+
return PVR_ERROR_SERVER_ERROR;
43+
3444
Logger::Log(LEVEL_DEBUG, "%s - Starting to get ChannelGroups for PVR", __FUNCTION__);
3545

3646
for (const auto& channelGroup : m_channelGroups)

src/iptvsimple/ChannelGroups.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@ namespace iptvsimple
3131
iptvsimple::data::ChannelGroup* GetChannelGroup(int uniqueId);
3232
iptvsimple::data::ChannelGroup* FindChannelGroup(const std::string& name);
3333
const std::vector<data::ChannelGroup>& GetChannelGroupsList() const { return m_channelGroups; }
34+
bool Init();
3435
void Clear();
3536
bool CheckChannelGroupAllowed(iptvsimple::data::ChannelGroup& newChannelGroup);
37+
void ChannelGroupsLoadFailed() { m_channelGroupsLoadFailed = true; };
3638

3739
private:
3840
const iptvsimple::Channels& m_channels;
3941
std::vector<iptvsimple::data::ChannelGroup> m_channelGroups;
42+
43+
bool m_channelGroupsLoadFailed = false;
4044
};
4145
} //namespace iptvsimple

src/iptvsimple/Channels.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ bool Channels::Init()
3131
void Channels::Clear()
3232
{
3333
m_channels.clear();
34+
m_channelsLoadFailed = false;
3435
m_currentChannelNumber = Settings::GetInstance().GetStartChannelNumber();
3536
}
3637

@@ -41,6 +42,9 @@ int Channels::GetChannelsAmount() const
4142

4243
PVR_ERROR Channels::GetChannels(kodi::addon::PVRChannelsResultSet& results, bool radio) const
4344
{
45+
if (m_channelsLoadFailed)
46+
return PVR_ERROR_SERVER_ERROR;
47+
4448
// We set a channel order here that applies to the 'Any channels' group in kodi-pvr
4549
// This allows the users to use the 'Backend Order' sort option in the left to
4650
// have the same order as the backend (regardles of the channel numbering used)

src/iptvsimple/Channels.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ namespace iptvsimple
4343
void Clear();
4444

4545
int GetCurrentChannelNumber() const { return m_currentChannelNumber; }
46+
void ChannelsLoadFailed() { m_channelsLoadFailed = true; };
4647

4748
private:
4849
int GenerateChannelId(const char* channelName, const char* streamUrl);
4950

5051
int m_currentChannelNumber;
52+
bool m_channelsLoadFailed = false;
5153

5254
std::vector<iptvsimple::data::Channel> m_channels;
5355
};

src/iptvsimple/PlaylistLoader.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ bool PlaylistLoader::LoadPlayList()
189189
if (m_channels.GetChannelsAmount() == 0)
190190
{
191191
Logger::Log(LEVEL_ERROR, "%s - Unable to load channels from file '%s'", __FUNCTION__, m_m3uLocation.c_str());
192-
return false;
192+
// We no longer return false as this is just an empty M3U and a missing file error.
193+
//return false;
193194
}
194195

195196
Logger::Log(LEVEL_INFO, "%s - Loaded %d channels.", __FUNCTION__, m_channels.GetChannelsAmount());
@@ -414,6 +415,11 @@ void PlaylistLoader::ReloadPlayList()
414415
m_client->TriggerChannelUpdate();
415416
m_client->TriggerChannelGroupsUpdate();
416417
}
418+
else
419+
{
420+
m_channels.ChannelsLoadFailed();
421+
m_channelGroups.ChannelGroupsLoadFailed();
422+
}
417423
}
418424

419425
std::string PlaylistLoader::ReadMarkerValue(const std::string& line, const std::string& markerName)

src/iptvsimple/data/EpgEntry.cpp

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ std::string ParseAsW3CDateString(const std::string& strDate)
157157

158158
std::string ParseAsW3CDateString(time_t time)
159159
{
160-
std::tm tm = SafeLocaltime(time);
160+
std::tm tm = SafeLocaltime(time);
161161
char buffer[16];
162162
std::strftime(buffer, 16, "%Y-%m-%d", &tm);
163163

@@ -336,16 +336,33 @@ bool EpgEntry::ParseOnScreenEpisodeNumberInfo(const std::string& episodeNumberSt
336336
static const std::regex unwantedCharsRegex("[ \\txX_\\.]");
337337
const std::string text = std::regex_replace(episodeNumberString, unwantedCharsRegex, "");
338338

339-
std::smatch match;
340-
static const std::regex seasonEpisodeRegex("^[sS]([0-9][0-9]*)[eE][pP]?([0-9][0-9]*)$");
341-
if (std::regex_match(text, match, seasonEpisodeRegex))
339+
if (StringUtils::StartsWithNoCase(text, "S"))
342340
{
343-
if (match.size() == 3)
341+
std::smatch match;
342+
static const std::regex seasonEpisodeRegex("^[sS]([0-9][0-9]*)[eE][pP]?([0-9][0-9]*)$");
343+
if (std::regex_match(text, match, seasonEpisodeRegex))
344344
{
345-
m_seasonNumber = std::atoi(match[1].str().c_str());
346-
m_episodeNumber = std::atoi(match[2].str().c_str());
345+
if (match.size() == 3)
346+
{
347+
m_seasonNumber = std::atoi(match[1].str().c_str());
348+
m_episodeNumber = std::atoi(match[2].str().c_str());
347349

348-
return true;
350+
return true;
351+
}
352+
}
353+
}
354+
else if (StringUtils::StartsWithNoCase(text, "E"))
355+
{
356+
static const std::regex episodeOnlyRegex("^[eE][pP]?([0-9][0-9]*)$");
357+
std::smatch matchEpOnly;
358+
if (std::regex_match(text, matchEpOnly, episodeOnlyRegex))
359+
{
360+
if (matchEpOnly.size() == 2)
361+
{
362+
m_episodeNumber = std::atoi(matchEpOnly[1].str().c_str());
363+
364+
return true;
365+
}
349366
}
350367
}
351368

0 commit comments

Comments
 (0)