diff options
49 files changed, 18 insertions, 2949 deletions
diff --git a/Makefile.in b/Makefile.in index 7d3d6b6ed8..c7ae87c235 100644 --- a/Makefile.in +++ b/Makefile.in @@ -58,7 +58,6 @@ DIRECTORY_ARCHIVES=$(DVDPLAYER_ARCHIVES) \ xbmc/music/music.a \ xbmc/music/tags/musictags.a \ xbmc/music/windows/musicwindows.a \ - xbmc/network/libscrobbler/scrobbler.a \ xbmc/network/websocket/websocket.a \ xbmc/network/network.a \ xbmc/peripherals/bus/peripheral-bus.a \ diff --git a/language/English/strings.po b/language/English/strings.po index 957ceebee1..01c4263872 100644 --- a/language/English/strings.po +++ b/language/English/strings.po @@ -6007,57 +6007,6 @@ msgctxt "#15200" msgid "Last.fm" msgstr "" -#: xbmc/settings/GUISettings.cpp -msgctxt "#15201" -msgid "Submit songs to Last.fm" -msgstr "" - -#: xbmc/settings/GUISettings.cpp -msgctxt "#15202" -msgid "Last.fm username" -msgstr "" - -#: xbmc/settings/GUISettings.cpp -msgctxt "#15203" -msgid "Last.fm password" -msgstr "" - -msgctxt "#15204" -msgid "Unable to handshake: sleeping..." -msgstr "" - -msgctxt "#15205" -msgid "Please update XBMC" -msgstr "" - -msgctxt "#15206" -msgid "Bad authorization: Check username and password" -msgstr "" - -msgctxt "#15207" -msgid "Connected" -msgstr "" - -msgctxt "#15208" -msgid "Not connected" -msgstr "" - -msgctxt "#15209" -msgid "Submit interval %i" -msgstr "" - -msgctxt "#15210" -msgid "Cached %i songs" -msgstr "" - -msgctxt "#15211" -msgid "Submitting..." -msgstr "" - -msgctxt "#15212" -msgid "Submitting in %i secs" -msgstr "" - msgctxt "#15213" msgid "Play using..." msgstr "" @@ -6074,227 +6023,7 @@ msgctxt "#15216" msgid "Play in party mode" msgstr "" -#: xbmc/settings/GUISettings.cpp -msgctxt "#15217" -msgid "Submit songs to Libre.fm" -msgstr "" - -#: xbmc/settings/GUISettings.cpp -msgctxt "#15218" -msgid "Libre.fm username" -msgstr "" - -#: xbmc/settings/GUISettings.cpp -msgctxt "#15219" -msgid "Libre.fm password" -msgstr "" - -msgctxt "#15220" -msgid "Libre.fm" -msgstr "" - -#: xbmc/settings/GUISettings.cpp -msgctxt "#15221" -msgid "Song submission" -msgstr "" - -#empty strings from id 15222 to 15249 - -msgctxt "#15250" -msgid "Submit Last.fm radio to Last.fm" -msgstr "" - -msgctxt "#15251" -msgid "Connecting to Last.fm..." -msgstr "" - -msgctxt "#15252" -msgid "Selecting station..." -msgstr "" - -msgctxt "#15253" -msgid "Search similar artists..." -msgstr "" - -msgctxt "#15254" -msgid "Search similar tags..." -msgstr "" - -msgctxt "#15255" -msgid "Your profile (%name%)" -msgstr "" - -msgctxt "#15256" -msgid "Overall top tags" -msgstr "" - -msgctxt "#15257" -msgid "Top artists for tag %name%" -msgstr "" - -msgctxt "#15258" -msgid "Top albums for tag %name%" -msgstr "" - -msgctxt "#15259" -msgid "Top tracks for tag %name%" -msgstr "" - -msgctxt "#15260" -msgid "Listen to tag %name% Last.fm radio" -msgstr "" - -msgctxt "#15261" -msgid "Similar artists as %name%" -msgstr "" - -msgctxt "#15262" -msgid "Top %name% albums" -msgstr "" - -msgctxt "#15263" -msgid "Top %name% tracks" -msgstr "" - -msgctxt "#15264" -msgid "Top %name% tags" -msgstr "" - -msgctxt "#15265" -msgid "Biggest fans of %name%" -msgstr "" - -msgctxt "#15266" -msgid "Listen to %name% fans Last.fm radio" -msgstr "" - -msgctxt "#15267" -msgid "Listen to %name% similar artists Last.fm radio" -msgstr "" - -msgctxt "#15268" -msgid "Top artists for user %name%" -msgstr "" - -msgctxt "#15269" -msgid "Top albums for user %name%" -msgstr "" - -msgctxt "#15270" -msgid "Top tracks for user %name%" -msgstr "" - -msgctxt "#15271" -msgid "Friends of user %name%" -msgstr "" - -msgctxt "#15272" -msgid "Neighbours of user %name%" -msgstr "" - -msgctxt "#15273" -msgid "Weekly artist chart for %name%" -msgstr "" - -msgctxt "#15274" -msgid "Weekly album chart for %name%" -msgstr "" - -msgctxt "#15275" -msgid "Weekly track chart for %name%" -msgstr "" - -msgctxt "#15276" -msgid "Listen to %name%'s neighbours Last.fm radio" -msgstr "" - -msgctxt "#15277" -msgid "Listen to %name%'s personal Last.fm radio" -msgstr "" - -msgctxt "#15278" -msgid "Listen to %name%'s mix Last.fm radio" -msgstr "" - -msgctxt "#15279" -msgid "Retrieving list from Last.fm..." -msgstr "" - -msgctxt "#15280" -msgid "Can't retrieve list from Last.fm..." -msgstr "" - -msgctxt "#15281" -msgid "Enter an artist name to find related ones" -msgstr "" - -msgctxt "#15282" -msgid "Enter a tag name to find similar ones" -msgstr "" - -msgctxt "#15283" -msgid "Tracks recently listened by %name%" -msgstr "" - -msgctxt "#15284" -msgid "Listen to %name%'s recommendations Last.fm radio" -msgstr "" - -msgctxt "#15285" -msgid "Top tags for user %name%" -msgstr "" - -#empty string with id 15286 - -msgctxt "#15287" -msgid "Do you want to add the current track to your loved tracks?" -msgstr "" - -msgctxt "#15288" -msgid "Do you want to ban the current track?" -msgstr "" - -msgctxt "#15289" -msgid "Added to your loved tracks: '%s'." -msgstr "" - -msgctxt "#15290" -msgid "Could not add '%s' to your loved tracks." -msgstr "" - -msgctxt "#15291" -msgid "Banned: '%s'." -msgstr "" - -msgctxt "#15292" -msgid "Could not ban '%s'." -msgstr "" - -msgctxt "#15293" -msgid "Tracks recently loved by %name%" -msgstr "" - -msgctxt "#15294" -msgid "Tracks recently banned by %name%" -msgstr "" - -msgctxt "#15295" -msgid "Remove from loved tracks" -msgstr "" - -msgctxt "#15296" -msgid "Un-ban" -msgstr "" - -msgctxt "#15297" -msgid "Do you want to remove this track from your loved tracks?" -msgstr "" - -msgctxt "#15298" -msgid "Do you want to un-ban this track?" -msgstr "" - -#empty string with id 15299 +#empty strings from id 15216 to 15299 msgctxt "#15300" msgid "Path not found or invalid" @@ -12012,4 +11741,4 @@ msgstr "" #: xbmc/settings/GUISettings.cpp msgctxt "#36042" msgid "Use limited color range (16-235)" -msgstr ""
\ No newline at end of file +msgstr "" diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index cac91dbd34..cf1a476a51 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -61,8 +61,6 @@ #endif #include "input/ButtonTranslator.h" #include "guilib/GUIAudioManager.h" -#include "network/libscrobbler/lastfmscrobbler.h" -#include "network/libscrobbler/librefmscrobbler.h" #include "GUIPassword.h" #include "input/InertialScrollingHandler.h" #include "ApplicationMessenger.h" @@ -86,7 +84,6 @@ #include "utils/TimeUtils.h" #include "GUILargeTextureManager.h" #include "TextureCache.h" -#include "music/LastFmManager.h" #include "playlists/SmartPlayList.h" #ifdef HAS_FILESYSTEM_RAR #include "filesystem/RarManager.h" @@ -3452,9 +3449,6 @@ bool CApplication::Cleanup() g_charsetConverter.clear(); g_directoryCache.Clear(); CButtonTranslator::GetInstance().Clear(); - CLastfmScrobbler::RemoveInstance(); - CLibrefmScrobbler::RemoveInstance(); - CLastFmManager::RemoveInstance(); #ifdef HAS_EVENT_SERVER CEventServer::RemoveInstance(); #endif @@ -3642,11 +3636,6 @@ bool CApplication::PlayMedia(const CFileItem& item, int iPlaylist) return PlayMedia(item_new, iPlaylist); return false; } - if (item.IsLastFM()) - { - g_partyModeManager.Disable(); - return CLastFmManager::GetInstance()->ChangeStation(item.GetAsUrl()); - } if (item.IsSmartPlayList()) { CFileItemList items; @@ -4189,12 +4178,6 @@ void CApplication::OnPlayBackEnded() data["end"] = true; CAnnouncementManager::Announce(Player, "xbmc", "OnStop", m_itemCurrentFile, data); - if (IsPlayingAudio()) - { - CLastfmScrobbler::GetInstance()->SubmitQueue(); - CLibrefmScrobbler::GetInstance()->SubmitQueue(); - } - CGUIMessage msg(GUI_MSG_PLAYBACK_ENDED, 0, 0); g_windowManager.SendThreadMessage(msg); } @@ -4222,12 +4205,6 @@ void CApplication::OnQueueNextItem() g_pythonParser.OnQueueNextItem(); // currently unimplemented #endif - if(IsPlayingAudio()) - { - CLastfmScrobbler::GetInstance()->SubmitQueue(); - CLibrefmScrobbler::GetInstance()->SubmitQueue(); - } - CGUIMessage msg(GUI_MSG_QUEUE_NEXT_ITEM, 0, 0); g_windowManager.SendThreadMessage(msg); } @@ -4247,9 +4224,6 @@ void CApplication::OnPlayBackStopped() data["end"] = false; CAnnouncementManager::Announce(Player, "xbmc", "OnStop", m_itemCurrentFile, data); - CLastfmScrobbler::GetInstance()->SubmitQueue(); - CLibrefmScrobbler::GetInstance()->SubmitQueue(); - CGUIMessage msg( GUI_MSG_PLAYBACK_STOPPED, 0, 0 ); g_windowManager.SendThreadMessage(msg); } @@ -4807,7 +4781,6 @@ bool CApplication::OnMessage(CGUIMessage& message) *m_itemCurrentFile = *item; } g_infoManager.SetCurrentItem(*m_itemCurrentFile); - CLastFmManager::GetInstance()->OnSongChange(*m_itemCurrentFile); g_partyModeManager.OnSongChange(true); CVariant param; @@ -4836,13 +4809,6 @@ bool CApplication::OnMessage(CGUIMessage& message) m_pKaraokeMgr->Start(m_itemCurrentFile->GetPath()); } #endif - // Let scrobbler know about the track - const CMusicInfoTag* tag=g_infoManager.GetCurrentSongTag(); - if (tag) - { - CLastfmScrobbler::GetInstance()->AddSong(*tag, CLastFmManager::GetInstance()->IsRadioEnabled()); - CLibrefmScrobbler::GetInstance()->AddSong(*tag, CLastFmManager::GetInstance()->IsRadioEnabled()); - } } return true; @@ -4925,10 +4891,6 @@ bool CApplication::OnMessage(CGUIMessage& message) } else { - // stop lastfm - if (CLastFmManager::GetInstance()->IsRadioEnabled()) - CLastFmManager::GetInstance()->StopRadio(); - // reset any forced player m_eForcedNextPlayer = EPC_NONE; @@ -5059,7 +5021,7 @@ void CApplication::Process() if (g_application.m_bStop) return; //we're done, everything has been unloaded // check how far we are through playing the current item - // and do anything that needs doing (lastfm submission, playcount updates etc) + // and do anything that needs doing (playcount updates etc) CheckPlayingProgress(); // update sound @@ -5100,12 +5062,6 @@ void CApplication::ProcessSlow() // Store our file state for use on close() UpdateFileState(); - if (IsPlayingAudio()) - { - CLastfmScrobbler::GetInstance()->UpdateStatus(); - CLibrefmScrobbler::GetInstance()->UpdateStatus(); - } - // Check if we need to activate the screensaver / DPMS. CheckScreenSaverAndDPMS(); diff --git a/xbmc/Application.h b/xbmc/Application.h index 3195c49543..34ed9afbb5 100644 --- a/xbmc/Application.h +++ b/xbmc/Application.h @@ -203,7 +203,6 @@ public: // Checks whether the screensaver and / or DPMS should become active. void CheckScreenSaverAndDPMS(); void CheckPlayingProgress(); - void CheckAudioScrobblerStatus(); void ActivateScreenSaver(bool forceType = false); virtual void Process(); diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp index d501cb126b..882a29cd19 100644 --- a/xbmc/FileItem.cpp +++ b/xbmc/FileItem.cpp @@ -842,7 +842,6 @@ bool CFileItem::IsAudio() const if (HasVideoInfoTag()) return false; if (HasPictureInfoTag()) return false; if (IsCDDA()) return true; - if (!m_bIsFolder && IsLastFM()) return true; CStdString extension; if( m_mimetype.Left(12).Equals("application/") ) @@ -866,7 +865,7 @@ bool CFileItem::IsAudio() const bool CFileItem::IsKaraoke() const { - if ( !IsAudio() || IsLastFM()) + if ( !IsAudio()) return false; return CKaraokeLyricsFactory::HasLyrics( m_strPath ); @@ -894,11 +893,6 @@ bool CFileItem::IsCUESheet() const return URIUtils::GetExtension(m_strPath).Equals(".cue", false); } -bool CFileItem::IsLastFM() const -{ - return URIUtils::IsLastFM(m_strPath); -} - bool CFileItem::IsInternetStream(const bool bStrictCheck /* = false */) const { if (HasProperty("IsHTTPDirectory")) diff --git a/xbmc/FileItem.h b/xbmc/FileItem.h index 85ee00f9db..3bc077ac87 100644 --- a/xbmc/FileItem.h +++ b/xbmc/FileItem.h @@ -111,7 +111,6 @@ public: bool IsAudio() const; bool IsKaraoke() const; bool IsCUESheet() const; - bool IsLastFM() const; bool IsInternetStream(const bool bStrictCheck = false) const; bool IsPlayList() const; bool IsSmartPlayList() const; diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index 767e990583..686f31d5d2 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -25,7 +25,6 @@ #include "dialogs/GUIDialogProgress.h" #include "Application.h" #include "Util.h" -#include "network/libscrobbler/lastfmscrobbler.h" #include "utils/URIUtils.h" #include "utils/Weather.h" #include "PartyModeManager.h" @@ -36,7 +35,6 @@ #include "utils/SystemInfo.h" #include "guilib/GUITextBox.h" #include "pictures/GUIWindowSlideShow.h" -#include "music/LastFmManager.h" #include "pictures/PictureInfoTag.h" #include "music/tags/MusicInfoTag.h" #include "guilib/GUIWindowManager.h" @@ -299,16 +297,6 @@ const infomap musicpartymode[] = {{ "enabled", MUSICPM_ENABLED }, { "relaxedsongspicked",MUSICPM_RELAXEDSONGSPICKED }, { "randomsongspicked", MUSICPM_RANDOMSONGSPICKED }}; -const infomap audioscrobbler[] = {{ "enabled", AUDIOSCROBBLER_ENABLED }, - { "connectstate", AUDIOSCROBBLER_CONN_STATE }, //labels from here - { "submitinterval", AUDIOSCROBBLER_SUBMIT_INT }, - { "filescached", AUDIOSCROBBLER_FILES_CACHED }, - { "submitstate", AUDIOSCROBBLER_SUBMIT_STATE }}; - -const infomap lastfm[] = {{ "radioplaying", LASTFM_RADIOPLAYING }, - { "canlove", LASTFM_CANLOVE}, - { "canban", LASTFM_CANBAN}}; - const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE }, { "album", MUSICPLAYER_ALBUM }, { "artist", MUSICPLAYER_ARTIST }, @@ -802,22 +790,6 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition) return musicpartymode[i].val; } } - else if (cat.name == "audioscrobbler") - { - for (size_t i = 0; i < sizeof(audioscrobbler) / sizeof(infomap); i++) - { - if (prop.name == audioscrobbler[i].str) - return audioscrobbler[i].val; - } - } - else if (cat.name == "lastfm") - { - for (size_t i = 0; i < sizeof(lastfm) / sizeof(infomap); i++) - { - if (prop.name == lastfm[i].str) - return lastfm[i].val; - } - } else if (cat.name == "system") { for (size_t i = 0; i < sizeof(system_labels) / sizeof(infomap); i++) @@ -1786,12 +1758,6 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa } break; - case AUDIOSCROBBLER_CONN_STATE: - case AUDIOSCROBBLER_SUBMIT_INT: - case AUDIOSCROBBLER_FILES_CACHED: - case AUDIOSCROBBLER_SUBMIT_STATE: - strLabel=GetAudioScrobblerLabel(info); - break; case VISUALISATION_PRESET: { CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0); @@ -2350,18 +2316,6 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI case MUSICPM_ENABLED: bReturn = g_partyModeManager.IsEnabled(); break; - case AUDIOSCROBBLER_ENABLED: - bReturn = CLastFmManager::GetInstance()->IsLastFmEnabled(); - break; - case LASTFM_RADIOPLAYING: - bReturn = CLastFmManager::GetInstance()->IsRadioEnabled(); - break; - case LASTFM_CANLOVE: - bReturn = CLastFmManager::GetInstance()->CanLove(); - break; - case LASTFM_CANBAN: - bReturn = CLastFmManager::GetInstance()->CanBan(); - break; case MUSICPLAYER_HASPREVIOUS: { // requires current playlist be PLAYLIST_MUSIC @@ -4002,27 +3956,6 @@ bool CGUIInfoManager::GetDisplayAfterSeek() return false; } -CStdString CGUIInfoManager::GetAudioScrobblerLabel(int item) -{ - switch (item) - { - case AUDIOSCROBBLER_CONN_STATE: - return CLastfmScrobbler::GetInstance()->GetConnectionState(); - break; - case AUDIOSCROBBLER_SUBMIT_INT: - return CLastfmScrobbler::GetInstance()->GetSubmitInterval(); - break; - case AUDIOSCROBBLER_FILES_CACHED: - return CLastfmScrobbler::GetInstance()->GetFilesCached(); - break; - case AUDIOSCROBBLER_SUBMIT_STATE: - return CLastfmScrobbler::GetInstance()->GetSubmitState(); - break; - } - - return ""; -} - void CGUIInfoManager::Clear() { CSingleLock lock(m_critInfo); diff --git a/xbmc/GUIInfoManager.h b/xbmc/GUIInfoManager.h index 0b03789a40..6a3410a8d5 100644 --- a/xbmc/GUIInfoManager.h +++ b/xbmc/GUIInfoManager.h @@ -269,15 +269,6 @@ namespace INFO #define VIDEOPLAYER_PARENTAL_RATING 307 #define VIDEOPLAYER_HAS_EPG 308 -#define AUDIOSCROBBLER_ENABLED 325 -#define AUDIOSCROBBLER_CONN_STATE 326 -#define AUDIOSCROBBLER_SUBMIT_INT 327 -#define AUDIOSCROBBLER_FILES_CACHED 328 -#define AUDIOSCROBBLER_SUBMIT_STATE 329 -#define LASTFM_RADIOPLAYING 330 -#define LASTFM_CANLOVE 331 -#define LASTFM_CANBAN 332 - #define CONTAINER_CAN_FILTER 342 #define CONTAINER_CAN_FILTERADVANCED 343 #define CONTAINER_FILTERED 344 @@ -847,8 +838,6 @@ protected: int AddMultiInfo(const GUIInfo &info); int AddListItemProp(const CStdString &str, int offset=0); - CStdString GetAudioScrobblerLabel(int item); - /*! * @brief Get the EPG tag that is currently active * @param tag The active tag diff --git a/xbmc/URL.cpp b/xbmc/URL.cpp index f90c647d14..6599e8df22 100644 --- a/xbmc/URL.cpp +++ b/xbmc/URL.cpp @@ -312,7 +312,6 @@ void CURL::Parse(const CStdString& strURL1) || m_strProtocol.CompareNoCase("musicdb") == 0 || m_strProtocol.CompareNoCase("videodb") == 0 || m_strProtocol.CompareNoCase("sources") == 0 - || m_strProtocol.CompareNoCase("lastfm") == 0 || m_strProtocol.CompareNoCase("pvr") == 0 || m_strProtocol.Left(3).CompareNoCase("mem") == 0) { @@ -755,7 +754,6 @@ CStdString CURL::TranslateProtocol(const CStdString& prot) || prot == "daap" || prot == "dav" || prot == "tuxbox" - || prot == "lastfm" || prot == "rss") return "http"; diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index 62a780e7be..6ef1856ff7 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -146,15 +146,6 @@ CStdString CUtil::GetTitleFromPath(const CStdString& strFileNameAndPath, bool bI return items.m_strTitle; } - // LastFM - if (url.GetProtocol() == "lastfm") - { - if (strFilename.IsEmpty()) - strFilename = g_localizeStrings.Get(15200); - else - strFilename = g_localizeStrings.Get(15200) + " - " + strFilename; - } - // Shoutcast else if (url.GetProtocol() == "shout") { @@ -1179,8 +1170,6 @@ int CUtil::GetMatchingSource(const CStdString& strPath1, VECSOURCES& VECSOURCES, if (checkURL.GetProtocol() == "shout") strPath = checkURL.GetHostName(); - if (checkURL.GetProtocol() == "lastfm") - return 1; if (checkURL.GetProtocol() == "tuxbox") return 1; if (checkURL.GetProtocol() == "plugin") diff --git a/xbmc/cores/paplayer/CodecFactory.cpp b/xbmc/cores/paplayer/CodecFactory.cpp index 8e546a1893..7decb523dc 100644 --- a/xbmc/cores/paplayer/CodecFactory.cpp +++ b/xbmc/cores/paplayer/CodecFactory.cpp @@ -150,7 +150,7 @@ ICodec* CodecFactory::CreateCodecDemux(const CStdString& strFile, const CStdStri else if (strContent.Equals("audio/flac") || strContent.Equals("audio/x-flac") || strContent.Equals("application/x-flac")) return new FLACCodec(); - if (urlFile.GetProtocol() == "lastfm" || urlFile.GetProtocol() == "shout") + if (urlFile.GetProtocol() == "shout") { return new MP3Codec(); // if we got this far with internet radio - content-type was wrong. gamble on mp3. } diff --git a/xbmc/cores/paplayer/MP3codec.cpp b/xbmc/cores/paplayer/MP3codec.cpp index 2ee229245c..d49b83ddb0 100644 --- a/xbmc/cores/paplayer/MP3codec.cpp +++ b/xbmc/cores/paplayer/MP3codec.cpp @@ -174,7 +174,7 @@ bool MP3Codec::Init(const CStdString &strFile, unsigned int filecache) length = m_file.GetLength(); if (length != 0) { - CTagLoaderTagLib tagLoaderTagLib; //opens the file so needs to be after m_file.Open or lastfm radio breaks. + CTagLoaderTagLib tagLoaderTagLib; //opens the file so needs to be after m_file.Open bTags = tagLoaderTagLib.Load(strFile, m_tag); if (bTags) diff --git a/xbmc/filesystem/DirectoryFactory.cpp b/xbmc/filesystem/DirectoryFactory.cpp index 0f5c39392c..73c3c3edb0 100644 --- a/xbmc/filesystem/DirectoryFactory.cpp +++ b/xbmc/filesystem/DirectoryFactory.cpp @@ -36,7 +36,6 @@ #include "LibraryDirectory.h" #include "AddonsDirectory.h" #include "SourcesDirectory.h" -#include "LastFMDirectory.h" #include "FTPDirectory.h" #include "HTTPDirectory.h" #include "DAVDirectory.h" @@ -169,7 +168,6 @@ IDirectory* CDirectoryFactory::Create(const CStdString& strPath) if( g_application.getNetwork().IsAvailable(true) ) // true to wait for the network (if possible) { - if (strProtocol == "lastfm") return new CLastFMDirectory(); if (strProtocol == "tuxbox") return new CTuxBoxDirectory(); if (strProtocol == "ftp" || strProtocol == "ftps") return new CFTPDirectory(); if (strProtocol == "http" || strProtocol == "https") return new CHTTPDirectory(); diff --git a/xbmc/filesystem/FileFactory.cpp b/xbmc/filesystem/FileFactory.cpp index 1483e31e5b..40f4180fa9 100644 --- a/xbmc/filesystem/FileFactory.cpp +++ b/xbmc/filesystem/FileFactory.cpp @@ -30,7 +30,6 @@ #include "HTTPFile.h" #include "DAVFile.h" #include "ShoutcastFile.h" -#include "LastFMFile.h" #include "FileReaderFile.h" #ifdef HAS_FILESYSTEM_SMB #ifdef _WIN32 @@ -156,7 +155,6 @@ IFile* CFileFactory::CreateLoader(const CURL& url) else if (strProtocol == "sftp" || strProtocol == "ssh") return new CSFTPFile(); #endif else if (strProtocol == "shout") return new CShoutcastFile(); - else if (strProtocol == "lastfm") return new CLastFMFile(); else if (strProtocol == "tuxbox") return new CTuxBoxFile(); else if (strProtocol == "hdhomerun") return new CHomeRunFile(); else if (strProtocol == "sling") return new CSlingboxFile(); diff --git a/xbmc/filesystem/LastFMDirectory.cpp b/xbmc/filesystem/LastFMDirectory.cpp deleted file mode 100644 index 08092bd1aa..0000000000 --- a/xbmc/filesystem/LastFMDirectory.cpp +++ /dev/null @@ -1,631 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include "LastFMDirectory.h" -#include "DirectoryCache.h" -#include "music/tags/MusicInfoTag.h" -#include "URL.h" -#include "guilib/GUIWindowManager.h" -#include "dialogs/GUIDialogProgress.h" -#include "settings/GUISettings.h" -#include "FileItem.h" -#include "CurlFile.h" -#include "utils/StringUtils.h" -#include "guilib/LocalizeStrings.h" -#include "utils/log.h" - -using namespace MUSIC_INFO; -using namespace XFILE; - -#define AUDIOSCROBBLER_BASE_URL "http://ws.audioscrobbler.com/1.0/" - -CLastFMDirectory::CLastFMDirectory() -{ - m_Error = false; - m_Downloaded = false; -} - -CLastFMDirectory::~CLastFMDirectory() -{ -} - -CStdString CLastFMDirectory::BuildURLFromInfo() -{ - CStdString strURL = (CStdString)AUDIOSCROBBLER_BASE_URL; - strURL += m_objtype + "/" + m_encodedobjname + "/" + m_objrequest + ".xml"; - - return strURL; -} - -bool CLastFMDirectory::RetrieveList(CStdString url) -{ - m_dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); - if (m_dlgProgress) - { - m_dlgProgress->ShowProgressBar(false); - m_dlgProgress->SetHeading(2); - m_dlgProgress->SetLine(0, 15279); - m_dlgProgress->SetLine(1, m_objrequest); - m_dlgProgress->SetLine(2, m_objname); - m_dlgProgress->StartModal(); - m_dlgProgress->Progress(); - } - - CThread thread(this, "CLastFMDirectory"); - m_strSource = url; - m_strDestination = "special://temp/lastfm.xml"; - thread.Create(); - - while (!m_Downloaded) - { - if (m_dlgProgress) - { - m_dlgProgress->Progress(); - - if (m_dlgProgress->IsCanceled()) - { - m_http.Cancel(); - thread.StopThread(); - m_dlgProgress->Close(); - return false; - } - } - } - - if (m_dlgProgress && !m_dlgProgress->IsCanceled() && m_Error) - { - if (m_dlgProgress) m_dlgProgress->Close(); - SetErrorDialog(257, 15280, 0, 0); - CLog::Log(LOGERROR, "Unable to retrieve list from last.fm"); - return false; - } - - - if (!m_xmlDoc.LoadFile(m_strDestination)) - { - if (m_dlgProgress) m_dlgProgress->Close(); - SetErrorDialog(257, 15280, 0, 0); - CLog::Log(LOGERROR, "Error parsing file from audioscrobbler web services, Line %d\n%s", m_xmlDoc.ErrorRow(), m_xmlDoc.ErrorDesc()); - return false; - } - - if (m_dlgProgress) m_dlgProgress->Close(); - - return true; -} - -void CLastFMDirectory::AddEntry(int iString, CStdString strPath, CStdString strIconPath, bool bFolder, CFileItemList &items) -{ - CStdString strLabel = g_localizeStrings.Get(iString); - strLabel.Replace("%name%", m_objname); - strLabel.Replace("%type%", m_objtype); - strLabel.Replace("%request%", m_objrequest); - strPath.Replace("%name%", m_encodedobjname); - strPath.Replace("%type%", m_objtype); - strPath.Replace("%request%", m_objrequest); - - CFileItemPtr pItem(new CFileItem); - pItem->SetLabel(strLabel); - pItem->SetPath(strPath); - pItem->m_bIsFolder = bFolder; - pItem->SetLabelPreformated(true); - //the extra info is used in the mediawindows to determine which items are needed in the contextmenu - if (strPath.Find("lastfm://xbmc") >= 0) - { - pItem->SetCanQueue(false); - pItem->SetExtraInfo("lastfmitem"); - } - - items.Add(pItem); -} - -void CLastFMDirectory::AddListEntry(const char *name, const char *artist, const char *count, const char *date, const char *icon, CStdString strPath, CFileItemList &items) -{ - CStdString strName; - CFileItemPtr pItem(new CFileItem); - CMusicInfoTag* musicinfotag = pItem->GetMusicInfoTag(); - musicinfotag->SetTitle(name); - - if (artist) - { - strName.Format("%s - %s", artist, name); - musicinfotag->SetArtist(artist); - } - else - { - strName = name; - } - - if (count) - { - pItem->SetLabel2(count); - pItem->m_dwSize = _atoi64(count) * 100000000; - - const char *dot; - if ((dot = (const char *)strstr(count, "."))) - pItem->m_dwSize += _atoi64(dot + 1); - } - - pItem->SetLabel(strName); - pItem->SetPath(strPath); - pItem->m_bIsFolder = true; - pItem->SetLabelPreformated(true); - - if (date) - { - LONGLONG ll = Int32x32To64(atoi(date), 10000000) + 116444736000000000LL; - FILETIME ft; - - ft.dwLowDateTime = (DWORD)(ll & 0xFFFFFFFF); - ft.dwHighDateTime = (DWORD)(ll >> 32); - - pItem->m_dateTime=ft; - } - - pItem->SetCanQueue(false); - //the extra info is used in the mediawindows to determine which items are needed in the contextmenu - if (m_objname.Equals(g_guiSettings.GetString("scrobbler.lastfmusername"))) - { - if (m_objrequest.Equals("recentbannedtracks")) - { - pItem->SetExtraInfo("lastfmbanned"); - } - else if (m_objrequest.Equals("recentlovedtracks")) - { - pItem->SetExtraInfo("lastfmloved"); - } - } - if (pItem->GetExtraInfo().IsEmpty() && strPath.Find("lastfm://xbmc") >= 0) - { - pItem->SetExtraInfo("lastfmitem"); - } - - // icons? would probably take too long to retrieve them all - items.Add(pItem); -} - -bool CLastFMDirectory::ParseArtistList(CStdString url, CFileItemList &items) -{ - if (!RetrieveList(url)) - return false; - - TiXmlElement* pRootElement = m_xmlDoc.RootElement(); - - TiXmlElement* pEntry = pRootElement->FirstChildElement("artist"); - - while(pEntry) - { - TiXmlNode* name = pEntry->FirstChild("name"); - TiXmlNode* count; - const char *countstr = NULL; - const char *namestr = NULL; - - count = pEntry->FirstChild("count"); - if (!count) count = pEntry->FirstChild("playcount"); - if (!count) count = pEntry->FirstChild("match"); - if (!count && pEntry->Attribute("count")) - countstr = pEntry->Attribute("count"); - else if (count) - countstr = count->FirstChild()->Value(); - - if (name) - namestr = name->FirstChild()->Value(); - else - namestr = pEntry->Attribute("name"); - - - if (namestr && countstr) - AddListEntry(namestr, NULL, countstr, NULL, NULL, - "lastfm://xbmc/artist/" + (CStdString)namestr + "/", items); - - pEntry = pEntry->NextSiblingElement("artist"); - } - - m_xmlDoc.Clear(); - return true; -} - -bool CLastFMDirectory::ParseAlbumList(CStdString url, CFileItemList &items) -{ - if (!RetrieveList(url)) - return false; - - TiXmlElement* pRootElement = m_xmlDoc.RootElement(); - - TiXmlElement* pEntry = pRootElement->FirstChildElement("album"); - - while(pEntry) - { - const char *artist = pRootElement->Attribute("artist"); - const char *name = NULL; - const char *count = NULL; - - if (pEntry->Attribute("name")) - name = pEntry->Attribute("name"); - else - { - TiXmlNode* nameNode = pEntry->FirstChild("name"); - if (nameNode && nameNode->FirstChild()) - name = nameNode->FirstChild()->Value(); - } - - TiXmlElement* artistElement = pEntry->FirstChildElement("artist"); - if (artistElement && artistElement->Attribute("name")) - artist = artistElement->Attribute("name"); - else - { - if (artistElement && artistElement->FirstChild()) - artist = artistElement->FirstChild()->Value(); - } - - if (pEntry->Attribute("count")) - count = pEntry->Attribute("count"); - else - { - TiXmlNode* countNode = pEntry->FirstChild("count"); - if (!countNode) countNode = pEntry->FirstChild("playcount"); - if (!countNode) countNode = pEntry->FirstChild("reach"); - if (countNode) - count = countNode->FirstChild()->Value(); - } - - AddListEntry(name, artist, count, NULL, NULL, - "lastfm://xbmc/artist/" + (CStdString)artist + "/", items); - - pEntry = pEntry->NextSiblingElement("album"); - } - - m_xmlDoc.Clear(); - return true; -} - -bool CLastFMDirectory::ParseUserList(CStdString url, CFileItemList &items) -{ - if (!RetrieveList(url)) - return false; - - TiXmlElement* pRootElement = m_xmlDoc.RootElement(); - - TiXmlElement* pEntry = pRootElement->FirstChildElement("user"); - - while(pEntry) - { - const char *name = pEntry->Attribute("username"); - - TiXmlNode* count; - count = pEntry->FirstChild("weight"); - if (!count) count = pEntry->FirstChild("match"); - - if (name) - { - AddListEntry(name, NULL, (count && count->FirstChild()) ? count->FirstChild()->Value() : NULL, NULL, NULL, - "lastfm://xbmc/user/" + (CStdString)name + "/", items); - } - - pEntry = pEntry->NextSiblingElement("user"); - } - - m_xmlDoc.Clear(); - return true; -} - -bool CLastFMDirectory::ParseTagList(CStdString url, CFileItemList &items) -{ - if (!RetrieveList(url)) - return false; - - TiXmlElement* pRootElement = m_xmlDoc.RootElement(); - - TiXmlElement* pEntry = pRootElement->FirstChildElement("tag"); - - while(pEntry) - { - TiXmlNode* name = pEntry->FirstChild("name"); - TiXmlNode* count; - const char *countstr = NULL; - const char *namestr = NULL; - - count = pEntry->FirstChild("count"); - if (!count) count = pEntry->FirstChild("playcount"); - if (!count) count = pEntry->FirstChild("match"); - if (!count && pEntry->Attribute("count")) - countstr = pEntry->Attribute("count"); - else if (count && count->FirstChild()) - countstr = count->FirstChild()->Value(); - - if (name && name->FirstChild()) - namestr = name->FirstChild()->Value(); - else - namestr = pEntry->Attribute("name"); - - if (namestr && countstr) - { - AddListEntry(namestr, NULL, countstr, NULL, NULL, - "lastfm://xbmc/tag/" + (CStdString)namestr + "/", items); - } - - pEntry = pEntry->NextSiblingElement("tag"); - } - - m_xmlDoc.Clear(); - return true; -} - -bool CLastFMDirectory::ParseTrackList(CStdString url, CFileItemList &items) -{ - if (!RetrieveList(url)) - return false; - - TiXmlElement* pRootElement = m_xmlDoc.RootElement(); - - TiXmlElement* pEntry = pRootElement->FirstChildElement("track"); - - while(pEntry) - { - TiXmlNode* name = pEntry->FirstChild("name"); - TiXmlNode* artist = pEntry->FirstChild("artist"); - TiXmlElement *date = pEntry->FirstChildElement("date"); - - TiXmlNode* count; - count = pEntry->FirstChild("count"); - if (!count) count = pEntry->FirstChild("playcount"); - if (!count) count = pEntry->FirstChild("match"); - - if (name) - { - if (artist) - AddListEntry(name->FirstChild()->Value(), - artist->FirstChild()->Value(), - (count) ? count->FirstChild()->Value() : ((date) ? date->FirstChild()->Value() : NULL), - (date) ? date->Attribute("uts") : NULL, - NULL, "lastfm://xbmc/artist/" + (CStdString)artist->FirstChild()->Value() + "/", items); - else - // no artist in xml, assuming we're retrieving track list for the artist in m_objname... - AddListEntry(name->FirstChild()->Value(), - m_objname.c_str(), - (count) ? count->FirstChild()->Value() : NULL, - NULL, NULL, "lastfm://xbmc/artist/" + m_objname + "/", items); - } - else - { - // no luck, try another way :) - const char *name = pEntry->Attribute("name"); - const char *artist = pEntry->FirstChildElement("artist")->Attribute("name"); - const char *count = pEntry->Attribute("count"); - - if (name) - AddListEntry(name, artist, count, NULL, NULL, - "lastfm://xbmc/artist/" + (CStdString)artist + "/", items); - } - - pEntry = pEntry->NextSiblingElement("track"); - } - - m_xmlDoc.Clear(); - return true; -} - -bool CLastFMDirectory::SearchSimilarArtists(CFileItemList &items) -{ - CStdString strSearchTerm = ""; - - if (!GetKeyboardInput(15281, strSearchTerm)) - return false; - - m_objname = m_encodedobjname = strSearchTerm; - CURL::Encode(m_encodedobjname); - CURL::Decode(m_objname); - - AddEntry(15267, "lastfm://artist/%name%/similarartists", "", false, items); - return ParseArtistList(BuildURLFromInfo(), items); -} - -bool CLastFMDirectory::SearchSimilarTags(CFileItemList &items) -{ - CStdString strSearchTerm = ""; - - if (!GetKeyboardInput(15282, strSearchTerm)) - return false; - - m_objname = m_encodedobjname = strSearchTerm; - CURL::Encode(m_encodedobjname); - CURL::Decode(m_objname); - - return ParseTagList(BuildURLFromInfo(), items); -} - -bool CLastFMDirectory::GetArtistInfo(CFileItemList &items) -{ - if (m_objname == "*" && m_objrequest == "similar") - return SearchSimilarArtists(items); - - if (m_objrequest == "similar") - return ParseArtistList(BuildURLFromInfo(), items); - else if (m_objrequest == "topalbums") - return ParseAlbumList(BuildURLFromInfo(), items); - else if (m_objrequest == "toptracks") - return ParseTrackList(BuildURLFromInfo(), items); - else if (m_objrequest == "toptags") - return ParseTagList(BuildURLFromInfo(), items); - else if (m_objrequest == "fans") - return ParseUserList(BuildURLFromInfo(), items); - else if (m_objrequest == "") - { - AddEntry(15261, "lastfm://xbmc/artist/%name%/similar/", "", true, items); - AddEntry(15262, "lastfm://xbmc/artist/%name%/topalbums/", "", true, items); - AddEntry(15263, "lastfm://xbmc/artist/%name%/toptracks/", "", true, items); - AddEntry(15264, "lastfm://xbmc/artist/%name%/toptags/", "", true, items); - AddEntry(15265, "lastfm://xbmc/artist/%name%/fans/", "", true, items); - } - else - return false; - - return true; -} - -bool CLastFMDirectory::GetUserInfo(CFileItemList &items) -{ - if (m_objrequest == "topartists") - return ParseArtistList(BuildURLFromInfo(), items); - else if (m_objrequest == "topalbums") - return ParseAlbumList(BuildURLFromInfo(), items); - else if (m_objrequest == "toptracks") - return ParseTrackList(BuildURLFromInfo(), items); - else if (m_objrequest == "toptags") - return ParseTagList(BuildURLFromInfo(), items); - else if (m_objrequest == "tags") - return ParseTagList(BuildURLFromInfo(), items); - else if (m_objrequest == "friends") - return ParseUserList(BuildURLFromInfo(), items); - else if (m_objrequest == "neighbours") - return ParseUserList(BuildURLFromInfo(), items); - else if (m_objrequest == "weeklyartistchart") - return ParseArtistList(BuildURLFromInfo(), items); - else if (m_objrequest == "weeklyalbumchart") - return ParseAlbumList(BuildURLFromInfo(), items); - else if (m_objrequest == "weeklytrackchart") - return ParseTrackList(BuildURLFromInfo(), items); - else if (m_objrequest == "recenttracks") - return ParseTrackList(BuildURLFromInfo(), items); - else if (m_objrequest == "recentlovedtracks") - return ParseTrackList(BuildURLFromInfo(), items); - else if (m_objrequest == "recentbannedtracks") - return ParseTrackList(BuildURLFromInfo(), items); - else if (m_objrequest == "") - { - AddEntry(15268, "lastfm://xbmc/user/%name%/topartists/", "", true, items); - AddEntry(15269, "lastfm://xbmc/user/%name%/topalbums/", "", true, items); - AddEntry(15270, "lastfm://xbmc/user/%name%/toptracks/", "", true, items); - AddEntry(15285, "lastfm://xbmc/user/%name%/tags/", "", true, items); - AddEntry(15271, "lastfm://xbmc/user/%name%/friends/", "", true, items); - AddEntry(15272, "lastfm://xbmc/user/%name%/neighbours/", "", true, items); - AddEntry(15273, "lastfm://xbmc/user/%name%/weeklyartistchart/", "", true, items); - AddEntry(15274, "lastfm://xbmc/user/%name%/weeklyalbumchart/", "", true, items); - AddEntry(15275, "lastfm://xbmc/user/%name%/weeklytrackchart/", "", true, items); - AddEntry(15283, "lastfm://xbmc/user/%name%/recenttracks/", "", true, items); - AddEntry(15293, "lastfm://xbmc/user/%name%/recentlovedtracks/", "", true, items); - AddEntry(15294, "lastfm://xbmc/user/%name%/recentbannedtracks/", "", true, items); - } - else - return false; - - return true; -} - -bool CLastFMDirectory::GetTagInfo(CFileItemList &items) -{ - if (m_objname == "*" && m_objrequest== "search") - return SearchSimilarTags(items); - - if (m_objrequest == "topartists") - return ParseArtistList(BuildURLFromInfo(), items); - else if (m_objrequest == "topalbums") - return ParseAlbumList(BuildURLFromInfo(), items); - else if (m_objrequest == "toptracks") - return ParseTrackList(BuildURLFromInfo(), items); - else if (m_objrequest == "toptags") - return ParseTagList(BuildURLFromInfo(), items); - else if (m_objrequest == "") - { - AddEntry(15257, "lastfm://xbmc/tag/%name%/topartists/", "", true, items); - AddEntry(15258, "lastfm://xbmc/tag/%name%/topalbums/", "", true, items); - AddEntry(15259, "lastfm://xbmc/tag/%name%/toptracks/", "", true, items); - } - - return true; -} - -bool CLastFMDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items) -{ - CStdString strURL = strPath; - CURL url(strURL); - strURL=url.GetFileName(); - - // parse the URL, finding object type, name, and requested info - CStdStringArray vecURLParts; - - m_objtype = ""; - m_objname = ""; - m_objrequest = ""; - - switch(StringUtils::SplitString(strURL, "/", vecURLParts)) - { - case 1: - // simple lastfm:// root URL... - g_directoryCache.ClearSubPaths("lastfm://"); - break; - // the following fallthru's are on purpose - case 5: - m_objrequest = vecURLParts[3]; - case 4: - m_objname = vecURLParts[2]; - m_encodedobjname = vecURLParts[2]; - CURL::Encode(m_encodedobjname); - CURL::Decode(m_objname); - case 3: - m_objtype = vecURLParts[1]; - case 2: - if (vecURLParts[0] != "xbmc") - return false; - break; - default: - return false; - } - - if (m_objtype == "user") - m_Error = GetUserInfo(items); - else if (m_objtype == "tag") - m_Error = GetTagInfo(items); - else if (m_objtype == "artist") - m_Error = GetArtistInfo(items); - else if (m_objtype == "") - { - AddEntry(15253, "lastfm://xbmc/artist/*/similar/", "", true, items); - AddEntry(15254, "lastfm://xbmc/tag/*/search/", "", true, items); - AddEntry(15256, "lastfm://xbmc/tag/xbmc/toptags/", "", true, items); - if (g_guiSettings.GetString("scrobbler.lastfmusername") != "") - { - m_encodedobjname = m_objname = g_guiSettings.GetString("scrobbler.lastfmusername"); - CURL::Decode(m_encodedobjname); - AddEntry(15255, "lastfm://xbmc/user/%name%/", "", true, items); - } - return true; - } - else - return false; - - return m_Error; -} - -DIR_CACHE_TYPE CLastFMDirectory::GetCacheType(const CStdString& strPath) const -{ - if (strPath == "lastfm://") - return DIR_CACHE_ONCE; - return DIR_CACHE_ALWAYS; -} - -void CLastFMDirectory::Run() -{ - XFILE::CCurlFile http; - if (!http.Download(m_strSource, m_strDestination)) - m_Error=true; - - m_Downloaded=true; -} diff --git a/xbmc/filesystem/LastFMDirectory.h b/xbmc/filesystem/LastFMDirectory.h deleted file mode 100644 index 27d1342590..0000000000 --- a/xbmc/filesystem/LastFMDirectory.h +++ /dev/null @@ -1,76 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2013 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include "IDirectory.h" -#include "CurlFile.h" -#include "utils/XBMCTinyXML.h" -#include "threads/Thread.h" - -class CGUIDialogProgress; - -namespace XFILE -{ -class CLastFMDirectory : - public IDirectory, public IRunnable -{ -public: - CLastFMDirectory(void); - virtual ~CLastFMDirectory(void); - virtual bool GetDirectory(const CStdString& strPath, CFileItemList &items); - virtual void Run(); - - virtual bool IsAllowed(const CStdString &strFile) const { return true; }; - virtual DIR_CACHE_TYPE GetCacheType(const CStdString& strPath) const; -protected: - void AddEntry(int iString, CStdString strPath, CStdString strIconPath, bool bFolder, CFileItemList &items); - void AddListEntry(const char *name, const char *artist, const char *count, const char *date, const char *icon, CStdString strPath, CFileItemList &items); - CStdString BuildURLFromInfo(); - bool RetrieveList(CStdString url); - bool ParseArtistList(CStdString url, CFileItemList &items); - bool ParseAlbumList(CStdString url, CFileItemList &items); - bool ParseUserList(CStdString url, CFileItemList &items); - bool ParseTagList(CStdString url, CFileItemList &items); - bool ParseTrackList(CStdString url, CFileItemList &items); - - bool GetArtistInfo(CFileItemList &items); - bool GetUserInfo(CFileItemList &items); - bool GetTagInfo(CFileItemList &items); - - bool SearchSimilarTags(CFileItemList &items); - bool SearchSimilarArtists(CFileItemList &items); - - bool m_Error; - bool m_Downloaded; - CXBMCTinyXML m_xmlDoc; - - XFILE::CCurlFile m_http; - - CStdString m_objtype; - CStdString m_objname; - CStdString m_encodedobjname; - CStdString m_objrequest; - - CStdString m_strSource; - CStdString m_strDestination; - - CGUIDialogProgress* m_dlgProgress; -}; -} diff --git a/xbmc/filesystem/LastFMFile.cpp b/xbmc/filesystem/LastFMFile.cpp deleted file mode 100644 index d3211f174f..0000000000 --- a/xbmc/filesystem/LastFMFile.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include "LastFMFile.h" - -namespace XFILE -{ - -CLastFMFile::CLastFMFile() : CCurlFile() -{ - SetUserAgent(""); - SetBufferSize(8192); -} - -CLastFMFile::~CLastFMFile() -{ -} - -} - diff --git a/xbmc/filesystem/LastFMFile.h b/xbmc/filesystem/LastFMFile.h deleted file mode 100644 index cb58c3a520..0000000000 --- a/xbmc/filesystem/LastFMFile.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2013 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include "CurlFile.h" -#include "utils/RingBuffer.h" - -namespace XFILE -{ - - class CLastFMFile : public CCurlFile - { - public: - CLastFMFile(); - virtual ~CLastFMFile(); - protected: - }; - -} diff --git a/xbmc/filesystem/Makefile.in b/xbmc/filesystem/Makefile.in index 5b9b8b25ad..f73851a768 100644 --- a/xbmc/filesystem/Makefile.in +++ b/xbmc/filesystem/Makefile.in @@ -38,8 +38,6 @@ SRCS += ImageFile.cpp SRCS += iso9660.cpp SRCS += ISO9660Directory.cpp SRCS += ISOFile.cpp -SRCS += LastFMDirectory.cpp -SRCS += LastFMFile.cpp SRCS += LibraryDirectory.cpp SRCS += MemBufferCache.cpp SRCS += MultiPathDirectory.cpp diff --git a/xbmc/filesystem/SourcesDirectory.cpp b/xbmc/filesystem/SourcesDirectory.cpp index e08363f08c..5d86f9e421 100644 --- a/xbmc/filesystem/SourcesDirectory.cpp +++ b/xbmc/filesystem/SourcesDirectory.cpp @@ -64,7 +64,7 @@ bool CSourcesDirectory::GetDirectory(const VECSOURCES &sources, CFileItemList &i { const CMediaSource& share = sources[i]; CFileItemPtr pItem(new CFileItem(share)); - if (pItem->IsLastFM() || (pItem->GetPath().Left(14).Equals("musicsearch://"))) + if (pItem->GetPath().Left(14).Equals("musicsearch://")) pItem->SetCanQueue(false); CStdString strIcon; @@ -79,8 +79,7 @@ bool CSourcesDirectory::GetDirectory(const VECSOURCES &sources, CFileItemList &i } else if (pItem->GetPath().Left(9) == "addons://") strIcon = "DefaultHardDisk.png"; - else if (pItem->IsLastFM() - || pItem->IsVideoDb() + else if ( pItem->IsVideoDb() || pItem->IsMusicDb() || pItem->IsPlugin() || pItem->GetPath() == "special://musicplaylists/" diff --git a/xbmc/interfaces/Builtins.cpp b/xbmc/interfaces/Builtins.cpp index 8e9b04f279..27e942a6f7 100644 --- a/xbmc/interfaces/Builtins.cpp +++ b/xbmc/interfaces/Builtins.cpp @@ -43,7 +43,6 @@ #include "addons/AddonInstaller.h" #include "addons/AddonManager.h" #include "addons/PluginSource.h" -#include "music/LastFmManager.h" #include "utils/log.h" #include "storage/MediaManager.h" #include "utils/RssReader.h" @@ -172,8 +171,6 @@ const BUILT_IN commands[] = { { "ExportLibrary", true, "Export the video/music library" }, { "PageDown", true, "Send a page down event to the pagecontrol with given id" }, { "PageUp", true, "Send a page up event to the pagecontrol with given id" }, - { "LastFM.Love", false, "Add the current playing last.fm radio track to the last.fm loved tracks" }, - { "LastFM.Ban", false, "Ban the current playing last.fm radio track" }, { "Container.Refresh", false, "Refresh current listing" }, { "Container.Update", false, "Update current listing. Send Container.Update(path,replace) to reset the path history" }, { "Container.NextViewMode", false, "Move to the next view type (and refresh the listing)" }, @@ -1400,14 +1397,6 @@ int CBuiltins::Execute(const CStdString& execString) } } } - else if (execute.Equals("lastfm.love")) - { - CLastFmManager::GetInstance()->Love(parameter.Equals("false") ? false : true); - } - else if (execute.Equals("lastfm.ban")) - { - CLastFmManager::GetInstance()->Ban(parameter.Equals("false") ? false : true); - } else if (execute.Equals("control.move") && params.size() > 1) { CGUIMessage message(GUI_MSG_MOVE_OFFSET, g_windowManager.GetFocusedWindow(), atoi(params[0].c_str()), atoi(params[1].c_str())); diff --git a/xbmc/music/GUIViewStateMusic.cpp b/xbmc/music/GUIViewStateMusic.cpp index d9d8bd4ab8..4c0f1b639c 100644 --- a/xbmc/music/GUIViewStateMusic.cpp +++ b/xbmc/music/GUIViewStateMusic.cpp @@ -552,8 +552,6 @@ void CGUIViewStateWindowMusicNav::AddOnlineShares() for (int i = 0; i < (int)g_settings.m_musicSources.size(); ++i) { CMediaSource share = g_settings.m_musicSources.at(i); - if (share.strPath.Find("lastfm://") == 0)//lastfm share - m_sources.push_back(share); } } @@ -707,30 +705,3 @@ VECSOURCES& CGUIViewStateWindowMusicPlaylist::GetSources() // CGUIViewState::GetSources would add music plugins return m_sources; } - -CGUIViewStateMusicLastFM::CGUIViewStateMusicLastFM(const CFileItemList& items) : CGUIViewStateWindowMusic(items) -{ - CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat"); - CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright"); - - AddSortMethod(SORT_METHOD_UNSORTED, 571, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", "")); // Userdefined, Userdefined | FolderName, empty - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", "")); // Userdefined, Userdefined | FolderName, empty - AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS(strTrackLeft, "%I", "%L", "%I")); // Userdefined, Size | FolderName, Size - - SetSortMethod(g_settings.m_viewStateMusicLastFM.m_sortMethod); - SetSortOrder(g_settings.m_viewStateMusicLastFM.m_sortOrder); - - SetViewAsControl(DEFAULT_VIEW_LIST); - LoadViewState(items.GetPath(), WINDOW_MUSIC_FILES); -} - -bool CGUIViewStateMusicLastFM::AutoPlayNextItem() -{ - return false; -} - -void CGUIViewStateMusicLastFM::SaveViewState() -{ - SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_FILES, &g_settings.m_viewStateMusicLastFM); -} - diff --git a/xbmc/music/GUIViewStateMusic.h b/xbmc/music/GUIViewStateMusic.h index 02cf96d0a2..1d03506997 100644 --- a/xbmc/music/GUIViewStateMusic.h +++ b/xbmc/music/GUIViewStateMusic.h @@ -105,13 +105,3 @@ protected: virtual bool HideParentDirItems(); virtual VECSOURCES& GetSources(); }; - -class CGUIViewStateMusicLastFM : public CGUIViewStateWindowMusic -{ -public: - CGUIViewStateMusicLastFM(const CFileItemList& items); - -protected: - virtual bool AutoPlayNextItem(); - virtual void SaveViewState(); -}; diff --git a/xbmc/music/LastFmManager.cpp b/xbmc/music/LastFmManager.cpp deleted file mode 100644 index 597944f9ac..0000000000 --- a/xbmc/music/LastFmManager.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include "threads/SystemClock.h" -#include "LastFmManager.h" -#include "Album.h" -#include "Artist.h" -#include "Application.h" -#include "ApplicationMessenger.h" -#include "PlayListPlayer.h" -#include "playlists/PlayListFactory.h" -#include "utils/md5.h" -#include "filesystem/File.h" -#include "filesystem/CurlFile.h" -#include "GUIInfoManager.h" -#include "MusicDatabase.h" -#include "music/tags/MusicInfoTag.h" -#include "URL.h" -#include "guilib/GUIWindowManager.h" -#include "dialogs/GUIDialogKaiToast.h" -#include "dialogs/GUIDialogProgress.h" -#include "dialogs/GUIDialogYesNo.h" -#include "dialogs/GUIDialogOK.h" -#include "settings/GUISettings.h" -#include "GUIUserMessages.h" -#include "playlists/PlayList.h" -#include "utils/Crc32.h" -#include "settings/AdvancedSettings.h" -#include "settings/Settings.h" -#include "utils/StringUtils.h" -#include "guilib/LocalizeStrings.h" -#include "utils/XBMCTinyXML.h" -#include "utils/TimeUtils.h" -#include "threads/SingleLock.h" -#include "utils/log.h" -#include "utils/URIUtils.h" - -#include <sstream> - -using namespace std; -using namespace MUSIC_INFO; -using namespace PLAYLIST; -using namespace XFILE; - - -CLastFmManager* CLastFmManager::m_pInstance=NULL; - -CLastFmManager::CLastFmManager() : CThread("CLastFmManager") -{ -} - -CLastFmManager::~CLastFmManager() -{ - StopThread(); - CLog::Log(LOGINFO,"lastfm destroyed"); -} - -void CLastFmManager::RemoveInstance() -{ - if (m_pInstance) - { - delete m_pInstance; - m_pInstance=NULL; - } -} - -CLastFmManager* CLastFmManager::GetInstance() -{ - if (!m_pInstance) - m_pInstance=new CLastFmManager; - - return m_pInstance; -} - -void CLastFmManager::Parameter(const CStdString& key, const CStdString& data, CStdString& value) -{ -} - -bool CLastFmManager::RadioHandShake() -{ - return false; -} - -void CLastFmManager::InitProgressDialog(const CStdString& strUrl) -{ -} - -void CLastFmManager::UpdateProgressDialog(const int iStringID) -{ -} - -void CLastFmManager::CloseProgressDialog() -{ -} - -bool CLastFmManager::ChangeStation(const CURL& stationUrl) -{ - return false; -} - -bool CLastFmManager::RequestRadioTracks() -{ - return false; -} - -void CLastFmManager::CacheTrackThumb(const int nrInitialTracksToAdd) -{ -} - -void CLastFmManager::AddToPlaylist(const int nrTracks) -{ -} - - -void CLastFmManager::OnSongChange(CFileItem& newSong) -{ -} - -void CLastFmManager::Update() -{ -} - -bool CLastFmManager::ReapSongs() -{ - return false; -} - -bool CLastFmManager::MovePlaying() -{ - return false; -} - -void CLastFmManager::SendUpdateMessage() -{ -} - -void CLastFmManager::OnStartup() -{ -} - -void CLastFmManager::Process() -{ -} - -void CLastFmManager::StopRadio(bool bKillSession /*= true*/) -{ -} - -void CLastFmManager::CreateMD5Hash(const CStdString& bufferToHash, CStdString& hash) -{ -} - -bool CLastFmManager::CallXmlRpc(const CStdString& action, const CStdString& artist, const CStdString& title) -{ - return false; -} - -bool CLastFmManager::Love(bool askConfirmation) -{ - return false; -} - -bool CLastFmManager::Ban(bool askConfirmation) -{ - return false; -} - -bool CLastFmManager::Love(const CMusicInfoTag& musicinfotag) -{ - return false; -} - -bool CLastFmManager::Ban(const CMusicInfoTag& musicinfotag) -{ - return false; -} - -bool CLastFmManager::Unlove(const CMusicInfoTag& musicinfotag, bool askConfirmation /*= true*/) -{ - return false; -} - -bool CLastFmManager::Unban(const CMusicInfoTag& musicinfotag, bool askConfirmation /*= true*/) -{ - return false; -} - -bool CLastFmManager::IsLastFmEnabled() -{ - return ( - !g_guiSettings.GetString("scrobbler.lastfmusername").IsEmpty() && - !g_guiSettings.GetString("scrobbler.lastfmpass").IsEmpty() - ); -} - -bool CLastFmManager::CanLove() -{ - return false; -} - -bool CLastFmManager::CanBan() -{ - return false; -} - -bool CLastFmManager::CanScrobble(const CFileItem &fileitem) -{ - return ( - (!fileitem.IsInternetStream() && g_guiSettings.GetBool("scrobbler.lastfmsubmit")) - ); -} diff --git a/xbmc/music/LastFmManager.h b/xbmc/music/LastFmManager.h deleted file mode 100644 index f6117252ad..0000000000 --- a/xbmc/music/LastFmManager.h +++ /dev/null @@ -1,110 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2013 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include "threads/CriticalSection.h" -#include "threads/Thread.h" -#include "threads/Event.h" -#include "PlayListPlayer.h" - -namespace PLAYLIST -{ - class CPlayList; - enum REPEAT_STATE; -} - -namespace MUSIC_INFO -{ - class CMusicInfoTag; -} - -class CURL; -class CGUIDialogProgress; - -class CLastFmManager : CThread -{ -public: - virtual ~CLastFmManager(); - static void RemoveInstance(); - static CLastFmManager* GetInstance(); - - //radio - bool ChangeStation(const CURL& stationUrl); - void StopRadio(bool bKillSession = true); - void OnSongChange(CFileItem& newSong); - bool IsRadioEnabled() {return !m_RadioSession.IsEmpty();} - bool IsLastFmEnabled(); - bool Love(bool askConfirmation = true); - bool Ban(bool askConfirmation = true); - bool CanLove(); - bool CanBan(); - bool Unlove(const MUSIC_INFO::CMusicInfoTag& musicinfotag, bool askConfirmation = true); - bool Unban(const MUSIC_INFO::CMusicInfoTag& musicinfotag, bool askConfirmation = true); - - //scrobbler - bool CanScrobble(const CFileItem &fileitem); -protected: - virtual void Process(); - virtual void OnStartup(); - -private: - typedef struct - { - CFileItem* CurrentSong; - bool IsLoved; - bool IsBanned; - } LastFmManagerSong; - - CLastFmManager(); - static CLastFmManager* m_pInstance; - - bool RadioHandShake(); - bool RequestRadioTracks(); - void CacheTrackThumb(const int nrInitialTracksToAdd); - void Parameter(const CStdString& key, const CStdString& data, CStdString& value); - bool ReapSongs(); - bool MovePlaying(); - void SendUpdateMessage(); - void Update(); - void AddToPlaylist(const int nrTracks); - bool CallXmlRpc(const CStdString& action, const CStdString& artist, const CStdString& title); - void CreateMD5Hash(const CStdString& bufferToHash, CStdString& hash); - bool Love(const MUSIC_INFO::CMusicInfoTag& musicinfotag); - bool Ban(const MUSIC_INFO::CMusicInfoTag& musicinfotag); - - CStdString m_RadioUrl; - CStdString m_RadioSession; - CStdString m_RadioBaseUrl; - CStdString m_RadioBasePath; - CStdString m_RadioSubscriber; - CStdString m_RadioBanned; - - LastFmManagerSong m_CurrentSong; - - PLAYLIST::CPlayList* m_RadioTrackQueue; - CEvent m_hWorkerEvent; - CCriticalSection m_lockCache; - CCriticalSection m_lockPlaylist; - - CGUIDialogProgress* dlgProgress; - void InitProgressDialog(const CStdString& strUrl); - void UpdateProgressDialog(const int iStringID); - void CloseProgressDialog(); -}; diff --git a/xbmc/music/Makefile b/xbmc/music/Makefile index 045a2675ca..cd9d3fdaad 100644 --- a/xbmc/music/Makefile +++ b/xbmc/music/Makefile @@ -1,7 +1,6 @@ SRCS=Album.cpp \ Artist.cpp \ GUIViewStateMusic.cpp \ - LastFmManager.cpp \ MusicDatabase.cpp \ MusicDbUrl.cpp \ MusicInfoLoader.cpp \ diff --git a/xbmc/music/dialogs/GUIDialogMusicInfo.cpp b/xbmc/music/dialogs/GUIDialogMusicInfo.cpp index aa1f9d9e3c..bba7f9814c 100644 --- a/xbmc/music/dialogs/GUIDialogMusicInfo.cpp +++ b/xbmc/music/dialogs/GUIDialogMusicInfo.cpp @@ -24,7 +24,6 @@ #include "dialogs/GUIDialogFileBrowser.h" #include "GUIPassword.h" #include "music/MusicDatabase.h" -#include "music/LastFmManager.h" #include "music/tags/MusicInfoTag.h" #include "URL.h" #include "filesystem/File.h" @@ -51,7 +50,6 @@ using namespace XFILE; #define CONTROL_BTN_TRACKS 5 #define CONTROL_BTN_REFRESH 6 #define CONTROL_BTN_GET_THUMB 10 -#define CONTROL_BTN_LASTFM 11 #define CONTROL_BTN_GET_FANART 12 #define CONTROL_LIST 50 @@ -126,15 +124,6 @@ bool CGUIDialogMusicInfo::OnMessage(CGUIMessage& message) return true; } } - else if (iControl == CONTROL_BTN_LASTFM) - { - CStdString strArtist = StringUtils::Join(m_album.artist, g_advancedSettings.m_musicItemSeparator); - CURL::Encode(strArtist); - CStdString strLink; - strLink.Format("lastfm://artist/%s/similarartists", strArtist.c_str()); - CURL url(strLink); - CLastFmManager::GetInstance()->ChangeStation(url); - } else if (iControl == CONTROL_BTN_GET_FANART) { OnGetFanart(); @@ -307,16 +296,6 @@ void CGUIDialogMusicInfo::Update() // disable the GetThumb button if the user isn't allowed it CONTROL_ENABLE_ON_CONDITION(CONTROL_BTN_GET_THUMB, g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser); - - if (!m_album.artist.empty() && CLastFmManager::GetInstance()->IsLastFmEnabled()) - { - SET_CONTROL_VISIBLE(CONTROL_BTN_LASTFM); - } - else - { - SET_CONTROL_HIDDEN(CONTROL_BTN_LASTFM); - } - } void CGUIDialogMusicInfo::SetLabel(int iControl, const CStdString& strLabel) diff --git a/xbmc/music/windows/GUIWindowMusicBase.cpp b/xbmc/music/windows/GUIWindowMusicBase.cpp index 3992aaf036..5f43def2be 100644 --- a/xbmc/music/windows/GUIWindowMusicBase.cpp +++ b/xbmc/music/windows/GUIWindowMusicBase.cpp @@ -44,7 +44,6 @@ #include "music/dialogs/GUIDialogSongInfo.h" #include "addons/GUIDialogAddonInfo.h" #include "dialogs/GUIDialogSmartPlaylistEditor.h" -#include "music/LastFmManager.h" #include "music/tags/MusicInfoTag.h" #include "guilib/GUIWindowManager.h" #include "dialogs/GUIDialogOK.h" @@ -890,15 +889,7 @@ void CGUIWindowMusicBase::GetContextButtons(int itemNumber, CContextButtons &but { if (!m_vecItems->IsPlugin() && (item->IsPlugin() || item->IsScript())) buttons.Add(CONTEXT_BUTTON_INFO,24003); // Add-on info - if (item->GetExtraInfo().Equals("lastfmloved")) - { - buttons.Add(CONTEXT_BUTTON_LASTFM_UNLOVE_ITEM, 15295); //unlove - } - else if (item->GetExtraInfo().Equals("lastfmbanned")) - { - buttons.Add(CONTEXT_BUTTON_LASTFM_UNBAN_ITEM, 15296); //unban - } - else if (item->CanQueue() && !item->IsAddonsPath() && !item->IsScript()) + if (item->CanQueue() && !item->IsAddonsPath() && !item->IsScript()) { buttons.Add(CONTEXT_BUTTON_QUEUE_ITEM, 13347); //queue @@ -1013,20 +1004,6 @@ bool CGUIWindowMusicBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) case CONTEXT_BUTTON_SETTINGS: g_windowManager.ActivateWindow(WINDOW_SETTINGS_MYMUSIC); return true; - case CONTEXT_BUTTON_LASTFM_UNBAN_ITEM: - if (CLastFmManager::GetInstance()->Unban(*item->GetMusicInfoTag())) - { - g_directoryCache.ClearDirectory(m_vecItems->GetPath()); - Refresh(true); - } - return true; - case CONTEXT_BUTTON_LASTFM_UNLOVE_ITEM: - if (CLastFmManager::GetInstance()->Unlove(*item->GetMusicInfoTag())) - { - g_directoryCache.ClearDirectory(m_vecItems->GetPath()); - Refresh(true); - } - return true; default: break; } @@ -1173,7 +1150,7 @@ bool CGUIWindowMusicBase::OnPlayMedia(int iItem) CFileItemPtr pItem = m_vecItems->Get(iItem); // party mode - if (g_partyModeManager.IsEnabled() && !pItem->IsLastFM()) + if (g_partyModeManager.IsEnabled()) { CPlayList playlistTemp; playlistTemp.Add(pItem); diff --git a/xbmc/music/windows/GUIWindowMusicNav.cpp b/xbmc/music/windows/GUIWindowMusicNav.cpp index 1f0fefa0b4..fd218f5be0 100644 --- a/xbmc/music/windows/GUIWindowMusicNav.cpp +++ b/xbmc/music/windows/GUIWindowMusicNav.cpp @@ -418,7 +418,7 @@ void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &butt CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); - if (item && (item->GetExtraInfo().Find("lastfm") < 0) && !item->GetPath().Left(14).Equals("addons://more/")) + if (item && !item->GetPath().Left(14).Equals("addons://more/")) { // are we in the playlists location? bool inPlaylists = m_vecItems->GetPath().Equals(CUtil::MusicPlaylistsLocation()) || @@ -427,7 +427,7 @@ void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &butt CMusicDatabaseDirectory dir; // enable music info button on an album or on a song. if (item->IsAudio() && !item->IsPlayList() && !item->IsSmartPlayList() && - !item->IsLastFM() && !item->m_bIsFolder) + !item->m_bIsFolder) { buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); } @@ -446,7 +446,7 @@ void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &butt else if (!inPlaylists && (dir.HasAlbumInfo(item->GetPath())|| dir.IsArtistDir(item->GetPath()) ) && !dir.IsAllItem(item->GetPath()) && !item->IsParentFolder() && - !item->IsLastFM() && !item->IsPlugin() && !item->IsScript() && + !item->IsPlugin() && !item->IsScript() && !item->GetPath().Left(14).Equals("musicsearch://")) { if (dir.IsArtistDir(item->GetPath())) @@ -458,7 +458,6 @@ void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &butt // enable query all albums button only in album view if (dir.HasAlbumInfo(item->GetPath()) && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder && !item->IsVideoDb() && !item->IsParentFolder() && - !item->IsLastFM() && !item->IsPlugin() && !item->GetPath().Left(14).Equals("musicsearch://")) { buttons.Add(CONTEXT_BUTTON_INFO_ALL, 20059); diff --git a/xbmc/music/windows/GUIWindowMusicPlaylist.cpp b/xbmc/music/windows/GUIWindowMusicPlaylist.cpp index d5a98e68f9..2c68520e1d 100644 --- a/xbmc/music/windows/GUIWindowMusicPlaylist.cpp +++ b/xbmc/music/windows/GUIWindowMusicPlaylist.cpp @@ -25,7 +25,6 @@ #include "Application.h" #include "PlayListPlayer.h" #include "PartyModeManager.h" -#include "music/LastFmManager.h" #include "utils/LabelFormatter.h" #include "music/tags/MusicInfoTag.h" #include "guilib/GUIWindowManager.h" @@ -365,7 +364,7 @@ void CGUIWindowMusicPlayList::UpdateButtons() CGUIWindowMusicBase::UpdateButtons(); // Update playlist buttons - if (m_vecItems->Size() && !g_partyModeManager.IsEnabled() && !CLastFmManager::GetInstance()->IsRadioEnabled()) + if (m_vecItems->Size() && !g_partyModeManager.IsEnabled()) { CONTROL_ENABLE(CONTROL_BTNSHUFFLE); CONTROL_ENABLE(CONTROL_BTNSAVE); @@ -520,8 +519,7 @@ void CGUIWindowMusicPlayList::GetContextButtons(int itemNumber, CContextButtons if (vecCores.size() > 1) buttons.Add(CONTEXT_BUTTON_PLAY_WITH, 15213); // Play With... - if (!item->IsLastFM()) - buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); // Song Info + buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); // Song Info if (CFavourites::IsFavourite(item.get(), GetID())) buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14077); // Remove Favourite else diff --git a/xbmc/music/windows/GUIWindowMusicSongs.cpp b/xbmc/music/windows/GUIWindowMusicSongs.cpp index 098e53e455..ec0ccdf850 100644 --- a/xbmc/music/windows/GUIWindowMusicSongs.cpp +++ b/xbmc/music/windows/GUIWindowMusicSongs.cpp @@ -254,7 +254,7 @@ void CGUIWindowMusicSongs::UpdateButtons() // Disable scan button if shoutcast if (m_vecItems->IsVirtualDirectoryRoot() || - m_vecItems->IsLastFM() || m_vecItems->IsMusicDb()) + m_vecItems->IsMusicDb()) { CONTROL_DISABLE(CONTROL_BTNSCAN); } @@ -318,9 +318,9 @@ void CGUIWindowMusicSongs::GetContextButtons(int itemNumber, CContextButtons &bu return; if (!item->IsPlayList() && !item->IsPlugin() && !item->IsScript()) { - if (item->IsAudio() && !item->IsLastFM()) + if (item->IsAudio()) buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); // Song Info - else if (!item->IsParentFolder() && !item->IsLastFM() && + else if (!item->IsParentFolder() && !item->GetPath().Left(3).Equals("new") && item->m_bIsFolder) { #if 0 @@ -363,7 +363,6 @@ void CGUIWindowMusicSongs::GetContextButtons(int itemNumber, CContextButtons &bu if (g_application.IsMusicScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning else if (!inPlaylists && !m_vecItems->IsInternetStream() && - !item->IsLastFM() && !item->GetPath().Equals("add") && !item->IsParentFolder() && !item->IsPlugin() && !item->GetPath().Left(9).Equals("addons://") && diff --git a/xbmc/network/Network.cpp b/xbmc/network/Network.cpp index 976056a777..ef193b4ac8 100644 --- a/xbmc/network/Network.cpp +++ b/xbmc/network/Network.cpp @@ -22,8 +22,6 @@ #include "Network.h" #include "Application.h" #include "ApplicationMessenger.h" -#include "libscrobbler/lastfmscrobbler.h" -#include "libscrobbler/librefmscrobbler.h" #include "utils/RssReader.h" #include "utils/log.h" #include "guilib/LocalizeStrings.h" @@ -302,8 +300,6 @@ void CNetwork::StartServices() #ifdef HAS_AIRPLAY g_application.StartAirplayServer(); #endif - CLastfmScrobbler::GetInstance()->Init(); - CLibrefmScrobbler::GetInstance()->Init(); g_rssManager.Start(); } @@ -320,8 +316,6 @@ void CNetwork::StopServices(bool bWait) #ifdef HAS_WEB_SERVER g_application.StopWebServer(); #endif - CLastfmScrobbler::GetInstance()->Term(); - CLibrefmScrobbler::GetInstance()->Term(); // smb.Deinit(); if any file is open over samba this will break. g_rssManager.Stop(); diff --git a/xbmc/network/libscrobbler/Makefile b/xbmc/network/libscrobbler/Makefile deleted file mode 100644 index 6283b2739e..0000000000 --- a/xbmc/network/libscrobbler/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -SRCS=lastfmscrobbler.cpp \ - librefmscrobbler.cpp \ - scrobbler.cpp \ - -LIB=scrobbler.a - -include ../../../Makefile.include --include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS))) diff --git a/xbmc/network/libscrobbler/errors.h b/xbmc/network/libscrobbler/errors.h deleted file mode 100644 index 8c976c236b..0000000000 --- a/xbmc/network/libscrobbler/errors.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - This file is part of libscrobbler. - - libscrobbler is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - libscrobbler is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with libscrobbler; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Copyright © 2003 Russell Garrett (russ-scrobbler@garrett.co.uk) -*/ -#ifndef _SCROBBLER_ERRORS_H -#define _SCROBBLER_ERRORS_H - -class EScrobbler { -public: - EScrobbler(){}; - ~EScrobbler(){}; - - const char *getText() const { return "Unknown Error"; } -}; - -class EOutOfMemory : public EScrobbler { -public: - const char *getText() const { return "Out of Memory"; } -}; - -#endif - diff --git a/xbmc/network/libscrobbler/lastfmscrobbler.cpp b/xbmc/network/libscrobbler/lastfmscrobbler.cpp deleted file mode 100644 index 9cdb124e35..0000000000 --- a/xbmc/network/libscrobbler/lastfmscrobbler.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include "lastfmscrobbler.h" -#include "threads/Atomics.h" -#include "settings/GUISettings.h" -#include "settings/Settings.h" -#include "utils/URIUtils.h" -#include "guilib/LocalizeStrings.h" -#include "dialogs/GUIDialogKaiToast.h" - -long CLastfmScrobbler::m_instanceLock = 0; -CLastfmScrobbler *CLastfmScrobbler::m_pInstance = NULL; - -CLastfmScrobbler::CLastfmScrobbler() - : CScrobbler(LASTFM_SCROBBLER_HANDSHAKE_URL, LASTFM_SCROBBLER_LOG_PREFIX) -{ -} - -CLastfmScrobbler::~CLastfmScrobbler() -{ - Term(); -} - -CLastfmScrobbler *CLastfmScrobbler::GetInstance() -{ - if (!m_pInstance) // Avoid spinning aimlessly - { - CAtomicSpinLock lock(m_instanceLock); - if (!m_pInstance) - { - m_pInstance = new CLastfmScrobbler; - } - } - return m_pInstance; -} - -void CLastfmScrobbler::RemoveInstance() -{ - if (m_pInstance) - { - CAtomicSpinLock lock(m_instanceLock); - delete m_pInstance; - m_pInstance = NULL; - } -} - -void CLastfmScrobbler::LoadCredentials() -{ - SetUsername(g_guiSettings.GetString("scrobbler.lastfmusername")); - SetPassword(g_guiSettings.GetString("scrobbler.lastfmpass")); -} - -CStdString CLastfmScrobbler::GetJournalFileName() -{ - CStdString strFileName = g_settings.GetProfileUserDataFolder(); - return URIUtils::AddFileToFolder(strFileName, "LastfmScrobbler.xml"); -} - -void CLastfmScrobbler::NotifyUser(int error) -{ - CStdString strText; - CStdString strAudioScrobbler; - switch (error) - { - case SCROBBLER_USER_ERROR_BADAUTH: - strText = g_localizeStrings.Get(15206); - m_bBadAuth = true; - strAudioScrobbler = g_localizeStrings.Get(15200); // AudioScrobbler - CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, strAudioScrobbler, strText, 10000); - break; - case SCROBBLER_USER_ERROR_BANNED: - strText = g_localizeStrings.Get(15205); - m_bBanned = true; - strAudioScrobbler = g_localizeStrings.Get(15200); // AudioScrobbler - CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, strAudioScrobbler, strText, 10000); - break; - default: - break; - } -} - -bool CLastfmScrobbler::CanScrobble() -{ - return (!g_guiSettings.GetString("scrobbler.lastfmusername").IsEmpty() && - !g_guiSettings.GetString("scrobbler.lastfmpass").IsEmpty() && - g_guiSettings.GetBool("scrobbler.lastfmsubmit")); -} - diff --git a/xbmc/network/libscrobbler/lastfmscrobbler.h b/xbmc/network/libscrobbler/lastfmscrobbler.h deleted file mode 100644 index 9c52a90209..0000000000 --- a/xbmc/network/libscrobbler/lastfmscrobbler.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#ifndef LASTFM_SCROBBLER_H__ -#define LASTFM_SCROBBLER_H__ - -#include "scrobbler.h" - -#define LASTFM_SCROBBLER_HANDSHAKE_URL "post.audioscrobbler.com" -#define LASTFM_SCROBBLER_LOG_PREFIX "CLastfmScrobbler" - -class CLastfmScrobbler : public CScrobbler -{ -private: - static long m_instanceLock; - static CLastfmScrobbler *m_pInstance; - virtual void LoadCredentials(); - virtual void NotifyUser(int error); - virtual bool CanScrobble(); - virtual CStdString GetJournalFileName(); -public: -// CLastfmScrobbler() : CScrobbler(LASTFM_SCROBBLER_HANDSHAKE_URL, LASTFM_SCROBBLER_LOG_PREFIX) {} -// virtual ~CLastfmScrobbler() {} - CLastfmScrobbler(); - virtual ~CLastfmScrobbler(); - static CLastfmScrobbler *GetInstance(); - static void RemoveInstance(); -}; - -#endif // LASTFM_SCROBBLER_H__ diff --git a/xbmc/network/libscrobbler/librefmscrobbler.cpp b/xbmc/network/libscrobbler/librefmscrobbler.cpp deleted file mode 100644 index 1f4ecd4303..0000000000 --- a/xbmc/network/libscrobbler/librefmscrobbler.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include "librefmscrobbler.h" -#include "threads/Atomics.h" -#include "settings/GUISettings.h" -#include "settings/Settings.h" -#include "utils/URIUtils.h" -#include "guilib/LocalizeStrings.h" -#include "dialogs/GUIDialogKaiToast.h" - -long CLibrefmScrobbler::m_instanceLock = 0; -CLibrefmScrobbler *CLibrefmScrobbler::m_pInstance = NULL; - -CLibrefmScrobbler::CLibrefmScrobbler() - : CScrobbler(LIBREFM_SCROBBLER_HANDSHAKE_URL, LIBREFM_SCROBBLER_LOG_PREFIX) -{ -} - -CLibrefmScrobbler::~CLibrefmScrobbler() -{ - Term(); -} - -CLibrefmScrobbler *CLibrefmScrobbler::GetInstance() -{ - if (!m_pInstance) // Avoid spinning aimlessly - { - CAtomicSpinLock lock(m_instanceLock); - if (!m_pInstance) - { - m_pInstance = new CLibrefmScrobbler; - } - } - return m_pInstance; -} - -void CLibrefmScrobbler::RemoveInstance() -{ - if (m_pInstance) - { - CAtomicSpinLock lock(m_instanceLock); - delete m_pInstance; - m_pInstance = NULL; - } -} - -void CLibrefmScrobbler::LoadCredentials() -{ - SetUsername(g_guiSettings.GetString("scrobbler.librefmusername")); - SetPassword(g_guiSettings.GetString("scrobbler.librefmpass")); -} - -CStdString CLibrefmScrobbler::GetJournalFileName() -{ - CStdString strFileName = g_settings.GetProfileUserDataFolder(); - return URIUtils::AddFileToFolder(strFileName, "LibrefmScrobbler.xml"); -} - -void CLibrefmScrobbler::NotifyUser(int error) -{ - CStdString strText; - CStdString strAudioScrobbler; - switch (error) - { - case SCROBBLER_USER_ERROR_BADAUTH: - strText = g_localizeStrings.Get(15206); - m_bBadAuth = true; - strAudioScrobbler = g_localizeStrings.Get(15220); // Libre.fm - CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, strAudioScrobbler, strText, 10000); - break; - case SCROBBLER_USER_ERROR_BANNED: - strText = g_localizeStrings.Get(15205); - m_bBanned = true; - strAudioScrobbler = g_localizeStrings.Get(15220); // Libre.fm - CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, strAudioScrobbler, strText, 10000); - break; - default: - break; - } -} - -bool CLibrefmScrobbler::CanScrobble() -{ - return (!g_guiSettings.GetString("scrobbler.librefmusername").IsEmpty() && - !g_guiSettings.GetString("scrobbler.librefmpass").IsEmpty() && - g_guiSettings.GetBool("scrobbler.librefmsubmit")); -} - diff --git a/xbmc/network/libscrobbler/librefmscrobbler.h b/xbmc/network/libscrobbler/librefmscrobbler.h deleted file mode 100644 index 983dc18458..0000000000 --- a/xbmc/network/libscrobbler/librefmscrobbler.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#ifndef LIBREFM_SCROBBLER_H__ -#define LIBREFM_SCROBBLER_H__ - -#include "scrobbler.h" - -#define LIBREFM_SCROBBLER_HANDSHAKE_URL "turtle.libre.fm" -#define LIBREFM_SCROBBLER_LOG_PREFIX "CLibrefmScrobbler" - -class CLibrefmScrobbler : public CScrobbler -{ -private: - static long m_instanceLock; - static CLibrefmScrobbler *m_pInstance; - virtual void LoadCredentials(); - virtual void NotifyUser(int error); - virtual bool CanScrobble(); - virtual CStdString GetJournalFileName(); -public: - CLibrefmScrobbler(); - virtual ~CLibrefmScrobbler(); - static CLibrefmScrobbler *GetInstance(); - static void RemoveInstance(); -}; - -#endif // LIBREFM_SCROBBLER_H__ diff --git a/xbmc/network/libscrobbler/scrobbler.cpp b/xbmc/network/libscrobbler/scrobbler.cpp deleted file mode 100644 index cf506fa0fc..0000000000 --- a/xbmc/network/libscrobbler/scrobbler.cpp +++ /dev/null @@ -1,690 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#include "PlatformDefs.h" -#include "scrobbler.h" -#include "utils/md5.h" -#include "utils/log.h" -#include "utils/StringUtils.h" -#include "Util.h" -#include "music/tags/MusicInfoTag.h" -#include "errors.h" -#include "threads/Atomics.h" -#include "settings/GUISettings.h" -#include "settings/AdvancedSettings.h" -#include "utils/XMLUtils.h" -#include "Application.h" -#include "threads/SingleLock.h" -#include "guilib/LocalizeStrings.h" -#include "filesystem/File.h" -#include "filesystem/CurlFile.h" -#include "URL.h" - -#define SCROBBLER_CLIENT "xbm" -//#define SCROBBLER_CLIENT "tst" // For testing ONLY! -#define SCROBBLER_PROTOCOL "1.2.1" -#define SCROBBLER_CLIENT_VERSION "0.2" -#define SCROBBLER_JOURNAL_VERSION 1 -#define SCROBBLER_MAX_SUBMISSIONS 50 // API rule -#define SCROBBLER_MIN_DURATION 30 // seconds. API rule -#define SCROBBLER_ACTION_SUBMIT 1 -#define SCROBBLER_ACTION_NOWPLAYING 2 - -CScrobbler::CScrobbler(const CStdString &strHandshakeURL, const CStdString &strLogPrefix) - : CThread("CScrobbler") -{ - m_bBanned = false; - m_bBadAuth = false; - m_pHttp = NULL; - m_strHandshakeURL = strHandshakeURL; - m_strLogPrefix = strLogPrefix; - ResetState(); -} - -CScrobbler::~CScrobbler() -{ -} - -void CScrobbler::Init() -{ - if (!CanScrobble()) - return; - ResetState(); - LoadCredentials(); - LoadJournal(); - if (!IsRunning()) - Create(); -} - -void CScrobbler::Term() -{ - StopThread(); - SaveJournal(); -} - -void CScrobbler::AddSong(const MUSIC_INFO::CMusicInfoTag &tag, bool lastfmradio) -{ - ClearSubmissionState(); - - if (!CanScrobble() || !tag.Loaded()) - return; - - if (tag.GetArtist().empty() || tag.GetTitle().IsEmpty()) - return; - - // our tags are stored as UTF-8, so no conversion needed - m_CurrentTrack.length = tag.GetDuration(); - m_CurrentTrack.strArtist = StringUtils::Join(tag.GetArtist(), g_advancedSettings.m_musicItemSeparator); - m_CurrentTrack.strAlbum = tag.GetAlbum(); - m_CurrentTrack.strTitle = tag.GetTitle(); - m_CurrentTrack.strMusicBrainzID = tag.GetMusicBrainzTrackID(); - if (lastfmradio) // TODO Set source more appropriately - m_CurrentTrack.strSource = "L" + tag.GetComment(); - else - m_CurrentTrack.strSource = "P"; - m_CurrentTrack.strRating = ""; - m_CurrentTrack.strLength.Format("%d", m_CurrentTrack.length); - m_CurrentTrack.strStartTime.Format("%d", time(NULL)); - m_CurrentTrack.strTrackNum.Format("%d",tag.GetTrackNumber()); - - CURL::Encode(m_CurrentTrack.strArtist); - CURL::Encode(m_CurrentTrack.strTitle); - CURL::Encode(m_CurrentTrack.strAlbum); - CURL::Encode(m_CurrentTrack.strMusicBrainzID); - - m_bNotified = false; - m_bSubmitted = !(lastfmradio || - (!lastfmradio && g_guiSettings.GetBool("scrobbler.lastfmsubmit") && (m_CurrentTrack.length > SCROBBLER_MIN_DURATION || !m_CurrentTrack.strMusicBrainzID.IsEmpty()))); -} - -void CScrobbler::UpdateStatus() -{ - // Called from CApp::ProcessSlow() every ~500ms. - if (!CanScrobble()) - return; - if (g_application.IsPaused() || (g_application.GetPlaySpeed() != 1)) - return; - - m_submissionTimer++; - - // Try to notify Last.fm of our currently playing after ~5s of playback. - // Don't try too hard, this is optional and doesn't affect the users library. - if (!m_bNotified && m_submissionTimer >= 10) - { - m_bNotified = true; // Only try once - { - CSingleLock lock(m_actionLock); - m_action = SCROBBLER_ACTION_NOWPLAYING; - } - m_hEvent.Set(); - return; - } - - // Scrobble the track after 50% playback or 240s, whichever occurs first. - // Just toss it in the queue here. We'll try to submit the queue at the - // end of playback. - if (!m_bSubmitted && - (m_submissionTimer > m_CurrentTrack.length || - m_submissionTimer >= 480)) - { - CSingleLock lock(m_queueLock); - m_bSubmitted = true; - m_vecSubmissionQueue.push_back(m_CurrentTrack); - lock.Leave(); - SaveJournal(); - CLog::Log(LOGDEBUG, "%s: Queued track for submission", m_strLogPrefix.c_str()); - } -} - -void CScrobbler::SubmitQueue() -{ - if (CanScrobble()) - { - { - CSingleLock lock(m_actionLock); - m_action = SCROBBLER_ACTION_SUBMIT; - } - m_hEvent.Set(); - } -} - -void CScrobbler::SetUsername(const CStdString& strUser) -{ - if (strUser.IsEmpty()) - return; - - m_strUsername=strUser; - CURL::Encode(m_strUsername); - m_bBadAuth = false; -} - -void CScrobbler::SetPassword(const CStdString& strPass) -{ - if (strPass.IsEmpty()) - return; - m_strPasswordHash = strPass; - m_strPasswordHash.ToLower(); - m_bBadAuth = false; -} - -CStdString CScrobbler::GetConnectionState() -{ - if (!CanScrobble()) - return ""; - return (m_strSessionID.IsEmpty()) ? - g_localizeStrings.Get(15208) : g_localizeStrings.Get(15207); -} - -CStdString CScrobbler::GetSubmitInterval() -{ - CStdString strInterval; - if (!CanScrobble()) - return strInterval; - CStdString strFormat = g_localizeStrings.Get(15209); - int seconds = m_CurrentTrack.length - m_submissionTimer/2; - strInterval.Format(strFormat, std::max(seconds, m_failedHandshakeDelay)); - return strInterval; -} - -CStdString CScrobbler::GetFilesCached() -{ - CStdString strCachedTracks; - if (!CanScrobble()) - return strCachedTracks; - CSingleLock lock(m_queueLock); - CStdString strFormat = g_localizeStrings.Get(15210); - strCachedTracks.Format(strFormat, m_vecSubmissionQueue.size()); - return strCachedTracks; -} - -CStdString CScrobbler::GetSubmitState() -{ - CStdString strState; - CStdString strFormat = g_localizeStrings.Get(15212); - if (!CanScrobble()) - return strState; - if (m_bSubmitting) - strState = g_localizeStrings.Get(15211); - else if (!g_application.IsPlayingAudio() || m_bBadAuth || m_bBanned) - strState.Format(strFormat, 0); - else if (m_strSessionID.IsEmpty()) - strState.Format(strFormat, m_failedHandshakeDelay); - else - { - int seconds = m_CurrentTrack.length - m_submissionTimer/2; - strState.Format(strFormat, std::max(0, seconds)); - } - return strState; -} - -void CScrobbler::ResetState() -{ - ClearSession(); - ClearSubmissionState(); - ClearErrorState(); -} - -void CScrobbler::ClearErrorState() -{ - m_hardErrorCount = 0; - m_lastFailedHandshake = 0; - m_failedHandshakeDelay = 0; -} - -void CScrobbler::ClearSubmissionState() -{ - m_bNotified = true; // Explicitly clear these when necessary - m_bSubmitting = false; - m_bSubmitted = true; - m_submissionTimer = 0; - CSingleLock lock(m_actionLock); - m_action = 0; -} - -void CScrobbler::ClearSession() -{ - CLog::Log(LOGDEBUG, "%s: Clearing session.", m_strLogPrefix.c_str()); - m_strSessionID.clear(); -} - -void CScrobbler::HandleHardError() -{ - CLog::Log(LOGDEBUG, "%s: A hard error has occurred.", m_strLogPrefix.c_str()); - if (++m_hardErrorCount == 3) - { - CLog::Log(LOGDEBUG, "%s: Three consecuetive hard errors have "\ - "occured. Forcing new handshake.", m_strLogPrefix.c_str()); - ClearSession(); - } -} - -bool CScrobbler::LoadJournal() -{ - int journalVersion = 0; - SubmissionJournalEntry entry; - CXBMCTinyXML xmlDoc; - CStdString JournalFileName = GetJournalFileName(); - CSingleLock lock(m_queueLock); - - m_vecSubmissionQueue.clear(); - - if (!xmlDoc.LoadFile(JournalFileName)) - { - CLog::Log(LOGDEBUG, "%s: %s, Line %d (%s)", m_strLogPrefix.c_str(), - JournalFileName.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc()); - return false; - } - - TiXmlElement *pRoot = xmlDoc.RootElement(); - if (strcmpi(pRoot->Value(), "asjournal") != 0) - { - CLog::Log(LOGDEBUG, "%s: %s missing <asjournal>", m_strLogPrefix.c_str(), - JournalFileName.c_str()); - return false; - } - - if (pRoot->Attribute("version")) - journalVersion = atoi(pRoot->Attribute("version")); - - TiXmlNode *pNode = pRoot->FirstChild("entry"); - for (; pNode; pNode = pNode->NextSibling("entry")) - { - entry.Clear(); - XMLUtils::GetString(pNode, "artist", entry.strArtist); - XMLUtils::GetString(pNode, "album", entry.strAlbum); - XMLUtils::GetString(pNode, "title", entry.strTitle); - XMLUtils::GetString(pNode, "length", entry.strLength); - entry.length = atoi(entry.strLength.c_str()); - XMLUtils::GetString(pNode, "starttime", entry.strStartTime); - XMLUtils::GetString(pNode, "musicbrainzid", entry.strMusicBrainzID); - - if (journalVersion > 0) - { - XMLUtils::GetString(pNode, "tracknum", entry.strTrackNum); - XMLUtils::GetString(pNode, "source", entry.strSource); - XMLUtils::GetString(pNode, "rating", entry.strRating); - } - else - { - // Update from journal v0 - // Convert start time stamp - struct tm starttm; - time_t startt; - if (!strptime(entry.strStartTime.c_str(), "%Y-%m-%d %H:%M:%S", &starttm)) - continue; - if ((startt = mktime(&starttm)) == -1) - continue; - entry.strStartTime.Format("%d", startt); - // url encode entries - CURL::Encode(entry.strArtist); - CURL::Encode(entry.strTitle); - CURL::Encode(entry.strAlbum); - CURL::Encode(entry.strMusicBrainzID); - } - m_vecSubmissionQueue.push_back(entry); - } - - CLog::Log(LOGDEBUG, "%s: Journal loaded with %"PRIuS" entries.", m_strLogPrefix.c_str(), - m_vecSubmissionQueue.size()); - return !m_vecSubmissionQueue.empty(); -} - -bool CScrobbler::SaveJournal() -{ - CSingleLock lock(m_queueLock); - - if (m_vecSubmissionQueue.size() == 0) - { - if (XFILE::CFile::Exists(GetJournalFileName())) - XFILE::CFile::Delete(GetJournalFileName()); - return true; - } - CStdString strJournalVersion; - CXBMCTinyXML xmlDoc; - TiXmlDeclaration decl("1.0", "utf-8", "yes"); - TiXmlElement xmlRootElement("asjournal"); - xmlDoc.InsertEndChild(decl); - strJournalVersion.Format("%d", SCROBBLER_JOURNAL_VERSION); - xmlRootElement.SetAttribute("version", strJournalVersion.c_str()); - TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement); - if (!pRoot) - return false; - - int i = 0; - SCROBBLERJOURNALITERATOR it = m_vecSubmissionQueue.begin(); - for (; it != m_vecSubmissionQueue.end(); it++, i++) - { - TiXmlElement entryNode("entry"); - TiXmlNode *pNode = pRoot->InsertEndChild(entryNode); - if (!pNode) - return false; - XMLUtils::SetString(pNode, "artist", it->strArtist); - XMLUtils::SetString(pNode, "album", it->strAlbum); - XMLUtils::SetString(pNode, "title", it->strTitle); - XMLUtils::SetString(pNode, "length", it->strLength); - XMLUtils::SetString(pNode, "starttime", it->strStartTime); - XMLUtils::SetString(pNode, "musicbrainzid", it->strMusicBrainzID); - XMLUtils::SetString(pNode, "tracknum", it->strTrackNum); - XMLUtils::SetString(pNode, "source", it->strSource); - XMLUtils::SetString(pNode, "rating", it->strRating); - } - lock.Leave(); - - CStdString FileName = GetJournalFileName(); - CLog::Log(LOGDEBUG, "%s: Journal with %d entries saved to %s", - m_strLogPrefix.c_str(), i, FileName.c_str()); - return xmlDoc.SaveFile(FileName); -} - -bool CScrobbler::DoHandshake(time_t now) -{ - XBMC::XBMC_MD5 authToken; - CStdString strAuthToken; - CStdString strTimeStamp; - CStdString strResponse; - CStdString strHandshakeRequest; - - // Create auth token. md5(md5(pass)+str(now)) - strTimeStamp.Format("%d", now); - authToken.append(m_strPasswordHash + strTimeStamp); - authToken.getDigest(strAuthToken); - strAuthToken.ToLower(); - - // Construct handshake URL. - strHandshakeRequest.Format("http://%s/?hs=true"\ - "&p=%s&c=%s&v=%s&u=%s&t=%d&a=%s", m_strHandshakeURL.c_str(), - SCROBBLER_PROTOCOL, SCROBBLER_CLIENT, SCROBBLER_CLIENT_VERSION, - m_strUsername.c_str(), now, strAuthToken.c_str()); - - // Make and handle request - if (m_pHttp->Get(strHandshakeRequest, strResponse) && - HandleHandshake(strResponse)) - return true; - - m_failedHandshakeDelay = // 60, 120, 240, ... 7200s - (m_failedHandshakeDelay) ? std::min(2*m_failedHandshakeDelay, 7200) : 60; - m_lastFailedHandshake = now; - if (!m_bBanned && !m_bBadAuth) - CLog::Log(LOGDEBUG, "%s: A hard error has occurred during "\ - "handshake. Sleeping for %d minutes.", - m_strLogPrefix.c_str(), m_failedHandshakeDelay/60); - - return false; -} - -bool CScrobbler::HandleHandshake(CStdString &strResponse) -{ - if (strResponse.IsEmpty()) - return false; - - std::vector<CStdString> vecTokens; - CUtil::Tokenize(strResponse, vecTokens, " \n\r"); - - if (vecTokens[0] == "OK") - { - if (vecTokens.size() >= 4) - { - m_strSessionID = vecTokens[1]; - m_strNowPlayingURL = vecTokens[2]; - m_strSubmissionURL = vecTokens[3]; - CLog::Log(LOGDEBUG, "%s: Handshake succeeded!", m_strLogPrefix.c_str()); - CLog::Log(LOGDEBUG, "%s: SessionID is %s", m_strLogPrefix.c_str(), - m_strSessionID.c_str()); - CLog::Log(LOGDEBUG, "%s: NP URL is %s", m_strLogPrefix.c_str(), - m_strNowPlayingURL.c_str()); - CLog::Log(LOGDEBUG, "%s: Submit URL is %s", m_strLogPrefix.c_str(), - m_strSubmissionURL.c_str()); - ClearErrorState(); - return true; - } - CLog::Log(LOGERROR, "%s: Handshake failed! Received malformed "\ - "reply.", m_strLogPrefix.c_str()); - } - else if (vecTokens[0] == "BANNED") - { - CLog::Log(LOGERROR, "%s: Handshake failed! Client is banned! "\ - "Disabling submissions. Subsequent scrobbles will be cached. "\ - "Please update your client to the newest version. ", m_strLogPrefix.c_str()); - if (m_failedHandshakeDelay == 0) - { - NotifyUser(SCROBBLER_USER_ERROR_BANNED); - } - } - else if (vecTokens[0] == "BADAUTH") - { - CLog::Log(LOGERROR, "%s: Handshake failed! Authentication failed! "\ - "Disabling submissions. Subsequent scrobbles will be cached. "\ - "Please enter the correct credentials to re-enable scrobbling. ", - m_strLogPrefix.c_str()); - if (m_failedHandshakeDelay == 0) - { - NotifyUser(SCROBBLER_USER_ERROR_BADAUTH); - } - } - else if (vecTokens[0] == "BADTIME") - { - CLog::Log(LOGDEBUG, "%s: Handshake failed! Timestamp is invalid! "\ - "Disabling submissions. Subsequent scrobbles will be cached. "\ - "Please correct the system time and restart the application. ", - m_strLogPrefix.c_str()); - } - else if (vecTokens[0] == "FAILED") - { - CLog::Log(LOGDEBUG, "%s: Handshake failed! REASON: %s! ", m_strLogPrefix.c_str(), - strResponse.c_str()); - } - else - CLog::Log(LOGDEBUG, "%s: Handshake failed! REASON: Unspecified!", m_strLogPrefix.c_str()); - - return false; -} - -bool CScrobbler::DoNowPlayingNotification() -{ - CStdString strNowPlayingRequest; - CStdString strResponse; - - // Construct now playing notification URL. - strNowPlayingRequest.Format("s=%s&a=%s&t=%s&b=%s&l=%d&n=%s&m=%s", - m_strSessionID.c_str(), m_CurrentTrack.strArtist.c_str(), - m_CurrentTrack.strTitle.c_str(), m_CurrentTrack.strAlbum.c_str(), - m_CurrentTrack.length, m_CurrentTrack.strTrackNum.c_str(), - m_CurrentTrack.strMusicBrainzID.c_str()); - - // Make and handle request - if (m_pHttp->Post(m_strNowPlayingURL, strNowPlayingRequest, strResponse) && - HandleNowPlayingNotification(strResponse)) - return true; - - HandleHardError(); - return false; -} - -bool CScrobbler::HandleNowPlayingNotification(CStdString &strResponse) -{ - if (strResponse.IsEmpty()) - return false; - - std::vector<CStdString> vecTokens; - CUtil::Tokenize(strResponse, vecTokens, " \n\r"); - - if (vecTokens[0] == "OK") - { - CLog::Log(LOGDEBUG, "%s: Now playing notification succeeded!", m_strLogPrefix.c_str()); - ClearErrorState(); - return true; - } - else if (vecTokens[0] == "BADSESSION") - { - CLog::Log(LOGDEBUG, "%s: Now playing notification failed! "\ - "REASON: Bad session ID. Forcing new handshake.", m_strLogPrefix.c_str()); - ClearSession(); - } - else - CLog::Log(LOGDEBUG, "%s: Now playing notification failed! "\ - "REASON: Unspecified.", m_strLogPrefix.c_str()); - - return false; -} - -bool CScrobbler::DoSubmission() -{ - int i; - int numSubmissions; - CStdString strSubmissionRequest; - CStdString strSubmission; - CStdString strResponse; - CSingleLock lock(m_queueLock); - - // Construct submission URL. - numSubmissions = - std::min((size_t)SCROBBLER_MAX_SUBMISSIONS, m_vecSubmissionQueue.size()); - if (numSubmissions == 0) - return true; - strSubmissionRequest.Format("s=%s", m_strSessionID.c_str()); - SCROBBLERJOURNALITERATOR it = m_vecSubmissionQueue.begin(); - for (i = 0; it != m_vecSubmissionQueue.end() && i < numSubmissions; i++,it++) - { - strSubmission.Format("&a[%d]=%s&t[%d]=%s&i[%d]=%s&o[%d]=%s&r[%d]=%s", - i, it->strArtist.c_str(), i, it->strTitle.c_str(), - i, it->strStartTime.c_str(), i, it->strSource.c_str(), - i, it->strRating.c_str()); - // Too many params, must be split (or hack CStdString) - strSubmission.Format("%s&l[%d]=%s&b[%d]=%s&n[%d]=%s&m[%d]=%s", - strSubmission.c_str(), i, it->strLength.c_str(), - i, it->strAlbum.c_str(), i, it->strTrackNum.c_str(), - i, it->strMusicBrainzID.c_str()); - strSubmissionRequest += strSubmission; - } - - // Make and handle request - lock.Leave(); - if (m_pHttp->Post(m_strSubmissionURL, strSubmissionRequest, strResponse) && - HandleSubmission(strResponse)) - { - lock.Enter(); - SCROBBLERJOURNALITERATOR it = m_vecSubmissionQueue.begin(); - m_vecSubmissionQueue.erase(it, it + i); // Remove submitted entries - lock.Leave(); - SaveJournal(); - return true; - } - - HandleHardError(); - return false; -} - -bool CScrobbler::HandleSubmission(CStdString &strResponse) -{ - if (strResponse.IsEmpty()) - return false; - - std::vector<CStdString> vecTokens; - CUtil::Tokenize(strResponse, vecTokens, " \n\r"); - - if (vecTokens[0] == "OK") - { - CLog::Log(LOGDEBUG, "%s: Submission succeeded!", m_strLogPrefix.c_str()); - ClearErrorState(); - return true; - } - else if (vecTokens[0] == "BADSESSION") - { - CLog::Log(LOGDEBUG, "%s: Submission failed! "\ - "REASON: Bad session. Forcing new handshake.", m_strLogPrefix.c_str()); - ClearSession(); - } - else if (vecTokens[0] == "FAILED") - { - CLog::Log(LOGDEBUG, "%s: Submission failed! "\ - "REASON: %s", m_strLogPrefix.c_str(), strResponse.c_str()); - } - else - CLog::Log(LOGDEBUG, "%s: Submission failed! "\ - "REASON: Unspecified.", m_strLogPrefix.c_str()); - - return false; -} - -void CScrobbler::Process() -{ - CLog::Log(LOGDEBUG, "%s: Thread started.", m_strLogPrefix.c_str()); - if (!m_pHttp) - { - // Hack since CCurlFile isn't threadsafe - if (!(m_pHttp = new XFILE::CCurlFile)) - return; - } - while (!m_bStop) - { - AbortableWait(m_hEvent); - if (m_bStop) - break; - - if (m_strSessionID.IsEmpty()) - { - time_t now = time(NULL); - // We need to handshake. - if (m_bBanned || m_bBadAuth || - ((now - m_lastFailedHandshake) < m_failedHandshakeDelay)) - continue; - if (!DoHandshake(now)) - continue; - } - int action = 0; - { - CSingleLock lock(m_actionLock); - action = m_action; - m_action = 0; - } - if (action == SCROBBLER_ACTION_NOWPLAYING) - DoNowPlayingNotification(); - else if (action == SCROBBLER_ACTION_SUBMIT) - { - m_bSubmitting = true; - DoSubmission(); - m_bSubmitting = false; - } - } - delete m_pHttp; // More of aforementioned hack - m_pHttp = NULL; - CLog::Log(LOGDEBUG, "%s: Thread ended.", m_strLogPrefix.c_str()); -} - -void CScrobbler::NotifyUser(int error) -{ -} - -bool CScrobbler::CanScrobble() -{ - return false; -} - -void CScrobbler::LoadCredentials() -{ - SetUsername(""); - SetPassword(""); -} - -CStdString CScrobbler::GetJournalFileName() -{ - return ""; -} - diff --git a/xbmc/network/libscrobbler/scrobbler.h b/xbmc/network/libscrobbler/scrobbler.h deleted file mode 100644 index d3abf053fa..0000000000 --- a/xbmc/network/libscrobbler/scrobbler.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * <http://www.gnu.org/licenses/>. - * - */ - -#ifndef LIBSCROBBLER_H__ -#define LIBSCROBBLER_H__ - -#include <vector> -#include "utils/StdString.h" -#include "threads/Thread.h" -#include "threads/CriticalSection.h" -#include "threads/Event.h" - -#define SCROBBLER_USER_ERROR_BADAUTH 1 -#define SCROBBLER_USER_ERROR_BANNED 2 - -namespace MUSIC_INFO -{ - class CMusicInfoTag; -} - -namespace XFILE -{ - class CCurlFile; -} - -/* The following structure describes an entry in the scrobbler submission - * journal. Declare members added purely for convenience at the top and - * members which will actually be read/written from/to disk under a - * version number comment. Also, remember to bump the version macro in - * scrobbler.cpp. - */ -typedef struct SubmissionJournalEntry_s -{ - int length; - // v0 - CStdString strArtist; - CStdString strAlbum; - CStdString strTitle; - CStdString strLength; // Required if strSource below is "P" - CStdString strStartTime; - CStdString strMusicBrainzID; - // v1 - CStdString strTrackNum; - CStdString strSource; - /* strSource must be one of the following. - * P: Chosen by the user (the most common value, unless you have a reason - * for choosing otherwise, use this). - * R: Non-personalised broadcast (e.g. Shoutcast, BBC Radio 1). - * E: Personalised recommendation except Last.fm (e.g. Pandora, Launchcast). - * L: Last.fm (any mode). In this case, the 5-digit Last.fm recommendation - * key must be appended to this source ID to prove the validity of the - * submission (for example, "o[0]=L1b48a"). - * U: Source unknown. - */ - CStdString strRating; - /* strRating must be one of the following or empty. - * L: Love (on any mode if the user has manually loved the track). This - * implies a listen. - * B: Ban (only if source=L). This implies a skip, and the client should - * skip to the next track when a ban happens. - * S: Skip (only if source=L) - * - * NOTE: This will eventually replace the love/ban web service. - */ - SubmissionJournalEntry_s() {} - SubmissionJournalEntry_s(const struct SubmissionJournalEntry_s& j) - { - strArtist = j.strArtist; - strAlbum = j.strAlbum; - strTitle = j.strTitle; - strLength = j.strLength; - strStartTime = j.strStartTime; - strMusicBrainzID = j.strMusicBrainzID; - strTrackNum = j.strTrackNum; - strSource = j.strSource; - strRating = j.strRating; - length = j.length; - } - void Clear() - { - strArtist.clear(); - strAlbum.clear(); - strTitle.clear(); - strLength.clear(); - strStartTime.clear(); - strMusicBrainzID.clear(); - strTrackNum.clear(); - strSource = "P"; - strRating.clear(); - length = 0; - } -} SubmissionJournalEntry; - -typedef std::vector<SubmissionJournalEntry>::iterator SCROBBLERJOURNALITERATOR; - -class CScrobbler : public CThread -{ -protected: - bool m_bNotified; - bool m_bSubmitting; - bool m_bSubmitted; - bool m_bBanned; - bool m_bBadAuth; - int m_submissionTimer; - int m_hardErrorCount; - int m_failedHandshakeDelay; - int m_action; - time_t m_lastFailedHandshake; - CStdString m_strLogPrefix; - CStdString m_strUsername; - CStdString m_strPasswordHash; - CStdString m_strSessionID; - CStdString m_strHandshakeURL; - CStdString m_strNowPlayingURL; - CStdString m_strSubmissionURL; - CStdString m_strHandshakeTimeStamp; - SubmissionJournalEntry m_CurrentTrack; - CEvent m_hEvent; - XFILE::CCurlFile *m_pHttp; - CCriticalSection m_queueLock; - CCriticalSection m_actionLock; - std::vector<SubmissionJournalEntry> m_vecSubmissionQueue; -private: - void ResetState(); - void ClearErrorState(); - void ClearSubmissionState(); - void ClearSession(); - void HandleHardError(); - bool LoadJournal(); - bool SaveJournal(); - bool DoHandshake(time_t now); - bool HandleHandshake(CStdString &strResponse); - bool DoNowPlayingNotification(); - bool HandleNowPlayingNotification(CStdString &strResponse); - bool DoSubmission(); - bool HandleSubmission(CStdString &strResponse); - virtual void Process(); // Shouldn't need over ridden by inheriting CScrobblers -protected: - virtual void NotifyUser(int error); - virtual bool CanScrobble(); - virtual void LoadCredentials(); - virtual CStdString GetJournalFileName(); - -public: - CScrobbler(const CStdString &strHandshakeURL, const CStdString &strLogPrefix = "CScrobbler"); - virtual ~CScrobbler(); - void Init(); - void Term(); - void AddSong(const MUSIC_INFO::CMusicInfoTag &tag, bool lastfmradio); - void UpdateStatus(); - void SubmitQueue(); - void SetUsername(const CStdString &strUser); - void SetPassword(const CStdString &strPass); - CStdString GetConnectionState(); - CStdString GetSubmitInterval(); - CStdString GetFilesCached(); - CStdString GetSubmitState(); -}; - -#endif // LIBSCROBBLER_H__ diff --git a/xbmc/playlists/PlayListFactory.cpp b/xbmc/playlists/PlayListFactory.cpp index 17dabdcf67..be4e293161 100644 --- a/xbmc/playlists/PlayListFactory.cpp +++ b/xbmc/playlists/PlayListFactory.cpp @@ -37,9 +37,6 @@ CPlayList* CPlayListFactory::Create(const CStdString& filename) CPlayList* CPlayListFactory::Create(const CFileItem& item) { - if(item.IsLastFM()) //lastfm is always a stream, and just silly to check content - return NULL; - if( item.IsInternetStream() ) { CStdString strMimeType = item.GetMimeType(); diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp index 5b9bc463ef..8dba6d37e5 100644 --- a/xbmc/settings/GUISettings.cpp +++ b/xbmc/settings/GUISettings.cpp @@ -329,15 +329,6 @@ void CGUISettings::Initialize() AddString(NULL, "musicfiles.librarytrackformatright", 13387, "", EDIT_CONTROL_INPUT, false, 16016); AddBool(mf, "musicfiles.findremotethumbs", 14059, true); - CSettingsCategory* scr = AddCategory(SETTINGS_MUSIC, "scrobbler", 15221); - AddBool(scr, "scrobbler.lastfmsubmit", 15201, false); - AddString(scr,"scrobbler.lastfmusername", 15202, "", EDIT_CONTROL_INPUT, false, 15202); - AddString(scr,"scrobbler.lastfmpass", 15203, "", EDIT_CONTROL_MD5_INPUT, false, 15203); - AddSeparator(scr, "scrobbler.sep1"); - AddBool(scr, "scrobbler.librefmsubmit", 15217, false); - AddString(scr, "scrobbler.librefmusername", 15218, "", EDIT_CONTROL_INPUT, false, 15218); - AddString(scr, "scrobbler.librefmpass", 15219, "", EDIT_CONTROL_MD5_INPUT, false, 15219); - CSettingsCategory* acd = AddCategory(SETTINGS_MUSIC, "audiocds", 620); map<int,int> autocd; autocd.insert(make_pair(16018, AUTOCD_NONE)); diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp index 2b421e8cb2..8e939eb4d7 100644 --- a/xbmc/settings/Settings.cpp +++ b/xbmc/settings/Settings.cpp @@ -701,7 +701,6 @@ bool CSettings::LoadSettings(const CStdString& strSettingsFile) GetViewState(pElement, "musicnavartists", m_viewStateMusicNavArtists); GetViewState(pElement, "musicnavalbums", m_viewStateMusicNavAlbums); GetViewState(pElement, "musicnavsongs", m_viewStateMusicNavSongs); - GetViewState(pElement, "musiclastfm", m_viewStateMusicLastFM); GetViewState(pElement, "videonavactors", m_viewStateVideoNavActors); GetViewState(pElement, "videonavyears", m_viewStateVideoNavYears); GetViewState(pElement, "videonavgenres", m_viewStateVideoNavGenres); @@ -877,7 +876,6 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo SetViewState(pNode, "musicnavartists", m_viewStateMusicNavArtists); SetViewState(pNode, "musicnavalbums", m_viewStateMusicNavAlbums); SetViewState(pNode, "musicnavsongs", m_viewStateMusicNavSongs); - SetViewState(pNode, "musiclastfm", m_viewStateMusicLastFM); SetViewState(pNode, "videonavactors", m_viewStateVideoNavActors); SetViewState(pNode, "videonavyears", m_viewStateVideoNavYears); SetViewState(pNode, "videonavgenres", m_viewStateVideoNavGenres); diff --git a/xbmc/settings/Settings.h b/xbmc/settings/Settings.h index 69f1a56c0c..fd44a0f306 100644 --- a/xbmc/settings/Settings.h +++ b/xbmc/settings/Settings.h @@ -170,7 +170,6 @@ public: CViewState m_viewStateMusicNavArtists; CViewState m_viewStateMusicNavAlbums; CViewState m_viewStateMusicNavSongs; - CViewState m_viewStateMusicLastFM; CViewState m_viewStateVideoNavActors; CViewState m_viewStateVideoNavYears; CViewState m_viewStateVideoNavGenres; diff --git a/xbmc/settings/windows/GUIWindowSettingsCategory.cpp b/xbmc/settings/windows/GUIWindowSettingsCategory.cpp index 62374d81bd..80b5d77afd 100644 --- a/xbmc/settings/windows/GUIWindowSettingsCategory.cpp +++ b/xbmc/settings/windows/GUIWindowSettingsCategory.cpp @@ -38,8 +38,6 @@ #include "PlayListPlayer.h" #include "addons/Skin.h" #include "guilib/GUIAudioManager.h" -#include "network/libscrobbler/lastfmscrobbler.h" -#include "network/libscrobbler/librefmscrobbler.h" #include "GUIPassword.h" #include "GUIInfoManager.h" #include "dialogs/GUIDialogGamepad.h" @@ -889,16 +887,6 @@ void CGUIWindowSettingsCategory::UpdateSettings() pControl->SetEnabled(geteuid() == 0); } #endif - else if (strSetting.Equals("scrobbler.lastfmusername") || strSetting.Equals("scrobbler.lastfmpass")) - { - CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("scrobbler.lastfmsubmit")); - } - else if (strSetting.Equals("scrobbler.librefmusername") || strSetting.Equals("scrobbler.librefmpass")) - { - CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID()); - if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("scrobbler.librefmsubmit")); - } else if (strSetting.Equals("subtitles.color") || strSetting.Equals("subtitles.style") || strSetting.Equals("subtitles.charset")) { CGUIControl *pControl = (CGUIControl *)GetControl(GetSetting(strSetting)->GetID()); @@ -1212,34 +1200,6 @@ void CGUIWindowSettingsCategory::OnSettingChanged(BaseSettingControlPtr pSetting musicdatabase.Close(); } } - else if (strSetting.Equals("scrobbler.lastfmsubmit") || strSetting.Equals("scrobbler.lastfmusername") || strSetting.Equals("scrobbler.lastfmpass")) - { - CStdString strPassword=g_guiSettings.GetString("scrobbler.lastfmpass"); - CStdString strUserName=g_guiSettings.GetString("scrobbler.lastfmusername"); - if (g_guiSettings.GetBool("scrobbler.lastfmsubmit") && - !strUserName.IsEmpty() && !strPassword.IsEmpty()) - { - CLastfmScrobbler::GetInstance()->Init(); - } - else - { - CLastfmScrobbler::GetInstance()->Term(); - } - } - else if (strSetting.Equals("scrobbler.librefmsubmit") || strSetting.Equals("scrobbler.librefmusername") || strSetting.Equals("scrobbler.librefmpass")) - { - CStdString strPassword=g_guiSettings.GetString("scrobbler.librefmpass"); - CStdString strUserName=g_guiSettings.GetString("scrobbler.librefmusername"); - if (g_guiSettings.GetBool("scrobbler.librefmsubmit") && - !strUserName.IsEmpty() && !strPassword.IsEmpty()) - { - CLibrefmScrobbler::GetInstance()->Init(); - } - else - { - CLibrefmScrobbler::GetInstance()->Term(); - } - } else if (strSetting.Left(22).Equals("MusicPlayer.ReplayGain")) { // Update our replaygain settings g_guiSettings.m_replayGain.iType = g_guiSettings.GetInt("musicplayer.replaygaintype"); diff --git a/xbmc/utils/URIUtils.cpp b/xbmc/utils/URIUtils.cpp index 4663b85ac4..cfb9de81c5 100644 --- a/xbmc/utils/URIUtils.cpp +++ b/xbmc/utils/URIUtils.cpp @@ -840,11 +840,6 @@ bool URIUtils::IsVideoDb(const CStdString& strFile) return strFile.Left(8).Equals("videodb:"); } -bool URIUtils::IsLastFM(const CStdString& strFile) -{ - return strFile.Left(7).Equals("lastfm:"); -} - bool URIUtils::IsBluray(const CStdString& strFile) { return strFile.Left(7).Equals("bluray:"); diff --git a/xbmc/utils/URIUtils.h b/xbmc/utils/URIUtils.h index 3e6f2510f3..826489d0f7 100644 --- a/xbmc/utils/URIUtils.h +++ b/xbmc/utils/URIUtils.h @@ -69,7 +69,6 @@ public: static bool IsInAPK(const CStdString& strFile); static bool IsInZIP(const CStdString& strFile); static bool IsISO9660(const CStdString& strFile); - static bool IsLastFM(const CStdString& strFile); static bool IsLiveTV(const CStdString& strFile); static bool IsPVRRecording(const CStdString& strFile); static bool IsMultiPath(const CStdString& strPath); diff --git a/xbmc/utils/test/TestURIUtils.cpp b/xbmc/utils/test/TestURIUtils.cpp index 87988bcade..548af27503 100644 --- a/xbmc/utils/test/TestURIUtils.cpp +++ b/xbmc/utils/test/TestURIUtils.cpp @@ -277,11 +277,6 @@ TEST_F(TestURIUtils, IsISO9660) EXPECT_TRUE(URIUtils::IsISO9660("iso9660://path/to/file")); } -TEST_F(TestURIUtils, IsLastFM) -{ - EXPECT_TRUE(URIUtils::IsLastFM("lastfm://path/to/file")); -} - TEST_F(TestURIUtils, IsLiveTV) { EXPECT_TRUE(URIUtils::IsLiveTV("tuxbox://path/to/file")); @@ -487,7 +482,6 @@ TEST_F(TestURIUtils, ProtocolHasEncodedFilename) EXPECT_TRUE(URIUtils::ProtocolHasEncodedFilename("daap")); EXPECT_TRUE(URIUtils::ProtocolHasEncodedFilename("dav")); EXPECT_TRUE(URIUtils::ProtocolHasEncodedFilename("tuxbox")); - EXPECT_TRUE(URIUtils::ProtocolHasEncodedFilename("lastfm")); EXPECT_TRUE(URIUtils::ProtocolHasEncodedFilename("rss")); EXPECT_TRUE(URIUtils::ProtocolHasEncodedFilename("davs")); } diff --git a/xbmc/view/GUIViewState.cpp b/xbmc/view/GUIViewState.cpp index de0b5b371d..6778263893 100644 --- a/xbmc/view/GUIViewState.cpp +++ b/xbmc/view/GUIViewState.cpp @@ -103,9 +103,6 @@ CGUIViewState* CGUIViewState::GetViewState(int windowId, const CFileItemList& it if (items.IsPlayList()) return new CGUIViewStateMusicPlaylist(items); - if (url.GetProtocol() == "lastfm") - return new CGUIViewStateMusicLastFM(items); - if (items.GetPath() == "special://musicplaylists/") return new CGUIViewStateWindowMusicSongs(items); |