Skip to content

Commit

Permalink
rename formattedTitle to groupingTitle
Browse files Browse the repository at this point in the history
  • Loading branch information
janbar committed Nov 9, 2018
1 parent 2c0289a commit bb446c0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
23 changes: 13 additions & 10 deletions src/cppmyth/MythProgramInfo.cpp
Expand Up @@ -342,22 +342,20 @@ bool MythProgramInfo::IsDamaged() const
#include <locale>
#include <codecvt>

std::string MythProgramInfo::FormattedTitle() const
std::string MythProgramInfo::GroupingTitle() const
{
if (!m_proginfo || !m_formattedTitle.empty())
return m_formattedTitle;
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
if (!m_proginfo || !m_groupingTitle.empty())
return m_groupingTitle;
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> > converter;
std::wstring wt = converter.from_bytes(m_proginfo->title);
// truncate title at the first left parenthesis
// i.e: "Ad Vitam (1/6)" => "Ad Vitam "
size_t p = wt.find(L'\x0028');
if (p == std::wstring::npos || p == 0)
p = wt.length();
// trim trailing spaces
while (p > 0 && iswspace((wint_t)(wt[p - 1])))
--p;
// clean special characters
std::wstring wb;
// erase special characters
for (int i = 0; i < p; ++i)
for (size_t i = 0; i < p; ++i)
{
wchar_t c = wt[i];
if (c != L'\x002f' // slash
Expand All @@ -369,5 +367,10 @@ std::string MythProgramInfo::FormattedTitle() const
else
wb.push_back(L'\x0020');
}
return m_formattedTitle = converter.to_bytes(wb);
// trim trailing spaces
p = wb.length();
while (p > 0 && iswspace((wint_t)(wb[p - 1])))
--p;
wb.resize(p);
return m_groupingTitle = converter.to_bytes(wb);
}
4 changes: 2 additions & 2 deletions src/cppmyth/MythProgramInfo.h
Expand Up @@ -85,12 +85,12 @@ class MythProgramInfo
time_t Airdate() const;
bool IsDamaged() const;

std::string FormattedTitle() const;
std::string GroupingTitle() const;

private:
Myth::ProgramPtr m_proginfo;
mutable int32_t m_flags;
mutable std::string m_formattedTitle;
mutable std::string m_groupingTitle;

class Props
{
Expand Down
4 changes: 2 additions & 2 deletions src/pvrclient-mythtv.cpp
Expand Up @@ -881,7 +881,7 @@ PVR_ERROR PVRClientMythTV::GetRecordings(ADDON_HANDLE handle)
{
if (!it->second.IsNull() && it->second.IsVisible() && (g_bLiveTVRecordings || !it->second.IsLiveTV()))
{
std::pair<std::string, std::string> title = std::make_pair(it->second.RecordingGroup(), it->second.FormattedTitle());
std::pair<std::string, std::string> title = std::make_pair(it->second.RecordingGroup(), it->second.GroupingTitle());
TitlesMap::iterator found = titles.find(title);
if (found != titles.end())
{
Expand Down Expand Up @@ -946,7 +946,7 @@ PVR_ERROR PVRClientMythTV::GetRecordings(ADDON_HANDLE handle)
// Add recording title to directory to group everything according to its name just like MythTV does
std::string strDirectory(it->second.RecordingGroup());
if (g_iGroupRecordings == GROUP_RECORDINGS_ALWAYS || (g_iGroupRecordings == GROUP_RECORDINGS_ONLY_FOR_SERIES && it->second.GetPropsSerie()))
strDirectory.append("/").append(it->second.FormattedTitle());
strDirectory.append("/").append(it->second.GroupingTitle());
PVR_STRCPY(tag.strDirectory, strDirectory.c_str());

// Images
Expand Down

0 comments on commit bb446c0

Please sign in to comment.