Skip to content

Commit

Permalink
[artist art] Musicvideo art is retrieved from the music database
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Marshall committed Jul 3, 2012
1 parent 3c1178b commit 43bdd51
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 53 deletions.
18 changes: 17 additions & 1 deletion xbmc/ThumbLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,22 @@ bool CVideoThumbLoader::FillLibraryArt(CFileItem *pItem)
m_database->Open();
if (m_database->GetArtForItem(tag.m_iDbId, tag.m_type, artwork))
pItem->SetArt(artwork);
else if (pItem->GetVideoInfoTag()->m_type == "artist")
{ // we retrieve music video art from the music database (no backward compat)
CMusicDatabase database;
database.Open();
int idArtist = database.GetArtistByName(pItem->GetLabel());
if (database.GetArtForItem(idArtist, "artist", artwork))
pItem->SetArt(artwork);
}
else if (pItem->GetVideoInfoTag()->m_type == "album")
{ // we retrieve music video art from the music database (no backward compat)
CMusicDatabase database;
database.Open();
int idAlbum = database.GetAlbumByName(pItem->GetLabel(), pItem->GetVideoInfoTag()->m_artist);
if (database.GetArtForItem(idAlbum, "album", artwork))
pItem->SetArt(artwork);
}
else
{
if (tag.m_type == "movie" || tag.m_type == "episode" ||
Expand All @@ -325,7 +341,7 @@ bool CVideoThumbLoader::FillLibraryArt(CFileItem *pItem)
pItem->SetArt(items[0]->GetArt());
}
}
else if (tag.m_type == "actor" || tag.m_type == "artist" ||
else if (tag.m_type == "actor" ||
tag.m_type == "writer" || tag.m_type == "director")
{
// We can't realistically get the local thumbs (as we'd need to check every movie that contains this actor)
Expand Down
11 changes: 0 additions & 11 deletions xbmc/video/VideoDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
#include "addons/AddonInstaller.h"
#include "interfaces/AnnouncementManager.h"
#include "dbwrappers/dataset.h"
#include "ThumbnailCache.h"
#include "utils/LabelFormatter.h"
#include "XBDateTime.h"

Expand Down Expand Up @@ -4499,9 +4498,6 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI
if (!items.Contains(pItem->GetPath()))
{
pItem->GetVideoInfoTag()->m_artist.push_back(it->second.second);
CStdString strThumb = CThumbnailCache::GetAlbumThumb(*pItem);
if (CFile::Exists(strThumb))
pItem->SetThumbnailImage(strThumb);
items.Add(pItem);
}
}
Expand All @@ -4522,9 +4518,6 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI
if (!items.Contains(pItem->GetPath()))
{
pItem->GetVideoInfoTag()->m_artist.push_back(m_pDS->fv(2).get_asString());
CStdString strThumb = CThumbnailCache::GetAlbumThumb(pItem->GetLabel(), m_pDS->fv(2).get_asString());
if (CFile::Exists(strThumb))
pItem->SetThumbnailImage(strThumb);
items.Add(pItem);
}
}
Expand Down Expand Up @@ -4561,11 +4554,7 @@ bool CVideoDatabase::GetActorsNav(const CStdString& strBaseDir, CFileItemList& i
{
CFileItemPtr pItem = items[i];
if (idContent == VIDEODB_CONTENT_MUSICVIDEOS)
{
if (CFile::Exists(pItem->GetCachedArtistThumb()))
pItem->SetThumbnailImage(pItem->GetCachedArtistThumb());
pItem->SetIconImage("DefaultArtist.png");
}
else
pItem->SetIconImage("DefaultActor.png");
}
Expand Down
9 changes: 7 additions & 2 deletions xbmc/video/dialogs/GUIDialogVideoInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "guilib/LocalizeStrings.h"
#include "GUIUserMessages.h"
#include "TextureCache.h"
#include "music/MusicDatabase.h"

using namespace std;
using namespace XFILE;
Expand Down Expand Up @@ -233,12 +234,16 @@ void CGUIDialogVideoInfo::SetMovie(const CFileItem *item)
VIDEODB_CONTENT_TYPE type = (VIDEODB_CONTENT_TYPE)m_movieItem->GetVideoContentType();
if (type == VIDEODB_CONTENT_MUSICVIDEOS)
{ // music video
CMusicDatabase database;
database.Open();
const std::vector<std::string> &artists = m_movieItem->GetVideoInfoTag()->m_artist;
for (std::vector<std::string>::const_iterator it = artists.begin(); it != artists.end(); ++it)
{
int idArtist = database.GetArtistByName(*it);
CStdString thumb = database.GetArtForItem(idArtist, "artist", "thumb");
CFileItemPtr item(new CFileItem(*it));
if (CFile::Exists(item->GetCachedArtistThumb()))
item->SetThumbnailImage(item->GetCachedArtistThumb());
if (!thumb.empty())
item->SetThumbnailImage(thumb);
item->SetIconImage("DefaultArtist.png");
m_castList->Add(item);
}
Expand Down
59 changes: 20 additions & 39 deletions xbmc/video/windows/GUIWindowVideoNav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,13 +775,6 @@ bool CGUIWindowVideoNav::DeleteItem(CFileItem* pItem, bool bUnavailable /* = fal
void CGUIWindowVideoNav::OnPrepareFileItems(CFileItemList &items)
{
CGUIWindowVideoBase::OnPrepareFileItems(items);

// set fanart
CQueryParams params;
CVideoDatabaseDirectory dir;
dir.GetQueryParams(items.GetPath(),params);
if (params.GetContentType() == VIDEODB_CONTENT_MUSICVIDEOS)
CGUIWindowMusicNav::SetupFanart(items);
}

void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &buttons)
Expand Down Expand Up @@ -1026,22 +1019,25 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
case CONTEXT_BUTTON_SET_MOVIESET_THUMB:
{
// Grab the thumbnails from the web
CStdString strPath;
CFileItemList items;
URIUtils::AddFileToFolder(g_advancedSettings.m_cachePath,"imdbthumbs",strPath);
CFileItemPtr cacheItem(new CFileItem(strPath,true));
CFileUtils::DeleteItem(cacheItem,true);
XFILE::CDirectory::Create(strPath);
CFileItemPtr noneitem(new CFileItem("thumb://None", false));
CStdString cachedThumb;
CStdString currentThumb;
int idArtist = -1;
CStdString artistPath;
if (button == CONTEXT_BUTTON_SET_ARTIST_THUMB)
cachedThumb = m_vecItems->Get(itemNumber)->GetCachedArtistThumb();
else
cachedThumb = m_database.GetArtForItem(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_iDbId, m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_type, "thumb");
if (!cachedThumb.IsEmpty() && CFile::Exists(cachedThumb))
{
CMusicDatabase database;
database.Open();
idArtist = database.GetArtistByName(m_vecItems->Get(itemNumber)->GetLabel());
database.GetArtistPath(idArtist, artistPath);
currentThumb = database.GetArtForItem(idArtist, "artist", "thumb");
}
if (currentThumb.empty())
currentThumb = m_database.GetArtForItem(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_iDbId, m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_type, "thumb");
if (!currentThumb.IsEmpty() && CFile::Exists(currentThumb))
{
CFileItemPtr item(new CFileItem("thumb://Current", false));
item->SetThumbnailImage(cachedThumb);
item->SetThumbnailImage(currentThumb);
item->SetLabel(g_localizeStrings.Get(20016));
items.Add(item);
}
Expand Down Expand Up @@ -1079,24 +1075,8 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
bool local=false;
if (button == CONTEXT_BUTTON_SET_ARTIST_THUMB)
{
CStdString picturePath;

CStdString strPath = m_vecItems->Get(itemNumber)->GetPath();
URIUtils::RemoveSlashAtEnd(strPath);

int nPos=strPath.ReverseFind("/");
if (nPos>-1)
{
// try to guess where the user should start
// browsing for the artist thumb
CMusicDatabase database;
database.Open();
long idArtist=database.GetArtistByName(m_vecItems->Get(itemNumber)->GetLabel());
database.GetArtistPath(idArtist, picturePath);
}

CStdString strThumb;
URIUtils::AddFileToFolder(picturePath,"folder.jpg",strThumb);
URIUtils::AddFileToFolder(artistPath,"folder.jpg",strThumb);
if (XFILE::CFile::Exists(strThumb))
{
CFileItemPtr pItem(new CFileItem(strThumb,false));
Expand Down Expand Up @@ -1155,13 +1135,14 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
result.clear();
if (button == CONTEXT_BUTTON_SET_MOVIESET_THUMB ||
button == CONTEXT_BUTTON_SET_ACTOR_THUMB ||
button == CONTEXT_BUTTON_SET_SEASON_THUMB)
button == CONTEXT_BUTTON_SET_SEASON_THUMB ||
(button == CONTEXT_BUTTON_SET_ARTIST_THUMB && idArtist < 0))
m_database.SetArtForItem(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_iDbId, m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_type, "thumb", result);
else
{
CTextureCache::Get().ClearCachedImage(cachedThumb, true);
if (!result.IsEmpty())
CFile::Cache(result,cachedThumb);
CMusicDatabase db;
if (db.Open())
db.SetArtForItem(idArtist, "artist", "thumb", result);
}

CUtil::DeleteVideoDatabaseDirectoryCache();
Expand Down

0 comments on commit 43bdd51

Please sign in to comment.