Skip to content

Commit

Permalink
[videolibrary] Assign extra artwork from file system
Browse files Browse the repository at this point in the history
with a whitelist configuration in AS.xml, and apply the whitelist
to scraper results.
  • Loading branch information
rmrector committed Oct 8, 2018
1 parent 62d47f9 commit 9c81d82
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 62 deletions.
55 changes: 29 additions & 26 deletions xbmc/settings/AdvancedSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ void CAdvancedSettings::Initialize()
m_bVideoScannerIgnoreErrors = false;
m_iVideoLibraryDateAdded = 1; // prefer mtime over ctime and current time

m_videoEpisodeExtraArt = {};
m_videoTvShowExtraArt = {};
m_videoTvSeasonExtraArt = {};
m_videoMovieExtraArt = {};
m_videoMusicVideoExtraArt = {};

m_iEpgUpdateCheckInterval = 300; /* check if tables need to be updated every 5 minutes */
m_iEpgCleanupInterval = 900; /* remove old entries from the EPG every 15 minutes */
m_iEpgActiveTagCheckInterval = 60; /* check for updated active tags every minute */
Expand Down Expand Up @@ -772,32 +778,9 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file)
separator = separator->NextSibling("separator");
}
}
// Music extra artist art
TiXmlElement* arttypes = pElement->FirstChildElement("artistextraart");
if (arttypes)
{
m_musicArtistExtraArt.clear();
TiXmlNode* arttype = arttypes->FirstChild("arttype");
while (arttype)
{
if (arttype->FirstChild())
m_musicArtistExtraArt.push_back(arttype->FirstChild()->ValueStr());
arttype = arttype->NextSibling("arttype");
}
}
// Music extra album art
arttypes = pElement->FirstChildElement("albumextraart");
if (arttypes)
{
m_musicAlbumExtraArt.clear();
TiXmlNode* arttype = arttypes->FirstChild("arttype");
while (arttype)
{
if (arttype->FirstChild())
m_musicAlbumExtraArt.push_back(arttype->FirstChild()->ValueStr());
arttype = arttype->NextSibling("arttype");
}
}

SetExtraArtwork(pElement->FirstChildElement("artistextraart"), m_musicArtistExtraArt);
SetExtraArtwork(pElement->FirstChildElement("albumextraart"), m_musicAlbumExtraArt);
}

pElement = pRootElement->FirstChildElement("videolibrary");
Expand All @@ -812,6 +795,12 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file)
XMLUtils::GetBoolean(pElement, "importwatchedstate", m_bVideoLibraryImportWatchedState);
XMLUtils::GetBoolean(pElement, "importresumepoint", m_bVideoLibraryImportResumePoint);
XMLUtils::GetInt(pElement, "dateadded", m_iVideoLibraryDateAdded);

SetExtraArtwork(pElement->FirstChildElement("episodeextraart"), m_videoEpisodeExtraArt);
SetExtraArtwork(pElement->FirstChildElement("tvshowextraart"), m_videoTvShowExtraArt);
SetExtraArtwork(pElement->FirstChildElement("tvseasonextraart"), m_videoTvSeasonExtraArt);
SetExtraArtwork(pElement->FirstChildElement("movieextraart"), m_videoMovieExtraArt);
SetExtraArtwork(pElement->FirstChildElement("musicvideoextraart"), m_videoMusicVideoExtraArt);
}

pElement = pRootElement->FirstChildElement("videoscanner");
Expand Down Expand Up @@ -1462,3 +1451,17 @@ void CAdvancedSettings::SetExtraLogLevel(const std::vector<CVariant> &components
m_extraLogLevels |= static_cast<int>(it->asInteger());
}
}

void CAdvancedSettings::SetExtraArtwork(const TiXmlElement* arttypes, std::vector<std::string>& artworkMap)
{
if (!arttypes)
return
artworkMap.clear();
const TiXmlNode* arttype = arttypes->FirstChild("arttype");
while (arttype)
{
if (arttype->FirstChild())
artworkMap.push_back(arttype->FirstChild()->ValueStr());
arttype = arttype->NextSibling("arttype");
}
}
6 changes: 6 additions & 0 deletions xbmc/settings/AdvancedSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler
bool m_bVideoLibraryExportAutoThumbs;
bool m_bVideoLibraryImportWatchedState;
bool m_bVideoLibraryImportResumePoint;
std::vector<std::string> m_videoEpisodeExtraArt;
std::vector<std::string> m_videoTvShowExtraArt;
std::vector<std::string> m_videoTvSeasonExtraArt;
std::vector<std::string> m_videoMovieExtraArt;
std::vector<std::string> m_videoMusicVideoExtraArt;

bool m_bVideoScannerIgnoreErrors;
int m_iVideoLibraryDateAdded;
Expand Down Expand Up @@ -382,4 +387,5 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler
void SetExtraLogLevel(const std::vector<CVariant> &components);
void Initialize();
void Clear();
void SetExtraArtwork(const TiXmlElement* arttypes, std::vector<std::string>& artworkMap);
};
28 changes: 6 additions & 22 deletions xbmc/video/VideoInfoScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1441,9 +1441,6 @@ namespace VIDEO

