Skip to content

Commit

Permalink
Information provider settings and related scraping fixes.
Browse files Browse the repository at this point in the history
MusicDB changes:
Add release group MBID, scrapedMBID flag and lastScraped to views. GetAlbum and GetArtist now fetch these values, so remove separate queries for values. This fixes loss of release group MBID when refreshing with a scraper that does not return release group id e.g. TADB scraper or from NFO files, and needed for JSON API exposure of properties.

Rework info provider settings to be artist and album id specific rather than path. Replace content with infosetting table and store idSetting in artist and album tables. Add clean up of orphaned settings.

Remove albuminfosong table, storing scraped tracks is deprecated.

Fix having "Change information provider" on context menu for parent folder and *all items. IsAllItem() handles paths with options at the end.

Fix refresh of information for all items within this path after info provider change for a single artist or album.

Add facility to set information provider for multiple artists or albums. Unlike the path based attempt before this works. From context menu set information provider for a) current item, b) all items on node, c) default (for all).
  • Loading branch information
DaveTBlake committed Aug 15, 2017
1 parent f1dd912 commit 873c1a3
Show file tree
Hide file tree
Showing 14 changed files with 610 additions and 405 deletions.
95 changes: 92 additions & 3 deletions addons/resource.language.en_gb/resources/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ msgctxt "#180"
msgid "Duration"
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#181"
msgid "Select album"
msgstr ""
Expand Down Expand Up @@ -1170,10 +1171,12 @@ msgctxt "#254"
msgid "DTS capable receiver"
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#255"
msgid "CDDB"
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#256"
msgid "Fetching CD information"
msgstr ""
Expand Down Expand Up @@ -1464,46 +1467,57 @@ msgctxt "#317"
msgid "Cleaned database successfully"
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#318"
msgid "Cleaning songs..."
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#319"
msgid "Error cleaning songs"
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#320"
msgid "Cleaning artists..."
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#321"
msgid "Error cleaning artists"
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#322"
msgid "Cleaning genres..."
msgid "Cleaning genres, roles etc...."
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#323"
msgid "Error cleaning genres"
msgid "Error cleaning genres, roles etc."
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#324"
msgid "Cleaning paths..."
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#325"
msgid "Error cleaning paths"
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#326"
msgid "Cleaning albums..."
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#327"
msgid "Error cleaning albums"
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#328"
msgid "Writing changes..."
msgstr ""
Expand All @@ -1512,10 +1526,12 @@ msgctxt "#329"
msgid "Error writing changes"
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#330"
msgid "This may take some time..."
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#331"
msgid "Compressing database..."
msgstr ""
Expand Down Expand Up @@ -2942,10 +2958,12 @@ msgctxt "#648"
msgid "Import video library"
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#649"
msgid "Importing"
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#650"
msgid "Exporting"
msgstr ""
Expand Down Expand Up @@ -3099,10 +3117,12 @@ msgstr ""

#empty strings from id 682 to 699

#: xbmc/music/MusicDatabase.cpp
msgctxt "#700"
msgid "Cleaning up library"
msgstr ""

#: xbmc/music/MusicDatabase.cpp
msgctxt "#701"
msgid "Removing old songs from the library"
msgstr ""
Expand Down Expand Up @@ -12147,6 +12167,7 @@ msgctxt "#20194"
msgid "Default provider for artist information"
msgstr ""

#: xbmc/music/windows/GUIWindowMusicBase.cpp
msgctxt "#20195"
msgid "Change information provider"
msgstr ""
Expand Down Expand Up @@ -20379,6 +20400,7 @@ msgid "All roles"
msgstr ""

#empty strings from id 38047 to 38059
#strings 38047 to 38059 reserved for music library roles

#. Question when forced rescan of music tags needed after upgrade from previous version of Kodi
#: xbmc/music/windows/GUIWindowMusicBase.cpp
Expand All @@ -20398,7 +20420,74 @@ msgctxt "#38062"
msgid "Do full tag scan even when music files are unchanged?"
msgstr ""

#empty strings from id 38063 to 38099
#. Label for a context submenu entry to change the default addon used to fetch artist or album information, related to #20195, #20193 and #20194
#: xbmc/music/windows/GUIWindowMusicNav.cpp
msgctxt "#38063"
msgid "Set default information provider"
msgstr ""

#. Label for a context submenu entry to change the information provider for a specific artist, related to #20195
#: xbmc/music/windows/GUIWindowMusicNav.cpp
msgctxt "#38064"
msgid "Set for this artist"
msgstr ""

#. Label for a context submenu entry to change the information provider for all artists in node, related to #20195
#: xbmc/music/windows/GUIWindowMusicNav.cpp
msgctxt "#38065"
msgid "Set for all artists shown"
msgstr ""

