bool CMusicInfoTagLoaderNSF::Load(const CStdString& strFileName, CMusicInfoTag& tag) { tag.SetLoaded(false); if (!m_dll.Load()) return false; m_nsf = m_dll.LoadNSF(strFileName.c_str()); if (!m_nsf) { CLog::Log(LOGERROR,"MusicInfoTagLoaderNSF: failed to open NSF %s",strFileName.c_str()); return false; } tag.SetURL(strFileName); tag.SetLoaded(false); char* szTitle = (char*)m_dll.GetTitle(m_nsf); // no alloc if( szTitle && strcmp(szTitle,"<?>") ) { tag.SetTitle(szTitle); tag.SetLoaded(true); } char* szArtist = (char*)m_dll.GetArtist(m_nsf); // no alloc if( szArtist && strcmp(szArtist,"<?>") && tag.Loaded() ) tag.SetArtist(szArtist); m_dll.FreeNSF(m_nsf); m_nsf = 0; return tag.Loaded(); }
bool CMusicInfoTagLoaderSPC::Load(const CStdString& strFileName, CMusicInfoTag& tag) { tag.SetLoaded(false); CFile file; if (!file.Open(strFileName)) { CLog::Log(LOGERROR,"MusicInfoTagLoaderSPC: failed to open SPC %s",strFileName.c_str()); return false; } tag.SetURL(strFileName); tag.SetLoaded(false); SPC_ID666* spc = SPC_get_id666FP(file); if (!spc) return false; if( strcmp(spc->songname,"") ) { tag.SetTitle(spc->songname); tag.SetLoaded(true); } if( strcmp(spc->author,"") && tag.Loaded() ) tag.SetArtist(spc->author); if (spc->playtime) tag.SetDuration(spc->playtime); else tag.SetDuration(4*60); // 4 mins free(spc); return tag.Loaded(); }
bool CMusicInfoTagLoaderMod::Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) { tag.SetURL(strFileName); // first, does the module have a .mdz? CStdString strMDZ(URIUtils::ReplaceExtension(strFileName,".mdz")); if (CFile::Exists(strMDZ)) { if (!getFile(strMDZ,strMDZ)) { tag.SetLoaded(false); return( false ); } ifstream inMDZ(CSpecialProtocol::TranslatePath(strMDZ.c_str())); char temp[8192]; char temp2[8192]; while (!inMDZ.eof()) { inMDZ.getline(temp,8191); if (strstr(temp,"COMPOSER")) { strcpy(temp2,temp+strlen("COMPOSER ")); tag.SetArtist(temp2); } else if (strstr(temp,"TITLE")) { strcpy(temp2,temp+strlen("TITLE ")); tag.SetTitle(temp2); tag.SetLoaded(true); } else if (strstr(temp,"PLAYTIME")) { char* temp3 = strtok(temp+strlen("PLAYTIME "),":"); int iSecs = atoi(temp3)*60; temp3 = strtok(NULL,":"); iSecs += atoi(temp3); tag.SetDuration(iSecs); } else if (strstr(temp,"STYLE")) { strcpy(temp2,temp+strlen("STYLE ")); tag.SetGenre(temp2); } } return( tag.Loaded() ); } else { // TODO: no, then try to atleast fetch the title } return tag.Loaded(); }
bool CMusicInfoTagLoaderGYM::Load(const CStdString& strFileName, CMusicInfoTag& tag) { tag.SetLoaded(false); if (!m_dll.Load()) return false; m_dll.Init(); m_gym = m_dll.LoadGYM(strFileName.c_str()); if (!m_gym) { CLog::Log(LOGERROR,"MusicInfoTagLoaderGYM: failed to open GYM %s",strFileName.c_str()); return false; } tag.SetURL(strFileName); tag.SetLoaded(false); char* szTitle = (char*)m_dll.GetTitle(m_gym); // no alloc if (szTitle) if( strcmp(szTitle,"") ) { tag.SetTitle(szTitle); tag.SetLoaded(true); } char* szArtist = (char*)m_dll.GetArtist(m_gym); // no alloc if (szArtist) if( strcmp(szArtist,"") && tag.Loaded() ) tag.SetArtist(szArtist); m_dll.FreeGYM(m_gym); m_gym = 0; return tag.Loaded(); }
bool CMusicInfoTagLoaderAdplug::Load(const CStdString& strFileName, CMusicInfoTag& tag) { tag.SetLoaded(false); if (!m_dll.Load()) return false; m_adl = m_dll.LoadADL(strFileName.c_str()); if (!m_adl) { CLog::Log(LOGERROR,"MusicInfoTagLoaderAdplug: failed to open %s",strFileName.c_str()); return false; } tag.SetURL(strFileName); tag.SetLoaded(false); const char* szTitle = m_dll.GetTitle(m_adl); // no alloc if (szTitle) if( strcmp(szTitle,"") ) { tag.SetTitle(szTitle); tag.SetLoaded(true); } const char* szArtist = m_dll.GetArtist(m_adl); // no alloc if( strcmp(szArtist,"") && tag.Loaded() ) tag.SetArtist(szArtist); tag.SetDuration(m_dll.GetLength(m_adl)/1000); m_dll.FreeADL(m_adl); m_adl = 0; return tag.Loaded(); }
bool CMusicInfoTagLoaderDatabase::Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) { tag.SetLoaded(false); CMusicDatabase database; database.Open(); XFILE::MUSICDATABASEDIRECTORY::CQueryParams param; XFILE::MUSICDATABASEDIRECTORY::CDirectoryNode::GetDatabaseInfo(strFileName,param); CSong song; if (database.GetSong(param.GetSongId(),song)) tag.SetSong(song); database.Close(); return tag.Loaded(); }
bool CMusicInfoTagLoaderOgg::Load(const CStdString& strFileName, CMusicInfoTag& tag) { try { // retrieve the OGG Tag info from strFileName // and put it in tag COggTag myTag; if (myTag.Read(strFileName)) { myTag.GetMusicInfoTag(tag); } return tag.Loaded(); } catch (...) { CLog::Log(LOGERROR, "Tag loader ogg: exception in file %s", strFileName.c_str()); } tag.SetLoaded(false); return false; }
bool CMusicInfoTagLoaderFlac::Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art) { try { // retrieve the Flac Tag info from strFileName // and put it in tag CFlacTag myTag; myTag.SetArt(art); if (myTag.Read(strFileName)) { myTag.GetMusicInfoTag(tag); } return tag.Loaded(); } catch (...) { CLog::Log(LOGERROR, "Tag loader flac: exception in file %s", strFileName.c_str()); } tag.SetLoaded(false); return false; }
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; } }
bool SPCCodec::Init(const CStdString &strFile, unsigned int filecache) { // SNESAPU can ONLY be opened and used by one instance (lot's of statics). // So to work around this problem with SNESAPU, we need to make sure that // each instance of SPCCodec has it's own instance of SNESAPU. Do this by // coping DLL_PATH_SPC_CODEC into special://temp and using a unique name. Then // loading this unique named SNESAPU as the library. // This forces the shared lib loader to load a per-instance copy of SNESAPU. #ifdef _LINUX m_loader_name = CUtil::GetNextFilename("special://temp/SNESAPU-%03d.so", 999); XFILE::CFile::Cache(DLL_PATH_SPC_CODEC, m_loader_name); m_loader = new SoLoader(m_loader_name); #else m_loader_name = CUtil::GetNextFilename("special://temp/SNESAPU-%03d.dll", 999); XFILE::CFile::Cache(DLL_PATH_SPC_CODEC, m_loader_name); m_loader = new Win32DllLoader(m_loader_name); #endif if (!m_loader) { XFILE::CFile::Delete(m_loader_name); return false; } if (!m_loader->Load()) { delete m_loader; m_loader = NULL; XFILE::CFile::Delete(m_loader_name); return false; } m_loader->ResolveExport("LoadSPCFile",(void**)&m_dll.LoadSPCFile); m_loader->ResolveExport("EmuAPU",(void**)&m_dll.EmuAPU); m_loader->ResolveExport("SeekAPU",(void**)&m_dll.SeekAPU); #ifdef _LINUX m_loader->ResolveExport("InitAPU",(void**)&m_dll.InitAPU); m_loader->ResolveExport("ResetAPU",(void**)&m_dll.ResetAPU); #endif CFile file; if (!file.Open(strFile)) { CLog::Log(LOGERROR,"SPCCodec: error opening file %s!",strFile.c_str()); return false; } m_szBuffer = new char[0x10200]; if (!file.Read(m_szBuffer,0x10200)) { delete[] m_szBuffer; m_szBuffer = NULL; file.Close(); CLog::Log(LOGERROR,"SPCCodec: error reading file %s!",strFile.c_str()); return false; } file.Close(); m_pApuRAM = new u8[65536]; #ifdef _LINUX m_dll.InitAPU(); m_dll.ResetAPU(); #endif m_dll.LoadSPCFile(m_szBuffer); m_SampleRate = 32000; m_Channels = 2; m_BitsPerSample = 16; CMusicInfoTagLoaderSPC tagLoader; CMusicInfoTag tag; tagLoader.Load(strFile,tag); if (tag.Loaded()) m_TotalTime = tag.GetDuration()*1000; else m_TotalTime = 4*60*1000; // default m_iDataPos = 0; return true; }