CSong::CSong(CMusicInfoTag& tag) { SYSTEMTIME stTime; tag.GetReleaseDate(stTime); strTitle = tag.GetTitle(); strGenre = tag.GetGenre(); strFileName = tag.GetURL(); strArtist = tag.GetArtist(); strAlbum = tag.GetAlbum(); strAlbumArtist = tag.GetAlbumArtist(); strComment = tag.GetComment(); strLabel = tag.GetLabel(); // Laureon: Added getLabel strISRC = tag.GetISRC(); // Laureon: Added getISRC iVisible = 1; // Laureon: Added: Song Visibility rating = tag.GetRating(); iYear = stTime.wYear; iTrack = tag.GetTrackAndDiskNumber(); iDuration = tag.GetDuration(); strThumb = ""; iStartOffset = 0; iEndOffset = 0; idSong = -1; iTimesPlayed = 0; iKaraokeNumber = 0; iKaraokeDelay = 0; //! Karaoke song lyrics-music delay in 1/10 seconds. iArtistId = -1; iAlbumId = -1; }
CSong::CSong(CMusicInfoTag& tag) { SYSTEMTIME stTime; tag.GetReleaseDate(stTime); strTitle = tag.GetTitle(); genre = tag.GetGenre(); strFileName = tag.GetURL(); artist = tag.GetArtist(); strAlbum = tag.GetAlbum(); albumArtist = tag.GetAlbumArtist(); strMusicBrainzTrackID = tag.GetMusicBrainzTrackID(); strMusicBrainzArtistID = tag.GetMusicBrainzArtistID(); strMusicBrainzAlbumID = tag.GetMusicBrainzAlbumID(); strMusicBrainzAlbumArtistID = tag.GetMusicBrainzAlbumArtistID(); strMusicBrainzTRMID = tag.GetMusicBrainzTRMID(); strComment = tag.GetComment(); rating = tag.GetRating(); iYear = stTime.wYear; iTrack = tag.GetTrackAndDiskNumber(); iDuration = tag.GetDuration(); bCompilation = tag.GetCompilation(); embeddedArt = tag.GetCoverArtInfo(); strThumb = ""; iStartOffset = 0; iEndOffset = 0; idSong = -1; iTimesPlayed = 0; iKaraokeNumber = 0; iKaraokeDelay = 0; //! Karaoke song lyrics-music delay in 1/10 seconds. iAlbumId = -1; }
bool CMusicInfoTagLoaderMP4::Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) { try { // Initially we say that we've not loaded any tag information tag.SetLoaded(false); // Attempt to open the file.. if ( !m_file.Open( strFileName ) ) { CLog::Log(LOGDEBUG, "Tag loader mp4: failed to open file %s", strFileName.c_str() ); return false; } // We've opened it, so associate the tag with the filename. tag.SetURL(strFileName); // Now go parse our atom data m_isCompilation = false; ParseAtom( 0, m_file.GetLength(), tag, art ); if (m_isCompilation) { // iTunes compilation flag is set - this could be a various artists file if (tag.GetAlbumArtist().empty()) tag.SetAlbumArtist(g_localizeStrings.Get(340)); // Various Artists } // Close the file.. m_file.Close(); // Return to caller return true; } catch (...) { CLog::Log(LOGERROR, "Tag loader mp4: exception in file %s", strFileName.c_str()); } // Something must have gone wrong for us to get here, so let's report our failure to the boss.. tag.SetLoaded(false); return false; }
void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo) { if ((pItem->IsMusicDb() && !pItem->HasMusicInfoTag()) || pItem->IsParentFolder() || URIUtils::IsSpecial(pItem->GetPath()) || pItem->GetPath().Left(14).Equals("musicsearch://")) return; // nothing to do if (!pItem->m_bIsFolder) { // song lookup ShowSongInfo(pItem); return; } CStdString strPath = pItem->GetPath(); // Try to find an album to lookup from the current item CAlbum album; CArtist artist; bool foundAlbum = false; album.idAlbum = -1; // we have a folder if (pItem->IsMusicDb()) { CQueryParams params; CDirectoryNode::GetDatabaseInfo(pItem->GetPath(), params); if (params.GetAlbumId() == -1) { // artist lookup artist.idArtist = params.GetArtistId(); artist.strArtist = StringUtils::Join(pItem->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator); } else { // album lookup album.idAlbum = params.GetAlbumId(); album.strAlbum = pItem->GetMusicInfoTag()->GetAlbum(); album.artist = pItem->GetMusicInfoTag()->GetArtist(); // we're going to need it's path as well (we assume that there's only one) - this is for // assigning thumbs to folders, and obtaining the local folder.jpg m_musicdatabase.GetAlbumPath(album.idAlbum, strPath); } } else { // from filemode, so find the albums in the folder CFileItemList items; GetDirectory(strPath, items); // show dialog box indicating we're searching the album name if (m_dlgProgress && bShowInfo) { m_dlgProgress->SetHeading(185); m_dlgProgress->SetLine(0, 501); m_dlgProgress->SetLine(1, ""); m_dlgProgress->SetLine(2, ""); m_dlgProgress->StartModal(); m_dlgProgress->Progress(); if (m_dlgProgress->IsCanceled()) return; } // check the first song we find in the folder, and grab it's album info for (int i = 0; i < items.Size() && !foundAlbum; i++) { CFileItemPtr pItem = items[i]; pItem->LoadMusicTag(); if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded() && !pItem->GetMusicInfoTag()->GetAlbum().IsEmpty()) { // great, have a song - use it. CSong song(*pItem->GetMusicInfoTag()); // this function won't be needed if/when the tag has idSong information if (!m_musicdatabase.GetAlbumFromSong(song, album)) { // album isn't in the database - construct it from the tag info we have CMusicInfoTag *tag = pItem->GetMusicInfoTag(); album.strAlbum = tag->GetAlbum(); album.artist = tag->GetAlbumArtist().empty() ? tag->GetArtist() : tag->GetAlbumArtist(); album.idAlbum = -1; // the -1 indicates it's not in the database } foundAlbum = true; } } if (!foundAlbum) { CLog::Log(LOGINFO, "%s called on a folder containing no songs with tag info - nothing can be done", __FUNCTION__); if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); return; } if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); } if (album.idAlbum == -1 && foundAlbum == false) ShowArtistInfo(artist, pItem->GetPath(), false, bShowInfo); else ShowAlbumInfo(album, strPath, false, bShowInfo); }
bool CMusicInfoTagLoaderMP4::Load(const CStdString& strFileName, CMusicInfoTag& tag) { try { // Initially we say that we've not loaded any tag information tag.SetLoaded(false); // Attempt to open the file.. if ( !m_file.Open( strFileName ) ) { CLog::Log(LOGDEBUG, "Tag loader mp4: failed to open file %s", strFileName.c_str() ); return false; } // We've opened it, so associate the tag with the filename. tag.SetURL(strFileName); // Now go parse our atom data m_thumbSize = false; m_thumbData = NULL; m_isCompilation = false; ParseAtom( 0, m_file.GetLength(), tag ); if (m_thumbData) { // cache the thumb // if we don't have an album tag, cache with the full file path so that // other non-tagged files don't get this album image CStdString strCoverArt; if (!tag.GetAlbum().IsEmpty() && (!tag.GetAlbumArtist().IsEmpty() || !tag.GetArtist().IsEmpty())) strCoverArt = CThumbnailCache::GetAlbumThumb(&tag); else strCoverArt = CThumbnailCache::GetMusicThumb(tag.GetURL()); if (!CUtil::ThumbExists(strCoverArt)) { if (CPicture::CreateThumbnailFromMemory( m_thumbData, m_thumbSize, "", strCoverArt ) ) { CUtil::ThumbCacheAdd( strCoverArt, true ); } else { CLog::Log(LOGDEBUG, "%s unable to cache thumb as %s", __FUNCTION__, strCoverArt.c_str()); CUtil::ThumbCacheAdd( strCoverArt, false ); } } delete[] m_thumbData; } if (m_isCompilation) { // iTunes compilation flag is set - this could be a various artists file if (tag.GetAlbumArtist().IsEmpty()) tag.SetAlbumArtist(g_localizeStrings.Get(340)); // Various Artists } // Close the file.. m_file.Close(); // Return to caller return true; } catch (...) { CLog::Log(LOGERROR, "Tag loader mp4: exception in file %s", strFileName.c_str()); } // Something must have gone wrong for us to get here, so let's report our failure to the boss.. tag.SetLoaded(false); return false; }
void CMusicInfoTagLoaderWMA::SetTagValueBinary(const CStdString& strFrameName, const unsigned char* pValue, CMusicInfoTag& tag) { if (strFrameName == "WM/Picture") { WM_PICTURE picture; int iPicOffset = 0; // Picture types: http://msdn.microsoft.com/library/en-us/wmform/htm/wm_picture.asp picture.bPictureType = (BYTE)pValue[iPicOffset]; iPicOffset += 1; picture.dwDataLen = (DWORD)pValue[iPicOffset] + (pValue[iPicOffset + 1] * 0x100) + (pValue[iPicOffset + 2] * 0x10000); iPicOffset += 4; CStdStringW wString; CStdString16 utf16String = (uint16_t*)(pValue+iPicOffset); g_charsetConverter.utf16LEtoW(utf16String, wString); g_charsetConverter.wToUTF8(wString, picture.pwszMIMEType); iPicOffset += (wString.length() * 2); iPicOffset += 2; utf16String = (uint16_t*)(pValue+iPicOffset); g_charsetConverter.utf16LEtoW(utf16String, picture.pwszDescription); iPicOffset += (picture.pwszDescription.length() * 2); iPicOffset += 2; picture.pbData = (BYTE *)(pValue + iPicOffset); // many wma's don't have the bPictureType specified. For now, just take // Cover Front (3) or Other (0) as the cover. if (picture.bPictureType == 3 || picture.bPictureType == 0) // Cover Front { CStdString strExtension(picture.pwszMIMEType); // if we don't have an album tag, cache with the full file path so that // other non-tagged files don't get this album image CStdString strCoverArt; if (!tag.GetAlbum().IsEmpty() && (!tag.GetAlbumArtist().IsEmpty() || !tag.GetArtist().IsEmpty())) strCoverArt = CUtil::GetCachedAlbumThumb(tag.GetAlbum(), tag.GetAlbumArtist().IsEmpty() ? tag.GetArtist() : tag.GetAlbumArtist()); else strCoverArt = CUtil::GetCachedMusicThumb(tag.GetURL()); if (!CUtil::ThumbExists(strCoverArt)) { int nPos = strExtension.Find('/'); if (nPos > -1) strExtension.Delete(0, nPos + 1); if (picture.pbData != NULL && picture.dwDataLen > 0) { if (CPicture::CreateThumbnailFromMemory(picture.pbData, picture.dwDataLen, strExtension, strCoverArt)) { CUtil::ThumbCacheAdd(strCoverArt, true); } else { CUtil::ThumbCacheAdd(strCoverArt, false); CLog::Log(LOGERROR, "Tag loader wma: " "Unable to create album art for %s " "(extension=%s, size=%u)", tag.GetURL().c_str(), strExtension.c_str(), picture.dwDataLen); } } } } } }
void CMusicInfoTagLoaderWMA::SetTagValueString(const CStdString& strFrameName, const CStdString& strValue, CMusicInfoTag& tag) { if (strFrameName == "WM/AlbumTitle") { tag.SetAlbum(strValue); } else if (strFrameName == "WM/AlbumArtist") { if (tag.GetAlbumArtist().IsEmpty()) tag.SetAlbumArtist(strValue); } else if (strFrameName == "Author") { // Multiple artists are stored in multiple "Author" tags we have get them // separatly and merge them to our system if (tag.GetArtist().IsEmpty()) tag.SetArtist(strValue); else tag.SetArtist(tag.GetArtist() + g_advancedSettings.m_musicItemSeparator + strValue); } else if (strFrameName == "WM/TrackNumber") { if (tag.GetTrackNumber() <= 0) tag.SetTrackNumber(atoi(strValue.c_str())); } else if (strFrameName == "WM/PartOfSet") { tag.SetPartOfSet(atoi(strValue.c_str())); } //else if (strFrameName=="WM/Track") // Old Tracknumber, should not be used anymore else if (strFrameName == "WM/Year") { SYSTEMTIME dateTime; dateTime.wYear = atoi(strValue.c_str()); tag.SetReleaseDate(dateTime); } else if (strFrameName == "WM/Genre") { // Multiple genres are stared in multiple "WM/Genre" tags we have to get them // separatly and merge them to our system if (tag.GetGenre().IsEmpty()) tag.SetGenre(strValue); else tag.SetGenre(tag.GetGenre() + g_advancedSettings.m_musicItemSeparator + strValue); } else if (strFrameName == "WM/Lyrics") { tag.SetLyrics(strValue); } //else if (strFrameName=="WM/DRM") //{ // // File is DRM protected // pwszValue; //} //else if (strFrameName=="WM/Codec") //{ // pwszValue; //} //else if (strFrameName=="WM/BeatsPerMinute") //{ // pwszValue; //} //else if (strFrameName=="WM/Mood") //{ // pwszValue; //} //else if (strFrameName=="WM/RadioStationName") //{ // pwszValue; //} //else if (strFrameName=="WM/RadioStationOwner") //{ // pwszValue; //} }
void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo) { if (pItem->m_bIsFolder && pItem->IsParentFolder()) return; if (pItem->IsVideoDb()) { OnContextButton(m_viewControl.GetSelectedItem(), CONTEXT_BUTTON_INFO); // nasty but it is the same item i promise :) return; } CStdString strPath = pItem->m_strPath; // Try to find an album to lookup from the current item CAlbum album; CArtist artist; bool foundAlbum = false; album.idAlbum = -1; if (pItem->IsMusicDb()) { CQueryParams params; CDirectoryNode::GetDatabaseInfo(pItem->m_strPath, params); if (params.GetAlbumId() == -1) { artist.idArtist = params.GetArtistId(); artist.strArtist = pItem->GetMusicInfoTag()->GetArtist(); } else { // show dialog box indicating we're searching the album name if (m_dlgProgress && bShowInfo) { m_dlgProgress->SetHeading(185); m_dlgProgress->SetLine(0, 501); m_dlgProgress->SetLine(1, ""); m_dlgProgress->SetLine(2, ""); m_dlgProgress->StartModal(); m_dlgProgress->Progress(); if (m_dlgProgress->IsCanceled()) return; } album.idAlbum = params.GetAlbumId(); album.strAlbum = pItem->GetMusicInfoTag()->GetAlbum(); album.strArtist = pItem->GetMusicInfoTag()->GetArtist(); // we're going to need it's path as well (we assume that there's only one) - this is for // assigning thumbs to folders, and obtaining the local folder.jpg m_musicdatabase.GetAlbumPath(album.idAlbum, strPath); } } else { // lookup is done on a folder - find the albums in the folder CFileItemList items; GetDirectory(strPath, items); // check the first song we find in the folder, and grab it's album info for (int i = 0; i < items.Size() && !foundAlbum; i++) { CFileItem* pItem = items[i]; pItem->LoadMusicTag(); if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded() && !pItem->GetMusicInfoTag()->GetAlbum().IsEmpty()) { // great, have a song - use it. CSong song(*pItem->GetMusicInfoTag()); // this function won't be needed if/when the tag has idSong information if (!m_musicdatabase.GetAlbumFromSong(song, album)) { // album isn't in the database - construct it from the tag info we have CMusicInfoTag *tag = pItem->GetMusicInfoTag(); album.strAlbum = tag->GetAlbum(); album.strArtist = tag->GetAlbumArtist().IsEmpty() ? tag->GetArtist() : tag->GetAlbumArtist(); album.idAlbum = -1; // the -1 indicates it's not in the database } foundAlbum = true; } } if (!foundAlbum) { CLog::Log(LOGINFO, "%s called on a folder containing no songs with tag info - nothing can be done", __FUNCTION__); if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); } } if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); if (album.idAlbum == -1 && foundAlbum == false) ShowArtistInfo(artist, pItem->m_strPath, false, bShowInfo); else ShowAlbumInfo(album, strPath, false, bShowInfo); }
void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo) { // Boxee if (bShowInfo) { g_application.CurrentFileItem() = *pItem; if (pItem->IsLastFM() || pItem->IsRSS() || pItem->IsPlugin() || pItem->IsShoutCast()) { CGUIDialogBoxeeAppCtx *pContext = (CGUIDialogBoxeeAppCtx*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_APP_CTX); pContext->SetItem(*pItem); pContext->DoModal(); } else { if (pItem->HasMusicInfoTag() && !pItem->GetPropertyBOOL("IsArtist")) { CGUIDialogBoxeeMusicCtx *pContext = (CGUIDialogBoxeeMusicCtx*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_MUSIC_CTX); pContext->SetItem(*pItem); pContext->OnMoreInfo(); } else { CGUIWindowMusicInfo* pDlgInfo = (CGUIWindowMusicInfo*)g_windowManager.GetWindow(WINDOW_MUSIC_INFO); if (pDlgInfo) { *(pDlgInfo->GetCurrentListItem()) = *pItem; pDlgInfo->DoModal(); } } } return; } // end boxee section if (pItem->m_bIsFolder && pItem->IsParentFolder()) return; if (!pItem->m_bIsFolder) { // song lookup ShowSongInfo(pItem); return; } CStdString strPath = pItem->m_strPath; // Try to find an album to lookup from the current item CAlbum album; CArtist artist; bool foundAlbum = false; album.idAlbum = -1; // we have a folder if (pItem->IsMusicDb()) { CQueryParams params; CDirectoryNode::GetDatabaseInfo(pItem->m_strPath, params); if (params.GetAlbumId() == -1) { // artist lookup artist.idArtist = params.GetArtistId(); artist.strArtist = pItem->GetMusicInfoTag()->GetArtist(); } else { // album lookup album.idAlbum = params.GetAlbumId(); album.strAlbum = pItem->GetMusicInfoTag()->GetAlbum(); album.strArtist = pItem->GetMusicInfoTag()->GetArtist(); // we're going to need it's path as well (we assume that there's only one) - this is for // assigning thumbs to folders, and obtaining the local folder.jpg m_musicdatabase.GetAlbumPath(album.idAlbum, strPath); } } else { // from filemode, so find the albums in the folder CFileItemList items; GetDirectory(strPath, items); // show dialog box indicating we're searching the album name if (m_dlgProgress && bShowInfo) { m_dlgProgress->SetHeading(185); m_dlgProgress->SetLine(0, 501); m_dlgProgress->SetLine(1, ""); m_dlgProgress->SetLine(2, ""); m_dlgProgress->StartModal(); m_dlgProgress->Progress(); if (m_dlgProgress->IsCanceled()) return; } // check the first song we find in the folder, and grab it's album info for (int i = 0; i < items.Size() && !foundAlbum; i++) { CFileItemPtr pItem = items[i]; pItem->LoadMusicTag(); if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded() && !pItem->GetMusicInfoTag()->GetAlbum().IsEmpty()) { // great, have a song - use it. CSong song(*pItem->GetMusicInfoTag()); // this function won't be needed if/when the tag has idSong information if (!m_musicdatabase.GetAlbumFromSong(song, album)) { // album isn't in the database - construct it from the tag info we have CMusicInfoTag *tag = pItem->GetMusicInfoTag(); album.strAlbum = tag->GetAlbum(); album.strArtist = tag->GetAlbumArtist().IsEmpty() ? tag->GetArtist() : tag->GetAlbumArtist(); album.idAlbum = -1; // the -1 indicates it's not in the database } foundAlbum = true; } } if (!foundAlbum) { CLog::Log(LOGINFO, "%s called on a folder containing no songs with tag info - nothing can be done", __FUNCTION__); if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); return; } if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); } if (album.idAlbum == -1 && foundAlbum == false) ShowArtistInfo(artist, pItem->m_strPath, false, bShowInfo); else ShowAlbumInfo(album, strPath, false, bShowInfo); }