diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index 4bb7fe4df5572..1f48ca684c0d7 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -1865,11 +1865,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; @@ -1911,8 +1911,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; @@ -1990,9 +1990,13 @@ void CUtil::ScanForExternalSubtitles(const std::string& strMovie, std::vectorGetPath(), strPath, strItem); + std::string strSubtitlePath; + URIUtils::Split(items[j]->GetPath(), 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 @@ -2019,8 +2023,11 @@ void CUtil::ScanForExternalSubtitles(const std::string& strMovie, std::vectorGetPath(), strMovieFileNameNoExt, vecSubtitles ); + ScanArchiveForSubtitles(items[j]->GetPath(), strMovieFileNameNoExt2, vecSubtitles ); } } } diff --git a/xbmc/utils/URIUtils.cpp b/xbmc/utils/URIUtils.cpp index 1127a9ac9c33c..5caa91ef5b155 100644 --- a/xbmc/utils/URIUtils.cpp +++ b/xbmc/utils/URIUtils.cpp @@ -420,7 +420,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; @@ -444,7 +444,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 dc280fc77b7cb..8ddb2adf919df 100644 --- a/xbmc/utils/URIUtils.h +++ b/xbmc/utils/URIUtils.h @@ -79,7 +79,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 std::string SubstitutePath(const std::string& strPath, bool reverse = false);