From 183b9456929f8ef5e215032050c8f4c658f048de Mon Sep 17 00:00:00 2001 From: arnova Date: Tue, 3 Feb 2015 10:00:39 +0100 Subject: [PATCH 1/3] changed: Add option to not add the path with ChangeBasePath --- xbmc/utils/URIUtils.cpp | 7 +++++-- xbmc/utils/URIUtils.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xbmc/utils/URIUtils.cpp b/xbmc/utils/URIUtils.cpp index 6ab3dbb9b241f..8259d878e1b63 100644 --- a/xbmc/utils/URIUtils.cpp +++ b/xbmc/utils/URIUtils.cpp @@ -419,7 +419,7 @@ std::string URLDecodePath(const std::string& strPath) return StringUtils::Join(segments, "/"); } -std::string URIUtils::ChangeBasePath(const std::string &fromPath, const std::string &fromFile, const std::string &toPath) +std::string URIUtils::ChangeBasePath(const std::string &fromPath, const std::string &fromFile, const std::string &toPath, const bool &bAddPath /* = true */) { std::string toFile = fromFile; @@ -443,7 +443,10 @@ std::string URIUtils::ChangeBasePath(const std::string &fromPath, const std::str if (!IsDOSPath(fromPath) && IsDOSPath(toPath)) StringUtils::Replace(toFile, "/", "\\"); - return AddFileToFolder(toPath, toFile); + if (bAddPath) + return AddFileToFolder(toPath, toFile); + + return toFile; } CURL URIUtils::SubstitutePath(const CURL& url, bool reverse /* = false */) diff --git a/xbmc/utils/URIUtils.h b/xbmc/utils/URIUtils.h index 0094709d0c37a..48ef95df7e7b4 100644 --- a/xbmc/utils/URIUtils.h +++ b/xbmc/utils/URIUtils.h @@ -78,7 +78,7 @@ class URIUtils \param toPath the base path of the resulting URL \return the full path. */ - static std::string ChangeBasePath(const std::string &fromPath, const std::string &fromFile, const std::string &toPath); + static std::string ChangeBasePath(const std::string &fromPath, const std::string &fromFile, const std::string &toPath, const bool &bAddPath = true); static CURL SubstitutePath(const CURL& url, bool reverse = false); static CStdString SubstitutePath(const CStdString& strPath, bool reverse = false); From e72860fca7c56cf55d17a08282ece38dec352cdc Mon Sep 17 00:00:00 2001 From: arnova Date: Tue, 3 Feb 2015 11:00:05 +0100 Subject: [PATCH 2/3] changed: Rename shared strPath to seperate strMoviePath and strSubtitlePath for clarity --- xbmc/Util.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index 1760beb010f2c..c3563481b2631 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -1898,11 +1898,11 @@ void CUtil::ScanForExternalSubtitles(const std::string& strMovie, std::vector strLookInPaths; std::string strMovieFileName; - std::string strPath; + std::string strMoviePath; - URIUtils::Split(strMovie, strPath, strMovieFileName); + URIUtils::Split(strMovie, strMoviePath, strMovieFileName); std::string strMovieFileNameNoExt(URIUtils::ReplaceExtension(strMovieFileName, "")); - strLookInPaths.push_back(strPath); + strLookInPaths.push_back(strMoviePath); CURL url(strMovie); std::string isoFileNameNoExt; @@ -1944,8 +1944,8 @@ void CUtil::ScanForExternalSubtitles(const std::string& strMovie, std::vector dir. if (CMediaSettings::Get().GetAdditionalSubtitleDirectoryChecked() == 1) { - strPath = CSettings::Get().GetString("subtitles.custompath"); - URIUtils::AddSlashAtEnd(strPath); - strLookInPaths.push_back(strPath); + std::string strPath2 = CSettings::Get().GetString("subtitles.custompath"); + URIUtils::AddSlashAtEnd(strPath2); + strLookInPaths.push_back(strPath2); } std::string strDest; @@ -2023,7 +2023,8 @@ void CUtil::ScanForExternalSubtitles(const std::string& strMovie, std::vectorGetPath(), strPath, strItem); + std::string strSubtitlePath; + URIUtils::Split(items[j]->GetPath(), strSubtitlePath, strItem); if (StringUtils::StartsWithNoCase(strItem, strMovieFileNameNoExt) || (!isoFileNameNoExt.empty() && StringUtils::StartsWithNoCase(strItem, isoFileNameNoExt))) From a10def9b8f0366c2b3d3fb01467b8e66bfaa83c5 Mon Sep 17 00:00:00 2001 From: arnova Date: Tue, 3 Feb 2015 11:43:31 +0100 Subject: [PATCH 3/3] fixed: External subs in (local) custom folder did not work with url encoded files --- xbmc/Util.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index c3563481b2631..e176ea1a60939 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -2025,8 +2025,11 @@ void CUtil::ScanForExternalSubtitles(const std::string& strMovie, std::vectorGetPath(), strSubtitlePath, strItem); + + // Make sure filename uses the correct encoding + std::string strMovieFileNameNoExt2 = URIUtils::ChangeBasePath(strMoviePath, strMovieFileNameNoExt, strSubtitlePath, false); - if (StringUtils::StartsWithNoCase(strItem, strMovieFileNameNoExt) + if (StringUtils::StartsWithNoCase(strItem, strMovieFileNameNoExt2) || (!isoFileNameNoExt.empty() && StringUtils::StartsWithNoCase(strItem, isoFileNameNoExt))) { // is this a rar or zip-file @@ -2053,8 +2056,11 @@ void CUtil::ScanForExternalSubtitles(const std::string& strMovie, std::vectorGetPath(), strMovieFileNameNoExt, vecSubtitles ); + ScanArchiveForSubtitles(items[j]->GetPath(), strMovieFileNameNoExt2, vecSubtitles ); } } }