// get and cache thumb images
std::vector<std::string> artTypes = CVideoThumbLoader::GetArtTypes(ContentToMediaType(content, pItem->m_bIsFolder));
std::vector<std::string>::iterator i = find(artTypes.begin(), artTypes.end(), "fanart");
if (i != artTypes.end())
artTypes.erase(i); // fanart is handled below
bool lookForThumb = find(artTypes.begin(), artTypes.end(), "thumb") == artTypes.end() &&
art.find("thumb") == art.end();
// find local art
Expand Down Expand Up @@ -1480,7 +1477,7 @@ namespace VIDEO
{
for (auto& it : pItem->GetVideoInfoTag()->m_coverArt)
{
if (art.find(it.m_type) == art.end())
if (find(artTypes.begin(), artTypes.end(), it.m_type) != artTypes.end() && art.find(it.m_type) == art.end())
{
std::string thumb = CTextureUtils::GetWrappedImageURL(pItem->GetPath(),
"video_" + it.m_type);
Expand All @@ -1489,11 +1486,10 @@ namespace VIDEO
}
}

// get & save fanart image (treated separately due to it being stored in m_fanart)
bool isEpisode = (content == CONTENT_TVSHOWS && !pItem->m_bIsFolder);
if (!isEpisode && art.find("fanart") == art.end())
// add online fanart (treated separately due to it being stored in m_fanart)
if (find(artTypes.begin(), artTypes.end(), "fanart") != artTypes.end() && art.find("fanart") == art.end())
{
std::string fanart = GetFanart(pItem, useLocal);
std::string fanart = pItem->GetVideoInfoTag()->m_fanart.GetImageURL();
if (!fanart.empty())
art.insert(std::make_pair("fanart", fanart));
}
Expand All @@ -1507,7 +1503,7 @@ namespace VIDEO
if (aspect.empty())
// temporary support for XML music video scrapers that share music album scraper bits
aspect = content == CONTENT_MUSICVIDEOS ? "poster" : "thumb";
if (art.find(aspect) != art.end())
if (find(artTypes.begin(), artTypes.end(), aspect) == artTypes.end() || art.find(aspect) != art.end())
continue;
std::string image = GetImage(url, pItem->GetPath());
if (!image.empty())
Expand Down Expand Up @@ -1540,18 +1536,6 @@ namespace VIDEO
return thumb;
}

std::string CVideoInfoScanner::GetFanart(CFileItem *pItem, bool useLocal)
{
if (!pItem)
return "";
std::string fanart = pItem->GetArt("fanart");
if (fanart.empty() && useLocal)
fanart = pItem->FindLocalArt("fanart.jpg", true);
if (fanart.empty())
fanart = pItem->GetVideoInfoTag()->m_fanart.GetImageURL();
return fanart;
}

CInfoScanner::INFO_RET
CVideoInfoScanner::OnProcessSeriesFolder(EPISODELIST& files,
const ADDON::ScraperPtr &scraper,
Expand Down Expand Up @@ -1992,7 +1976,7 @@ namespace VIDEO
if (aspect.empty())
aspect = "thumb";
std::map<std::string, std::string>& art = seasonArt[url.m_season];
if (art.find(aspect) != art.end())
if (find(artTypes.begin(), artTypes.end(), aspect) == artTypes.end() || art.find(aspect) != art.end())
continue;
std::string image = CScraperUrl::GetThumbURL(url);
if (!image.empty())
Expand Down
1 change: 0 additions & 1 deletion xbmc/video/VideoInfoScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ namespace VIDEO
*/
static void GetSeasonThumbs(const CVideoInfoTag &show, std::map<int, std::map<std::string, std::string> > &art, const std::vector<std::string> &artTypes, bool useLocal = true);
static std::string GetImage(const CScraperUrl::SUrlEntry &image, const std::string& itemPath);
static std::string GetFanart(CFileItem *pItem, bool useLocal);

bool EnumerateEpisodeItem(const CFileItem *item, EPISODELIST& episodeList);

Expand Down
37 changes: 24 additions & 13 deletions xbmc/video/VideoThumbLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,27 +223,38 @@ static void SetupRarOptions(CFileItem& item, const std::string& path)

std::vector<std::string> CVideoThumbLoader::GetArtTypes(const std::string &type)
{
const std::shared_ptr<CAdvancedSettings> advancedSettings = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings();
std::vector<std::string> ret;
std::vector<std::string> extraart;
if (type == MediaTypeEpisode)
ret.push_back("thumb");
else if (type == MediaTypeTvShow || type == MediaTypeSeason)
{
ret.push_back("banner");
ret.push_back("poster");
ret.push_back("fanart");
ret = { "thumb" };
extraart = advancedSettings->m_videoEpisodeExtraArt;
}
else if (type == MediaTypeMovie || type == MediaTypeMusicVideo || type == MediaTypeVideoCollection)
else if (type == MediaTypeTvShow)
{
ret.push_back("poster");
ret.push_back("fanart");
ret = { "poster", "fanart", "banner" };
extraart = advancedSettings->m_videoTvShowExtraArt;
}
else if (type.empty()) // unknown - just throw everything in
else if (type == MediaTypeSeason)
{
ret.push_back("poster");
ret.push_back("banner");
ret.push_back("thumb");
ret.push_back("fanart");
ret = { "poster", "fanart", "banner" };
extraart = advancedSettings->m_videoTvSeasonExtraArt;
}
else if (type == MediaTypeMovie || type == MediaTypeVideoCollection)
{
ret = { "poster", "fanart" };
extraart = advancedSettings->m_videoMovieExtraArt;
}
else if (type == MediaTypeMusicVideo)
{
ret = { "poster", "fanart" };
extraart = advancedSettings->m_videoMusicVideoExtraArt;
}
else if (type.empty()) // unknown, just the basics
ret = { "poster", "fanart", "banner", "thumb" };

ret.insert(ret.end(), extraart.begin(), extraart.end());
return ret;
}

Expand Down

0 comments on commit 9c81d82

Please sign in to comment.