aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzard <fuzzard@users.noreply.github.com>2024-02-11 08:20:39 +1000
committerGitHub <noreply@github.com>2024-02-11 08:20:39 +1000
commit522894301504ff80d54ba680edcd17fbb282ddb5 (patch)
treea2a25371c0c1c80f69563341730b2daf52a1b722
parentf9d590b533821d9c967a71f48237cac26bd3fd04 (diff)
parent020824813ae20c4278369ed76b1f15a8398f6411 (diff)
Merge pull request #24314 from 78andyp/fix_BDMV_scrape
[VideoInfoScanner] Fix scraping of episodes in Blu-ray folders (BDMV).
-rw-r--r--xbmc/video/VideoInfoScanner.cpp68
1 files changed, 34 insertions, 34 deletions
diff --git a/xbmc/video/VideoInfoScanner.cpp b/xbmc/video/VideoInfoScanner.cpp
index a1e573780f..aca4162fd5 100644
--- a/xbmc/video/VideoInfoScanner.cpp
+++ b/xbmc/video/VideoInfoScanner.cpp
@@ -1078,42 +1078,42 @@ namespace VIDEO
// since we're doing this now anyway, should other items be stacked?
items.Sort(SortByPath, SortOrderAscending);
- int x = 0;
- while (x < items.Size())
- {
- if (items[x]->m_bIsFolder)
- {
- x++;
- continue;
- }
- std::string strPathX, strFileX;
- URIUtils::Split(items[x]->GetPath(), strPathX, strFileX);
- //CLog::Log(LOGDEBUG,"{}:{}:{}", x, strPathX, strFileX);
+ // If found VIDEO_TS.IFO or INDEX.BDMV then we are dealing with Blu-ray or DVD files on disc
+ // somewhere in the directory tree. Assume that all other files/folders in the same folder
+ // with VIDEO_TS or BDMV can be ignored.
+ // THere can be a BACKUP/INDEX.BDMV which needs to be ignored (and broke the old while loop here)
- const int y = x + 1;
- if (StringUtils::EqualsNoCase(strFileX, "VIDEO_TS.IFO"))
- {
- while (y < items.Size())
- {
- std::string strPathY, strFileY;
- URIUtils::Split(items[y]->GetPath(), strPathY, strFileY);
- //CLog::Log(LOGDEBUG," {}:{}:{}", y, strPathY, strFileY);
-
- if (StringUtils::EqualsNoCase(strPathY, strPathX))
- /*
- remove everything sorted below the video_ts.ifo file in the same path.
- understandably this wont stack correctly if there are other files in the the dvd folder.
- this should be unlikely and thus is being ignored for now but we can monitor the
- where the path changes and potentially remove the items above the video_ts.ifo file.
- */
- items.Remove(y);
- else
- break;
- }
- }
- x++;
- }
+ // Get folders to remove
+ std::vector<std::string> foldersToRemove;
+ for (const auto& item : items)
+ {
+ const std::string file = StringUtils::ToUpper(item->GetPath());
+ if (file.find("VIDEO_TS.IFO") != std::string::npos)
+ foldersToRemove.emplace_back(StringUtils::ToUpper(URIUtils::GetDirectory(file)));
+ if (file.find("INDEX.BDMV") != std::string::npos &&
+ file.find("BACKUP/INDEX.BDMV") == std::string::npos)
+ foldersToRemove.emplace_back(
+ StringUtils::ToUpper(URIUtils::GetParentPath(URIUtils::GetDirectory(file))));
+ }
+
+ // Remove folders
+ items.erase(
+ std::remove_if(items.begin(), items.end(),
+ [&](const CFileItemPtr& i)
+ {
+ const std::string fileAndPath(StringUtils::ToUpper(i->GetPath()));
+ std::string file;
+ std::string path;
+ URIUtils::Split(fileAndPath, path, file);
+ return (std::count_if(foldersToRemove.begin(), foldersToRemove.end(),
+ [&](const std::string& removePath)
+ { return path.rfind(removePath, 0) == 0; }) > 0) &&
+ file != "VIDEO_TS.IFO" &&
+ (file != "INDEX.BDMV" ||
+ fileAndPath.find("BACKUP/INDEX.BDMV") != std::string::npos);
+ }),
+ items.end());
// enumerate
for (int i=0;i<items.Size();++i)