diff options
Diffstat (limited to 'xbmc/playlists/PlayListPLS.cpp')
-rw-r--r-- | xbmc/playlists/PlayListPLS.cpp | 188 |
1 files changed, 5 insertions, 183 deletions
diff --git a/xbmc/playlists/PlayListPLS.cpp b/xbmc/playlists/PlayListPLS.cpp index 29cd4eb1b7..00eb67bfe4 100644 --- a/xbmc/playlists/PlayListPLS.cpp +++ b/xbmc/playlists/PlayListPLS.cpp @@ -17,24 +17,20 @@ #include "utils/CharsetConverter.h" #include "utils/StringUtils.h" #include "utils/URIUtils.h" -#include "utils/XBMCTinyXML.h" -#include "utils/XMLUtils.h" #include "utils/log.h" -#include "video/VideoFileItemClassify.h" -#include "video/VideoInfoTag.h" #include <iostream> -#include <memory> #include <string> #include <vector> -using namespace KODI; using namespace XFILE; -using namespace PLAYLIST; #define START_PLAYLIST_MARKER "[playlist]" // may be case-insensitive (equivalent to .ini file on win32) #define PLAYLIST_NAME "PlaylistName" +namespace KODI::PLAYLIST +{ + /*---------------------------------------------------------------------- [playlist] PlaylistName=Playlist 001 @@ -239,182 +235,6 @@ void CPlayListPLS::Save(const std::string& strFileName) const file.Close(); } -bool CPlayListASX::LoadAsxIniInfo(std::istream &stream) -{ - CLog::Log(LOGINFO, "Parsing INI style ASX"); - - std::string name, value; - - while( stream.good() ) - { - // consume blank rows, and blanks - while((stream.peek() == '\r' || stream.peek() == '\n' || stream.peek() == ' ') && stream.good()) - stream.get(); - - if(stream.peek() == '[') - { - // this is an [section] part, just ignore it - while(stream.good() && stream.peek() != '\r' && stream.peek() != '\n') - stream.get(); - continue; - } - name = ""; - value = ""; - // consume name - while(stream.peek() != '\r' && stream.peek() != '\n' && stream.peek() != '=' && stream.good()) - name += stream.get(); - - // consume = - if(stream.get() != '=') - continue; - - // consume value - while(stream.peek() != '\r' && stream.peek() != '\n' && stream.good()) - value += stream.get(); - - CLog::Log(LOGINFO, "Adding element {}={}", name, value); - CFileItemPtr newItem(new CFileItem(value)); - newItem->SetPath(value); - if (VIDEO::IsVideo(*newItem) && - !newItem->HasVideoInfoTag()) // File is a video and needs a VideoInfoTag - newItem->GetVideoInfoTag()->Reset(); // Force VideoInfoTag creation - Add(newItem); - } - - return true; -} - -bool CPlayListASX::LoadData(std::istream& stream) -{ - CLog::Log(LOGINFO, "Parsing ASX"); - - if(stream.peek() == '[') - { - return LoadAsxIniInfo(stream); - } - else - { - std::string asxstream(std::istreambuf_iterator<char>(stream), {}); - CXBMCTinyXML xmlDoc; - xmlDoc.Parse(asxstream, TIXML_DEFAULT_ENCODING); - - if (xmlDoc.Error()) - { - CLog::Log(LOGERROR, "Unable to parse ASX info Error: {}", xmlDoc.ErrorDesc()); - return false; - } - - TiXmlElement *pRootElement = xmlDoc.RootElement(); - - if (!pRootElement) - return false; - - // lowercase every element - TiXmlNode *pNode = pRootElement; - TiXmlNode *pChild = NULL; - std::string value; - value = pNode->Value(); - StringUtils::ToLower(value); - pNode->SetValue(value); - while(pNode) - { - pChild = pNode->IterateChildren(pChild); - if(pChild) - { - if (pChild->Type() == TiXmlNode::TINYXML_ELEMENT) - { - value = pChild->Value(); - StringUtils::ToLower(value); - pChild->SetValue(value); - - TiXmlAttribute* pAttr = pChild->ToElement()->FirstAttribute(); - while(pAttr) - { - value = pAttr->Name(); - StringUtils::ToLower(value); - pAttr->SetName(value); - pAttr = pAttr->Next(); - } - } - - pNode = pChild; - pChild = NULL; - continue; - } - - pChild = pNode; - pNode = pNode->Parent(); - } - std::string roottitle; - TiXmlElement *pElement = pRootElement->FirstChildElement(); - while (pElement) - { - value = pElement->Value(); - if (value == "title" && !pElement->NoChildren()) - { - roottitle = pElement->FirstChild()->ValueStr(); - } - else if (value == "entry") - { - std::string title(roottitle); - - TiXmlElement *pRef = pElement->FirstChildElement("ref"); - TiXmlElement *pTitle = pElement->FirstChildElement("title"); - - if(pTitle && !pTitle->NoChildren()) - title = pTitle->FirstChild()->ValueStr(); - - while (pRef) - { // multiple references may appear for one entry - // duration may exist on this level too - value = XMLUtils::GetAttribute(pRef, "href"); - if (!value.empty()) - { - if(title.empty()) - title = value; - - CLog::Log(LOGINFO, "Adding element {}, {}", title, value); - CFileItemPtr newItem(new CFileItem(title)); - newItem->SetPath(value); - Add(newItem); - } - pRef = pRef->NextSiblingElement("ref"); - } - } - else if (value == "entryref") - { - value = XMLUtils::GetAttribute(pElement, "href"); - if (!value.empty()) - { // found an entryref, let's try loading that url - std::unique_ptr<CPlayList> playlist(CPlayListFactory::Create(value)); - if (nullptr != playlist) - if (playlist->Load(value)) - Add(*playlist); - } - } - pElement = pElement->NextSiblingElement(); - } - } - - return true; -} - - -bool CPlayListRAM::LoadData(std::istream& stream) -{ - CLog::Log(LOGINFO, "Parsing RAM"); - - std::string strMMS; - while( stream.peek() != '\n' && stream.peek() != '\r' ) - strMMS += stream.get(); - - CLog::Log(LOGINFO, "Adding element {}", strMMS); - CFileItemPtr newItem(new CFileItem(strMMS)); - newItem->SetPath(strMMS); - Add(newItem); - return true; -} - bool CPlayListPLS::Resize(std::vector <int>::size_type newSize) { if (newSize == 0) @@ -427,3 +247,5 @@ bool CPlayListPLS::Resize(std::vector <int>::size_type newSize) } return true; } + +} // namespace KODI::PLAYLIST |