Пример #1
0
INFO_RET CMusicInfoScanner::ScanTags(const CFileItemList& items, CFileItemList& scannedItems)
{
  std::vector<std::string> regexps = g_advancedSettings.m_audioExcludeFromScanRegExps;

  for (int i = 0; i < items.Size(); ++i)
  {
    if (m_bStop)
      return INFO_CANCELLED;

    CFileItemPtr pItem = items[i];

    if (CUtil::ExcludeFileOrFolder(pItem->GetPath(), regexps))
      continue;

    if (pItem->m_bIsFolder || pItem->IsPlayList() || pItem->IsPicture() || pItem->IsLyrics())
      continue;

    m_currentItem++;

    CMusicInfoTag& tag = *pItem->GetMusicInfoTag();
    if (!tag.Loaded())
    {
      std::unique_ptr<IMusicInfoTagLoader> pLoader (CMusicInfoTagLoaderFactory::CreateLoader(*pItem));
      if (NULL != pLoader.get())
        pLoader->Load(pItem->GetPath(), tag);
    }

    if (m_handle && m_itemCount>0)
      m_handle->SetPercentage(m_currentItem / (float)m_itemCount * 100);

    if (!tag.Loaded() && !pItem->HasCueDocument())
    {
      CLog::Log(LOGDEBUG, "%s - No tag found for: %s", __FUNCTION__, pItem->GetPath().c_str());
      continue;
    }
    else
    {
      if (!tag.GetCueSheet().empty())
        pItem->LoadEmbeddedCue();
    }

    if (pItem->HasCueDocument())
      pItem->LoadTracksFromCueDocument(scannedItems);
    else
      scannedItems.Add(pItem);
  }
  return INFO_ADDED;
}
Пример #2
0
/// \brief Retrieve tag information for \e m_vecItems
void CGUIWindowMusicBase::RetrieveMusicInfo()
{
    unsigned int startTick = XbmcThreads::SystemClockMillis();

    OnRetrieveMusicInfo(*m_vecItems);

    // \todo Scan for multitrack items here...
    vector<string> itemsForRemove;
    CFileItemList itemsForAdd;
    for (int i = 0; i < m_vecItems->Size(); ++i)
    {
        CFileItemPtr pItem = (*m_vecItems)[i];
        if (pItem->m_bIsFolder || pItem->IsPlayList() || pItem->IsPicture() || pItem->IsLyrics())
            continue;

        CMusicInfoTag& tag = *pItem->GetMusicInfoTag();
        if (tag.Loaded() && !tag.GetCueSheet().empty())
            pItem->LoadEmbeddedCue();

        if (pItem->HasCueDocument()
                && pItem->LoadTracksFromCueDocument(itemsForAdd))
        {
            itemsForRemove.push_back(pItem->GetPath());
        }
    }
    for (size_t i = 0; i < itemsForRemove.size(); ++i)
    {
        for (int j = 0; j < m_vecItems->Size(); ++j)
        {
            if ((*m_vecItems)[j]->GetPath() == itemsForRemove[i])
            {
                m_vecItems->Remove(j);
                break;
            }
        }
    }
    m_vecItems->Append(itemsForAdd);

    CLog::Log(LOGDEBUG, "RetrieveMusicInfo() took %u msec",
              XbmcThreads::SystemClockMillis() - startTick);
}