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; }
int CScrobbler::AddSong(const CMusicInfoTag& tag) { if ((!g_guiSettings.GetBool("lastfm.enable") && !g_guiSettings.GetBool("lastfm.recordtoprofile")) || !g_guiSettings.GetBool("network.enableinternet")) return 0; if (tag.GetDuration() <= MINLENGTH || tag.GetDuration() > MAXLENGTH) // made <= to minlength to stop iTMS previews being submitted in iTunes return 0; if (!tag.Loaded() || tag.GetArtist().IsEmpty() || tag.GetTitle().IsEmpty()) return 0; if(m_bSubmitInProgress) { StatusUpdate(S_NOT_SUBMITTING,"Previous submission still in progress"); return 0; } char ti[20]; struct tm *today = gmtime(&m_SongStartTime); strftime(ti, sizeof(ti), "%Y-%m-%d %H:%M:%S", today); CStdString a, b, t; // our tags are stored as UTF-8, so no conversion needed a = tag.GetArtist(); b = tag.GetAlbum(); t = tag.GetTitle(); CStdString i=ti; CStdString m=tag.GetMusicBrainzTrackID(); CUtil::URLEncode(a); CUtil::URLEncode(b); CUtil::URLEncode(t); CUtil::URLEncode(i); CUtil::URLEncode(m); CStdString strSubmitStr; strSubmitStr.Format("a[%i]=%s&t[%i]=%s&b[%i]=%s&m[%i]=%s&l[%i]=%i&i[%i]=%s&", m_iSongNum, a.c_str(), m_iSongNum, t.c_str(), m_iSongNum, b.c_str(), m_iSongNum, m.c_str(), m_iSongNum, tag.GetDuration(), m_iSongNum, i.c_str()); if(m_strPostString.find(ti) != m_strPostString.npos) { // we have already tried to add a song at this time stamp // I have no idea how this could happen but apparently it does so // we stop it now StatusUpdate(S_NOT_SUBMITTING,strSubmitStr); StatusUpdate(S_NOT_SUBMITTING,m_strPostString); StatusUpdate(S_NOT_SUBMITTING,"Submission error, duplicate subbmission time found"); return 3; } m_strPostString += strSubmitStr; m_iSongNum++; SaveCache(m_strPostString.c_str(), m_iSongNum); time_t now; time (&now); if ((m_Interval + m_LastConnect) < now) { DoSubmit(); return 1; } else { CStdString strMsg; strMsg.Format("Not submitting, caching for %i more seconds. Cache is %i entries.", (int)(m_Interval + m_LastConnect - now), m_iSongNum); StatusUpdate(S_NOT_SUBMITTING,strMsg); return 2; } }