Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Prompt for rescan of music #1124

Merged
merged 2 commits into from

2 participants

@jmarshallnz
Owner

Music needs rescanning so we can generate the new album/song art (plus also ensure we get the compilations correct, though I suspect this needs more work).

This prompts the user and starts a scan.

Discussion is needed as to whether or not we reset the scan trigger (a setting set on db update) when the user starts a scan using this - if the cancel the scan then it's not possible to rescan without removing the source, clearing things out and readding it.

@jmarshallnz
Owner

Alternatives would be:

  1. Invalidate all the paths in the db, so that next scan it'll rescan anyway. Problem is if online lookups are done, then any artists/albums not found will be re-checked even though they don't necessarily need to be (slow). (The above scan turns off online lookups).

  2. Add ability to rescan-all to the music library settings - this would take the normal online lookup setting I guess. Not sure of the use - the current "Update Library" automatically rescans tags that have changed, assuming either filesize or filedate of the media has altered. I guess it might be possible to change a tag without these being changed on some filesystems? If we allow this, do we prompt to also look for online content (if the setting is enabled)?

  3. Add ability to rescan a source from the context menu (not sure this makes sense to be honest - XBMC's music library automatically detects if the user changes any tags) - plus, I hate adding stuff to context.

@jmarshallnz jmarshallnz merged commit a42e86b into xbmc:master
@arnova
Collaborator

I just updated xbmc on my HTPC with one build from today's master but after the rescan of my music database the info manager no longer shows any music thumbs in the now playing window.

Now playing window isn't the infomanager - it's a known issue though (the MusicInfoLoader runs threaded in that case, the thumb loader doesn't run, and the thumb assigning stuff won't work due to not working on a real folder).

Collaborator

I'm willing to look into this but do you have any ideas how to fix this?

First step is running the thumbloader. Problem with that is that you don't want 2 threads running.

Collaborator

Can't we modify the thumbloader to allow non threaded thumb retrieval and have the musicinfoloader use that to take care of the thumb-loading. Basically a non-threaded version of the thumbloader?

Collaborator
Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 6, 2012
  1. add flags for the music scanner instead of reading guisettings intern…

    Jonathan Marshall authored
    …ally
  2. add prompt to rescan music library on entry to music

    Jonathan Marshall authored
This page is out of date. Refresh to see the latest.
View
16 language/English/strings.po
@@ -2784,7 +2784,21 @@ msgctxt "#798"
msgid "Internet access"
msgstr ""
-#empty strings from id 799 to 849
+msgctxt "#799"
+msgid "Library Update"
+msgstr ""
+
+#: xbmc/music/windows/GUIWindowMusicBase.cpp
+msgctxt "#800"
+msgid "Music library needs to rescan art from tags"
+msgstr ""
+
+#: xbmc/music/windows/GUIWindowMusicBase.cpp
+msgctxt "#801"
+msgid "Would you like to scan now?"
+msgstr ""
+
+#empty strings from id 802 to 849
msgctxt "#850"
msgid "Invalid port number entered"
View
14 xbmc/Application.cpp
@@ -5548,12 +5548,20 @@ void CApplication::StartVideoScan(const CStdString &strDirectory, bool scanAll)
m_videoInfoScanner->Start(strDirectory,scanAll);
}
-void CApplication::StartMusicScan(const CStdString &strDirectory)
+void CApplication::StartMusicScan(const CStdString &strDirectory, int flags)
{
if (m_musicInfoScanner->IsScanning())
return;
- if (!g_guiSettings.GetBool("musiclibrary.backgroundupdate"))
+ if (!flags)
+ { // setup default flags
+ if (g_guiSettings.GetBool("musiclibrary.downloadinfo"))
+ flags |= CMusicInfoScanner::SCAN_ONLINE;
+ if (g_guiSettings.GetBool("musiclibrary.backgroundupdate"))
+ flags |= CMusicInfoScanner::SCAN_BACKGROUND;
+ }
+
+ if (!(flags & CMusicInfoScanner::SCAN_BACKGROUND))
{
CGUIDialogMusicScan *musicScan = (CGUIDialogMusicScan *)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN);
if (musicScan)
@@ -5563,7 +5571,7 @@ void CApplication::StartMusicScan(const CStdString &strDirectory)
}
}
SaveMusicScanSettings();
- m_musicInfoScanner->Start(strDirectory);
+ m_musicInfoScanner->Start(strDirectory, flags);
}
void CApplication::StartMusicAlbumScan(const CStdString& strDirectory,
View
2  xbmc/Application.h
@@ -230,7 +230,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
void StartVideoCleanup();
void StartVideoScan(const CStdString &path, bool scanAll = false);
- void StartMusicScan(const CStdString &path);
+ void StartMusicScan(const CStdString &path, int flags = 0);
void StartMusicAlbumScan(const CStdString& strDirectory, bool refresh=false);
void StartMusicArtistScan(const CStdString& strDirectory, bool refresh=false);
View
10 xbmc/music/infoscanner/MusicInfoScanner.cpp
@@ -65,6 +65,7 @@ CMusicInfoScanner::CMusicInfoScanner() : CThread("CMusicInfoScanner")
m_bCanInterrupt = false;
m_currentItem=0;
m_itemCount=0;
+ m_flags = 0;
}
CMusicInfoScanner::~CMusicInfoScanner()
@@ -205,11 +206,12 @@ void CMusicInfoScanner::Process()
m_pObserver->OnFinished();
}
-void CMusicInfoScanner::Start(const CStdString& strDirectory)
+void CMusicInfoScanner::Start(const CStdString& strDirectory, int flags)
{
m_pathsToScan.clear();
m_albumsScanned.clear();
m_artistsScanned.clear();
+ m_flags = flags;
if (strDirectory.IsEmpty())
{ // scan all paths in the database. We do this by scanning all paths in the db, and crossing them off the list as
@@ -378,7 +380,7 @@ bool CMusicInfoScanner::DoScan(const CStdString& strDirectory)
// check whether we need to rescan or not
CStdString dbHash;
- if (!m_musicDatabase.GetPathHash(strDirectory, dbHash) || dbHash != hash)
+ if ((m_flags & SCAN_RESCAN) || !m_musicDatabase.GetPathHash(strDirectory, dbHash) || dbHash != hash)
{ // path has changed - rescan
if (dbHash.IsEmpty())
CLog::Log(LOGDEBUG, "%s Scanning dir '%s' as not in the database", __FUNCTION__, strDirectory.c_str());
@@ -565,7 +567,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(CFileItemList& items, const CStdString&
{
CStdString strArtist = m_musicDatabase.GetArtistById(*it);
m_artistsScanned.push_back(*it);
- if (!m_bStop && g_guiSettings.GetBool("musiclibrary.downloadinfo"))
+ if (!m_bStop && (m_flags & SCAN_ONLINE))
{
CStdString strPath;
strPath.Format("musicdb://2/%u/", *it);
@@ -581,7 +583,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(CFileItemList& items, const CStdString&
}
}
- if (g_guiSettings.GetBool("musiclibrary.downloadinfo"))
+ if (m_flags & SCAN_ONLINE)
{
for (set<long>::iterator it = albumsToScan.begin(); it != albumsToScan.end(); ++it)
{
View
10 xbmc/music/infoscanner/MusicInfoScanner.h
@@ -44,10 +44,17 @@ class IMusicInfoScannerObserver
class CMusicInfoScanner : CThread, public IRunnable
{
public:
+ /*! \brief Flags for controlling the scanning process
+ */
+ enum SCAN_FLAGS { SCAN_NORMAL = 0,
+ SCAN_ONLINE = 1 << 0,
+ SCAN_BACKGROUND = 1 << 1,
+ SCAN_RESCAN = 1 << 2 };
+
CMusicInfoScanner();
virtual ~CMusicInfoScanner();
- void Start(const CStdString& strDirectory);
+ void Start(const CStdString& strDirectory, int flags);
void FetchAlbumInfo(const CStdString& strDirectory, bool refresh=false);
void FetchArtistInfo(const CStdString& strDirectory, bool refresh=false);
bool IsScanning();
@@ -126,5 +133,6 @@ class CMusicInfoScanner : CThread, public IRunnable
std::set<CStdString> m_pathsToCount;
std::vector<long> m_artistsScanned;
std::vector<long> m_albumsScanned;
+ int m_flags;
};
}
View
16 xbmc/music/windows/GUIWindowMusicBase.cpp
@@ -50,6 +50,7 @@
#include "music/tags/MusicInfoTag.h"
#include "guilib/GUIWindowManager.h"
#include "dialogs/GUIDialogOK.h"
+#include "dialogs/GUIDialogYesNo.h"
#include "dialogs/GUIDialogKeyboard.h"
#include "dialogs/GUIDialogProgress.h"
#include "FileItem.h"
@@ -1344,6 +1345,21 @@ void CGUIWindowMusicBase::OnPrepareFileItems(CFileItemList &items)
{
}
+void CGUIWindowMusicBase::OnInitWindow()
+{
+ CGUIMediaWindow::OnInitWindow();
+ if (g_settings.m_musicNeedsUpdate == 27 && !g_application.IsMusicScanning())
+ {
+ // rescan of music library required
+ if (CGUIDialogYesNo::ShowAndGetInput(799, 800, 801, -1))
+ {
+ g_application.StartMusicScan("", CMusicInfoScanner::SCAN_RESCAN);
+ g_settings.m_musicNeedsUpdate = false; // once is enough (user may interrupt, but that's up to them)
+ g_settings.Save();
+ }
+ }
+}
+
CStdString CGUIWindowMusicBase::GetStartFolder(const CStdString &dir)
{
if (dir.Equals("Plugins") || dir.Equals("Addons"))
View
1  xbmc/music/windows/GUIWindowMusicBase.h
@@ -51,6 +51,7 @@ class CGUIWindowMusicBase : public CGUIMediaWindow
void OnInfo(CFileItem *pItem, bool bShowInfo = false);
protected:
+ virtual void OnInitWindow();
/*!
\brief Will be called when an popup context menu has been asked for
\param itemNumber List/thumb control item that has been clicked on
Something went wrong with that request. Please try again.