#. Label for a context submenu entry to change the information provider for a specific album, related to #20195
#: xbmc/music/windows/GUIWindowMusicNav.cpp
msgctxt "#38066"
msgid "Set for this album"
msgstr ""

#. Label for a context submenu entry to change the information provider for all albums in node, related to #20195
#: xbmc/music/windows/GUIWindowMusicNav.cpp
msgctxt "#38067"
msgid "Set for all albums shown"
msgstr ""

#. Dialog message asking for confirmation of change the information provider for all artists shown in node, after #38065
#: xbmc/music/windows/GUIWindowMusicNav.cpp
msgctxt "#38068"
msgid "Use this information provider for all the artists shown here?"
msgstr ""

#. Dialog message asking for confirmation of change the information provider for all albums shown in node, after #38067
#: xbmc/music/windows/GUIWindowMusicNav.cpp
msgctxt "#38069"
msgid "Use this information provider for all the albums shown here?"
msgstr ""

#. Dialog message asking for confirmation of change to the default artist information provider, after #38063
#: xbmc/music/windows/GUIWindowMusicNav.cpp
msgctxt "#38070"
msgid "Use this information provider for all artists, clearing any previous settings for specific artists?"
msgstr ""

#. Dialog message asking for confirmation of change to the default album information provider, after #38063
#: xbmc/music/windows/GUIWindowMusicNav.cpp
msgctxt "#38071"
msgid "Use this information provider for all albums, clearing any previous settings for specific albums?"
msgstr ""

#. Dialog message asking for confirmation to get additional info for all the artists or albums in the node immediately
#: xbmc/music/windows/GUIWindowMusicNav.cpp
msgctxt "#38072"
msgid "Do you want to refresh information for all these items now?"
msgstr ""

#. Dialog message asking for confirmation to get additional info for the current artist or album immediately
#: xbmc/music/windows/GUIWindowMusicNav.cpp
msgctxt "#38073"
msgid "Do you want to refresh information for this item now?"
msgstr ""

#empty strings from id 38074 to 38099
#strings 38074 to 38099 reserved for music library

#. Description of section #14200 "Player""
#: system/settings/settings.xml
Expand Down
4 changes: 3 additions & 1 deletion xbmc/filesystem/MusicDatabaseDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ void CMusicDatabaseDirectory::ClearDirectoryCache(const std::string& strDirector

bool CMusicDatabaseDirectory::IsAllItem(const std::string& strDirectory)
{
if (StringUtils::EndsWith(strDirectory, "/-1/"))
//Last query parameter, ignoring any appended options, is -1
CURL url(strDirectory);
if (StringUtils::EndsWith(url.GetWithoutOptions(), "/-1/"))
return true;
return false;
}
Expand Down
73 changes: 3 additions & 70 deletions xbmc/music/Album.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,11 @@ void CAlbum::MergeScrapedAlbum(const CAlbum& source, bool override /* = true */)
for (auto &song : songs)
{
if (!song.strMusicBrainzTrackID.empty())
for (auto sourceSong : source.infoSongs)
for (auto sourceSong : source.songs)
if ((sourceSong.strMusicBrainzTrackID == song.strMusicBrainzTrackID) && (sourceSong.iTrack == song.iTrack))
song.MergeScrapedSong(sourceSong, override);
}
}
infoSongs = source.infoSongs;
}

std::string CAlbum::GetGenreString() const
Expand Down Expand Up @@ -469,8 +468,8 @@ bool CAlbum::Load(const TiXmlElement *album, bool append, bool prioritise)

XMLUtils::GetString(album, "title", strAlbum);
XMLUtils::GetString(album, "musicbrainzalbumid", strMusicBrainzAlbumID);
XMLUtils::GetString(album, "musicBrainzAlbumID", strMusicBrainzAlbumID);
XMLUtils::GetString(album, "musicbrainzreleasegroupid", strReleaseGroupMBID);
XMLUtils::GetBoolean(album, "scrapedmbid", bScrapedMBID);
XMLUtils::GetString(album, "artistdesc", strArtistDesc);
std::vector<std::string> artist; // Support old style <artist></artist> for backwards compatibility
XMLUtils::GetStringArray(album, "artist", artist, prioritise, g_advancedSettings.m_musicItemSeparator);
Expand Down Expand Up @@ -564,53 +563,6 @@ bool CAlbum::Load(const TiXmlElement *album, bool append, bool prioritise)
}
}

