From 62f697c9859eed011642ea07dffa6aa733580af2 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Wed, 14 Mar 2018 19:36:43 +0100 Subject: playlist: consider dynpath when creating playlists --- xbmc/playlists/PlayList.cpp | 26 +++++++++++++++++++++----- 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 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;isize();i++) + for (int i = 0;isize();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;isize();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") -- cgit v1.2.3