diff options
author | Rainer Hochecker <fernetmenta@online.de> | 2018-03-14 19:36:43 +0100 |
---|---|---|
committer | Rainer Hochecker <fernetmenta@online.de> | 2018-03-14 19:36:43 +0100 |
commit | 62f697c9859eed011642ea07dffa6aa733580af2 (patch) | |
tree | 4b4302c1bf1fbf62ccaa5a5c6a8b5ccff907d971 | |
parent | 7862c3bba084e6ade9f19479ce0768b818241861 (diff) |
playlist: consider dynpath when creating playlists
-rw-r--r-- | xbmc/playlists/PlayList.cpp | 26 | ||||
-rw-r--r-- | xbmc/playlists/PlayListFactory.cpp | 8 |
2 files changed, 27 insertions, 7 deletions
diff --git a/xbmc/playlists/PlayList.cpp b/xbmc/playlists/PlayList.cpp index b5b14c9212..5584cc35c8 100644 --- a/xbmc/playlists/PlayList.cpp +++ b/xbmc/playlists/PlayList.cpp @@ -463,23 +463,39 @@ bool CPlayList::Expand(int position) { CFileItemPtr item = m_vecItems[position]; std::unique_ptr<CPlayList> playlist (CPlayListFactory::Create(*item.get())); - if ( NULL == playlist.get()) + if (playlist.get() == nullptr) return false; - if(!playlist->Load(item->GetPath())) + std::string path = item->GetDynPath(); + if (path.empty()) + path = item->GetPath(); + + if (!playlist->Load(path)) return false; // remove any item that points back to itself - for(int i = 0;i<playlist->size();i++) + for (int i = 0;i<playlist->size();i++) { - if(StringUtils::EqualsNoCase((*playlist)[i]->GetPath(), item->GetPath())) + if (StringUtils::EqualsNoCase((*playlist)[i]->GetPath(), path)) { playlist->Remove(i); i--; } } - if(playlist->size() <= 0) + // @todo + // never change original path (id) of a file item + // playlist items should be created with dynPath instead + if (!item->GetDynPath().empty()) + { + for (int i = 0;i<playlist->size();i++) + { + (*playlist)[i]->SetDynPath((*playlist)[i]->GetPath()); + (*playlist)[i]->SetPath(item->GetPath()); + } + } + + if (playlist->size() <= 0) return false; Remove(position); diff --git a/xbmc/playlists/PlayListFactory.cpp b/xbmc/playlists/PlayListFactory.cpp index 46d0227abf..3b721cc5e5 100644 --- a/xbmc/playlists/PlayListFactory.cpp +++ b/xbmc/playlists/PlayListFactory.cpp @@ -38,7 +38,7 @@ CPlayList* CPlayListFactory::Create(const std::string& filename) CPlayList* CPlayListFactory::Create(const CFileItem& item) { - if( item.IsInternetStream() ) + if (item.IsInternetStream()) { // Ensure the MIME type has been retrieved for http:// and shout:// streams if (item.GetMimeType().empty()) @@ -72,7 +72,11 @@ CPlayList* CPlayListFactory::Create(const CFileItem& item) return new CPlayListWPL(); } - std::string extension = URIUtils::GetExtension(item.GetPath()); + std::string path = item.GetDynPath(); + if (path.empty()) + path = item.GetPath(); + + std::string extension = URIUtils::GetExtension(path); StringUtils::ToLower(extension); if (extension == ".m3u" || extension == ".strm") |