From 12ace5dfcc137ed32fcfc9bb1bcafb221f8f5692 Mon Sep 17 00:00:00 2001 From: jmarshallnz Date: Sun, 9 Mar 2014 12:05:14 +1300 Subject: [PATCH] Merge pull request #4368 from jmarshallnz/music_fixes Music fixes for .nfo files --- xbmc/NfoFile.cpp | 2 +- xbmc/NfoFile.h | 3 +-- xbmc/music/infoscanner/MusicInfoScanner.cpp | 14 +++++++++++--- xbmc/music/tags/MusicInfoTag.cpp | 16 ++++++++++++++++ xbmc/music/tags/MusicInfoTag.h | 3 ++- xbmc/music/windows/GUIWindowMusicBase.cpp | 12 +++++------- 6 files changed, 36 insertions(+), 14 deletions(-) diff --git a/xbmc/NfoFile.cpp b/xbmc/NfoFile.cpp index 804a2b0..fb1db08 100644 --- a/xbmc/NfoFile.cpp +++ b/xbmc/NfoFile.cpp @@ -37,7 +37,7 @@ using namespace std; using namespace XFILE; using namespace ADDON; -CNfoFile::NFOResult CNfoFile::Create(const CStdString& strPath, const ScraperPtr& info, int episode, const CStdString& strPath2) +CNfoFile::NFOResult CNfoFile::Create(const CStdString& strPath, const ScraperPtr& info, int episode) { m_info = info; // assume we can use these settings m_type = ScraperTypeFromContent(info->Content()); diff --git a/xbmc/NfoFile.h b/xbmc/NfoFile.h index 01f742a..b2648f4 100644 --- a/xbmc/NfoFile.h +++ b/xbmc/NfoFile.h @@ -46,8 +46,7 @@ public: ERROR_NFO = 4 }; - NFOResult Create(const CStdString&, const ADDON::ScraperPtr&, int episode=-1, - const CStdString& strPath2=""); + NFOResult Create(const CStdString&, const ADDON::ScraperPtr&, int episode=-1); template bool GetDetails(T& details,const char* document=NULL, bool prioritise=false) { diff --git a/xbmc/music/infoscanner/MusicInfoScanner.cpp b/xbmc/music/infoscanner/MusicInfoScanner.cpp index 0368bb6..98032f2 100644 --- a/xbmc/music/infoscanner/MusicInfoScanner.cpp +++ b/xbmc/music/infoscanner/MusicInfoScanner.cpp @@ -990,13 +990,17 @@ INFO_RET CMusicInfoScanner::DownloadAlbumInfo(const CAlbum& album, const ADDON:: } // handle nfo files - CStdString strNfo = URIUtils::AddFileToFolder(album.strPath, "album.nfo"); + CStdString path = album.strPath; + if (path.empty()) + m_musicDatabase.GetAlbumPath(album.idAlbum, path); + + CStdString strNfo = URIUtils::AddFileToFolder(path, "album.nfo"); CNfoFile::NFOResult result = CNfoFile::NO_NFO; CNfoFile nfoReader; if (XFILE::CFile::Exists(strNfo)) { CLog::Log(LOGDEBUG,"Found matching nfo file: %s", strNfo.c_str()); - result = nfoReader.Create(strNfo, info, -1, album.strPath); + result = nfoReader.Create(strNfo, info); if (result == CNfoFile::FULL_NFO) { CLog::Log(LOGDEBUG, "%s Got details from nfo", __FUNCTION__); @@ -1202,7 +1206,11 @@ INFO_RET CMusicInfoScanner::DownloadArtistInfo(const CArtist& artist, const ADDO } // handle nfo files - CStdString strNfo = URIUtils::AddFileToFolder(artist.strPath, "artist.nfo"); + CStdString path = artist.strPath; + if (path.empty()) + m_musicDatabase.GetArtistPath(artist.idArtist, path); + + CStdString strNfo = URIUtils::AddFileToFolder(path, "artist.nfo"); CNfoFile::NFOResult result=CNfoFile::NO_NFO; CNfoFile nfoReader; if (XFILE::CFile::Exists(strNfo)) diff --git a/xbmc/music/tags/MusicInfoTag.cpp b/xbmc/music/tags/MusicInfoTag.cpp index e66d4f5..c2d0793 100644 --- a/xbmc/music/tags/MusicInfoTag.cpp +++ b/xbmc/music/tags/MusicInfoTag.cpp @@ -55,6 +55,20 @@ bool EmbeddedArtInfo::matches(const EmbeddedArtInfo &right) const mime == right.mime); } +void EmbeddedArtInfo::Archive(CArchive &ar) +{ + if (ar.IsStoring()) + { + ar << size; + ar << mime; + } + else + { + ar >> size; + ar >> mime; + } +} + EmbeddedArt::EmbeddedArt(const uint8_t *dat, size_t siz, const std::string &mim) { set(dat, siz, mim); @@ -647,6 +661,7 @@ void CMusicInfoTag::Archive(CArchive& ar) ar << m_strLyrics; ar << m_bCompilation; ar << m_listeners; + ar << m_coverArt; } else { @@ -675,6 +690,7 @@ void CMusicInfoTag::Archive(CArchive& ar) ar >> m_strLyrics; ar >> m_bCompilation; ar >> m_listeners; + ar >> m_coverArt; } } diff --git a/xbmc/music/tags/MusicInfoTag.h b/xbmc/music/tags/MusicInfoTag.h index 0b76d22..48fdb8e 100644 --- a/xbmc/music/tags/MusicInfoTag.h +++ b/xbmc/music/tags/MusicInfoTag.h @@ -46,7 +46,7 @@ enum ReplayGain namespace MUSIC_INFO { - class EmbeddedArtInfo + class EmbeddedArtInfo : public IArchivable { public: EmbeddedArtInfo() {}; @@ -55,6 +55,7 @@ namespace MUSIC_INFO void clear(); bool empty() const; bool matches(const EmbeddedArtInfo &right) const; + virtual void Archive(CArchive& ar); size_t size; std::string mime; }; diff --git a/xbmc/music/windows/GUIWindowMusicBase.cpp b/xbmc/music/windows/GUIWindowMusicBase.cpp index f5261b7..8b1b767 100644 --- a/xbmc/music/windows/GUIWindowMusicBase.cpp +++ b/xbmc/music/windows/GUIWindowMusicBase.cpp @@ -373,6 +373,7 @@ void CGUIWindowMusicBase::ShowArtistInfo(const CFileItem *pItem, bool bShowInfo if (!m_musicdatabase.GetArtist(params.GetArtistId(), artist)) return; + m_musicdatabase.GetArtistPath(params.GetArtistId(), artist.strPath); while (1) { // Check if we have the information in the database first @@ -411,9 +412,7 @@ void CGUIWindowMusicBase::ShowArtistInfo(const CFileItem *pItem, bool bShowInfo CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO); if (pDlgArtistInfo) { - CStdString strPath; - m_musicdatabase.GetArtistPath(params.GetArtistId(), strPath); - pDlgArtistInfo->SetArtist(artist, strPath); + pDlgArtistInfo->SetArtist(artist, artist.strPath); pDlgArtistInfo->DoModal(); if (pDlgArtistInfo->NeedRefresh()) @@ -445,6 +444,7 @@ bool CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo / if (!m_musicdatabase.GetAlbum(params.GetAlbumId(), album)) return false; + m_musicdatabase.GetAlbumPath(params.GetAlbumId(), album.strPath); while (1) { if (!m_musicdatabase.HasAlbumBeenScraped(params.GetAlbumId())) @@ -491,9 +491,7 @@ bool CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo / CGUIDialogMusicInfo *pDlgAlbumInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO); if (pDlgAlbumInfo) { - CStdString strPath; - m_musicdatabase.GetAlbumPath(params.GetAlbumId(), strPath); - pDlgAlbumInfo->SetAlbum(album, strPath); + pDlgAlbumInfo->SetAlbum(album, album.strPath); pDlgAlbumInfo->DoModal(); if (pDlgAlbumInfo->NeedRefresh()) @@ -503,7 +501,7 @@ bool CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo / } else if (pDlgAlbumInfo->HasUpdatedThumb()) { - UpdateThumb(album, strPath); + UpdateThumb(album, album.strPath); } } break; -- 2.7.4