Skip to content

Commit

Permalink
Content rating test
Browse files Browse the repository at this point in the history
Replace episode art with content rating icon
  • Loading branch information
emveepee committed Jun 8, 2024
1 parent 4a78d27 commit 35bbad8
Show file tree
Hide file tree
Showing 82 changed files with 59 additions and 0 deletions.
Binary file added pvr.nextpvr/resources/content_ratings/AU/AV15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/AU/C.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/AU/E.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/AU/G.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/AU/M.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/AU/P.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/AU/PG.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/AU/R18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/AU/RC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/AU/X18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/13+.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/14+.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/14A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/16+.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/18+.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/18A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/C.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/C8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/G.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/PG.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/CA/R.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pvr.nextpvr/resources/content_ratings/DE/0.png
Binary file added pvr.nextpvr/resources/content_ratings/DE/12.png
Binary file added pvr.nextpvr/resources/content_ratings/DE/1206.png
Binary file added pvr.nextpvr/resources/content_ratings/DE/16.png
Binary file added pvr.nextpvr/resources/content_ratings/DE/18.png
Binary file added pvr.nextpvr/resources/content_ratings/DE/6.png
Binary file added pvr.nextpvr/resources/content_ratings/FR/-10.png
Binary file added pvr.nextpvr/resources/content_ratings/FR/-12.png
Binary file added pvr.nextpvr/resources/content_ratings/FR/-16.png
Binary file added pvr.nextpvr/resources/content_ratings/FR/-18.png
Binary file added pvr.nextpvr/resources/content_ratings/MPAA/G.png
Binary file added pvr.nextpvr/resources/content_ratings/MPAA/R.png
Binary file added pvr.nextpvr/resources/content_ratings/NL/12.png
Binary file added pvr.nextpvr/resources/content_ratings/NL/14.png
Binary file added pvr.nextpvr/resources/content_ratings/NL/16.png
Binary file added pvr.nextpvr/resources/content_ratings/NL/18.png
Binary file added pvr.nextpvr/resources/content_ratings/NL/6.png
Binary file added pvr.nextpvr/resources/content_ratings/NL/9.png
Binary file added pvr.nextpvr/resources/content_ratings/NL/AL.png
Binary file added pvr.nextpvr/resources/content_ratings/NO/12.png
Binary file added pvr.nextpvr/resources/content_ratings/NO/15.png
Binary file added pvr.nextpvr/resources/content_ratings/NO/18.png
Binary file added pvr.nextpvr/resources/content_ratings/NO/6.png
Binary file added pvr.nextpvr/resources/content_ratings/NO/9.png
Binary file added pvr.nextpvr/resources/content_ratings/NO/A.png
Binary file added pvr.nextpvr/resources/content_ratings/NZ/13.png
Binary file added pvr.nextpvr/resources/content_ratings/NZ/15.png
Binary file added pvr.nextpvr/resources/content_ratings/NZ/16.png
Binary file added pvr.nextpvr/resources/content_ratings/NZ/18.png
Binary file added pvr.nextpvr/resources/content_ratings/NZ/G.png
Binary file added pvr.nextpvr/resources/content_ratings/NZ/M.png
Binary file added pvr.nextpvr/resources/content_ratings/NZ/PG.png
Binary file added pvr.nextpvr/resources/content_ratings/NZ/R.png
Binary file added pvr.nextpvr/resources/content_ratings/NZ/R18.png
Binary file added pvr.nextpvr/resources/content_ratings/NZ/RP13.png
Binary file added pvr.nextpvr/resources/content_ratings/NZ/RP16.png
Binary file added pvr.nextpvr/resources/content_ratings/NZ/RP18.png
Binary file added pvr.nextpvr/resources/content_ratings/UK/12.png
Binary file added pvr.nextpvr/resources/content_ratings/UK/12A.png
Binary file added pvr.nextpvr/resources/content_ratings/UK/15.png
Binary file added pvr.nextpvr/resources/content_ratings/UK/18.png
Binary file added pvr.nextpvr/resources/content_ratings/UK/PG.png
Binary file added pvr.nextpvr/resources/content_ratings/UK/R18.png
Binary file added pvr.nextpvr/resources/content_ratings/US/TV14.png
Binary file added pvr.nextpvr/resources/content_ratings/US/TVG.png
Binary file added pvr.nextpvr/resources/content_ratings/US/TVMA.png
Binary file added pvr.nextpvr/resources/content_ratings/US/TVPG.png
Binary file added pvr.nextpvr/resources/content_ratings/US/TVY.png
Binary file added pvr.nextpvr/resources/content_ratings/US/TVY7.png
57 changes: 57 additions & 0 deletions src/EPG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,67 @@ PVR_ERROR EPG::GetEPGForChannel(int channelUid, time_t start, time_t end, kodi::
}
}
}
rating.clear();
XMLUtils::GetString(pListingNode, "rating", rating);
SetContentRating(broadcast, rating);
results.Add(broadcast);
}
return PVR_ERROR_NO_ERROR;
}

return PVR_ERROR_NO_ERROR;
}

void EPG::SetContentRating(kodi::addon::PVREPGTag& broadcast, std::string contentRating)
{
const std::string contentDirectory = "special://home/addons/pvr.nextpvr/resources/content_ratings";
// std::string checkname = kodi::vfs::TranslateSpecialProtocol(content);
if (!contentRating.empty() && kodi::vfs::DirectoryExists(contentDirectory))
{
broadcast.SetParentalRatingCode(contentRating);
std::regex base_regex("([1-9]\\d?)\\+?$");
std::smatch base_match;
if (std::regex_match(contentRating, base_match, base_regex))
{
int code = std::stoi(base_match[1].str());
if (code < 20)
broadcast.SetParentalRating(code);
}
std::map<std::string, std::string>::iterator lookupRating = m_contentRatings.find(contentRating);
if ( lookupRating == m_contentRatings.end())
{
std::list <std::string> regions{ "US", "MPAA", "AU", "UK", "NL", "NO","CA", "DE", "NZ", "FR"};
std::string parsedRating = contentRating;
kodi::tools::StringUtils::Trim(parsedRating);
kodi::tools::StringUtils::ToUpper(parsedRating);
if (parsedRating[0] != '-')
kodi::tools::StringUtils::Replace(parsedRating, "-", "");
kodi::tools::StringUtils::Replace(parsedRating, " ", "");

// get from a setting
std::string priorityRegion = "CA";
regions.emplace_front(priorityRegion);

int counter = 0;
for (std::string region : regions)
{
if (counter++ > 0 && region == priorityRegion)
continue;
std::string ratingName = kodi::tools::StringUtils::Format("%s/%s/%s.png", contentDirectory.c_str(), region.c_str(), parsedRating.c_str());
if (kodi::vfs::FileExists(ratingName))
{
m_contentRatings.emplace(contentRating, ratingName);
broadcast.SetIconPath(ratingName);
return;
}
}
kodi::Log(ADDON_LOG_DEBUG, "Content rating not found %s|%s",parsedRating.c_str(), contentRating.c_str());
// Optionally set a default
}
else
{
broadcast.SetIconPath(lookupRating->second);
return;
}
}
}
2 changes: 2 additions & 0 deletions src/EPG.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ namespace NextPVR
Request& m_request;
Recordings& m_recordings;
Channels& m_channels;
void SetContentRating(kodi::addon::PVREPGTag& broadcast, std::string rating);
std::map<std::string, std::string> m_contentRatings;
};
} // namespace NextPVR

0 comments on commit 35bbad8

Please sign in to comment.