const TiXmlElement* node = album->FirstChildElement("track");
if (node)
infoSongs.clear(); // this means that the tracks can't be spread over separate pages
// but this is probably a reasonable limitation
bool bIncrement = false;
while (node)
{
if (node->FirstChild())
{

CSong song;
const TiXmlElement* songArtistCreditsNode = node->FirstChildElement("songArtistCredits");
if (songArtistCreditsNode)
song.artistCredits.clear();

while (songArtistCreditsNode)
{
if (songArtistCreditsNode->FirstChild())
{
CArtistCredit artistCredit;
XMLUtils::GetString(songArtistCreditsNode, "artist", artistCredit.m_strArtist);
XMLUtils::GetString(songArtistCreditsNode, "musicBrainzArtistID", artistCredit.m_strMusicBrainzArtistID);
song.artistCredits.push_back(artistCredit);
}

songArtistCreditsNode = songArtistCreditsNode->NextSiblingElement("songArtistCredits");
}

XMLUtils::GetString(node, "musicBrainzTrackID", song.strMusicBrainzTrackID);
XMLUtils::GetInt(node, "position", song.iTrack);

if (song.iTrack == 0)
bIncrement = true;

XMLUtils::GetString(node,"title",song.strTitle);
std::string strDur;
XMLUtils::GetString(node,"duration",strDur);
song.iDuration = StringUtils::TimeStringToSeconds(strDur);

if (bIncrement)
song.iTrack = song.iTrack + 1;

infoSongs.push_back(song);
}
node = node->NextSiblingElement("track");
}

std::string strReleaseType;
if (XMLUtils::GetString(album, "releasetype", strReleaseType))
SetReleaseType(strReleaseType);
Expand All @@ -632,8 +584,8 @@ bool CAlbum::Save(TiXmlNode *node, const std::string &tag, const std::string& st

XMLUtils::SetString(album, "title", strAlbum);
XMLUtils::SetString(album, "musicbrainzalbumid", strMusicBrainzAlbumID);
XMLUtils::SetString(album, "musicBrainzAlbumID", strMusicBrainzAlbumID);
XMLUtils::SetString(album, "musicbrainzreleasegroupid", strReleaseGroupMBID);
XMLUtils::SetBoolean(album, "scrapedmbid", bScrapedMBID);
XMLUtils::SetString(album, "artistdesc", strArtistDesc); //Can be different from artist credits
XMLUtils::SetStringArray(album, "genre", genre);
XMLUtils::SetStringArray(album, "style", styles);
Expand Down Expand Up @@ -678,25 +630,6 @@ bool CAlbum::Save(TiXmlNode *node, const std::string &tag, const std::string& st
XMLUtils::SetString(albumArtistCreditsNode, "musicBrainzArtistID", artistCredit->m_strMusicBrainzArtistID);
}

for( VECSONGS::const_iterator song = infoSongs.begin(); song != infoSongs.end(); ++song)
{
// add a <song> tag
TiXmlElement cast("track");
TiXmlNode *node = album->InsertEndChild(cast);
for( VECARTISTCREDITS::const_iterator artistCredit = song->artistCredits.begin(); artistCredit != song->artistCredits.end(); ++artistCredit)
{
// add an <albumArtistCredits> tag
TiXmlElement songArtistCreditsElement("songArtistCredits");
TiXmlNode *songArtistCreditsNode = node->InsertEndChild(songArtistCreditsElement);
XMLUtils::SetString(songArtistCreditsNode, "artist", artistCredit->m_strArtist);
XMLUtils::SetString(songArtistCreditsNode, "musicBrainzArtistID", artistCredit->m_strMusicBrainzArtistID);
}
XMLUtils::SetString(node, "musicBrainzTrackID", song->strMusicBrainzTrackID);
XMLUtils::SetString(node, "title", song->strTitle);
XMLUtils::SetInt(node, "position", song->iTrack);
XMLUtils::SetString(node, "duration", StringUtils::SecondsToTimeString(song->iDuration));
}

XMLUtils::SetString(album, "releasetype", GetReleaseType());

return true;
Expand Down
4 changes: 2 additions & 2 deletions xbmc/music/Album.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class CAlbum
dateAdded.Reset();
lastPlayed.Reset();
songs.clear();
infoSongs.clear();
releaseType = Album;
strLastScraped.clear();
bScrapedMBID = false;
bArtistSongMerge = false;
}
Expand Down Expand Up @@ -165,8 +165,8 @@ class CAlbum
CDateTime dateAdded;
CDateTime lastPlayed;
VECSONGS songs; ///< Local songs
VECSONGS infoSongs; ///< Scraped songs
ReleaseType releaseType;
std::string strLastScraped;
bool bScrapedMBID;
bool bArtistSongMerge;
};
Expand Down
2 changes: 2 additions & 0 deletions xbmc/music/Artist.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class CArtist
strPath.clear();
dateAdded.Reset();
bScrapedMBID = false;
strLastScraped.clear();
}

/*! \brief Load artist information from an XML file.
Expand Down Expand Up @@ -107,6 +108,7 @@ class CArtist
std::vector<std::pair<std::string,std::string> > discography;
CDateTime dateAdded;
bool bScrapedMBID;
std::string strLastScraped;
};

class CArtistCredit
Expand Down

0 comments on commit 873c1a3

Please sign in to comment.