aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Sundermann <stephansundermann@gmail.com>2023-12-08 00:29:07 +0100
committerGitHub <noreply@github.com>2023-12-08 00:29:07 +0100
commitff07dd77605fdd30c6e8fe26730b356b2b808a97 (patch)
tree9e5916bcfbd615ebc14d8c22e576bedaa793c730
parent448b7a4e3d33aa5e2648d673d176d09c9c4326aa (diff)
parent8d4852b925aff4f0023c6a36ab5e3d6c5339d14d (diff)
Merge pull request #23840 from webosbrew/scraper-filename-identifiers
[Scraper] Support for filename identifiers
-rw-r--r--xbmc/Util.cpp46
-rw-r--r--xbmc/Util.h7
-rw-r--r--xbmc/addons/Scraper.cpp60
-rw-r--r--xbmc/addons/Scraper.h7
-rw-r--r--xbmc/settings/AdvancedSettings.cpp2
-rw-r--r--xbmc/settings/AdvancedSettings.h1
-rw-r--r--xbmc/test/TestUtil.cpp17
-rw-r--r--xbmc/video/VideoInfoDownloader.cpp14
-rw-r--r--xbmc/video/VideoInfoDownloader.h6
-rw-r--r--xbmc/video/VideoInfoScanner.cpp94
-rw-r--r--xbmc/video/VideoInfoScanner.h7
11 files changed, 222 insertions, 39 deletions
diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp
index a94c1d16a5..8a6bae30da 100644
--- a/xbmc/Util.cpp
+++ b/xbmc/Util.cpp
@@ -435,6 +435,46 @@ std::string CUtil::GetDiscNumberFromPath(const std::string& path)
return discNum;
}
+bool CUtil::GetFilenameIdentifier(const std::string& fileName,
+ std::string& identifierType,
+ std::string& identifier)
+{
+ std::string match;
+ return GetFilenameIdentifier(fileName, identifierType, identifier, match);
+}
+
+bool CUtil::GetFilenameIdentifier(const std::string& fileName,
+ std::string& identifierType,
+ std::string& identifier,
+ std::string& match)
+{
+ CRegExp reIdentifier(true, CRegExp::autoUtf8);
+
+ const std::shared_ptr<CAdvancedSettings> advancedSettings =
+ CServiceBroker::GetSettingsComponent()->GetAdvancedSettings();
+ if (!reIdentifier.RegComp(advancedSettings->m_videoFilenameIdentifierRegExp))
+ {
+ CLog::LogF(LOGERROR, "Invalid filename identifier RegExp:'{}'",
+ advancedSettings->m_videoFilenameIdentifierRegExp);
+ return false;
+ }
+ else
+ {
+ if (reIdentifier.RegComp(advancedSettings->m_videoFilenameIdentifierRegExp))
+ {
+ if (reIdentifier.RegFind(fileName) >= 0)
+ {
+ match = reIdentifier.GetMatch(0);
+ identifierType = reIdentifier.GetMatch(1);
+ identifier = reIdentifier.GetMatch(2);
+ StringUtils::ToLower(identifierType);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
void CUtil::CleanString(const std::string& strFileName,
std::string& strTitle,
std::string& strTitleAndYear,
@@ -447,6 +487,12 @@ void CUtil::CleanString(const std::string& strFileName,
if (strFileName == "..")
return;
+ std::string identifier;
+ std::string identifierType;
+ std::string identifierMatch;
+ if (GetFilenameIdentifier(strFileName, identifierType, identifier, identifierMatch))
+ StringUtils::Replace(strTitleAndYear, identifierMatch, "");
+
const std::shared_ptr<CAdvancedSettings> advancedSettings = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings();
const std::vector<std::string> &regexps = advancedSettings->m_videoCleanStringRegExps;
diff --git a/xbmc/Util.h b/xbmc/Util.h
index 44991514f5..b93df4c3c8 100644
--- a/xbmc/Util.h
+++ b/xbmc/Util.h
@@ -43,6 +43,13 @@ public:
std::string& strYear,
bool bRemoveExtension = false,
bool bCleanChars = true);
+ static bool GetFilenameIdentifier(const std::string& fileName,
+ std::string& identifierType,
+ std::string& identifier);
+ static bool GetFilenameIdentifier(const std::string& fileName,
+ std::string& identifierType,
+ std::string& identifier,
+ std::string& match);
static std::string GetTitleFromPath(const CURL& url, bool bIsFolder = false);
static std::string GetTitleFromPath(const std::string& strFileNameAndPath, bool bIsFolder = false);
diff --git a/xbmc/addons/Scraper.cpp b/xbmc/addons/Scraper.cpp
index ad7b251052..66cedcb969 100644
--- a/xbmc/addons/Scraper.cpp
+++ b/xbmc/addons/Scraper.cpp
@@ -30,6 +30,7 @@
#include "settings/SettingsComponent.h"
#include "settings/SettingsValueFlatJsonSerializer.h"
#include "utils/CharsetConverter.h"
+#include "utils/JSONVariantWriter.h"
#include "utils/ScraperParser.h"
#include "utils/ScraperUrl.h"
#include "utils/StringUtils.h"
@@ -731,10 +732,10 @@ static std::string ParseFanart(const CFileItem &item, int nFanart, const std::st
}
template<class T>
-static void DetailsFromFileItem(const CFileItem &, T &);
+static bool DetailsFromFileItem(const CFileItem&, T&);
template<>
-void DetailsFromFileItem<CAlbum>(const CFileItem &item, CAlbum &album)
+bool DetailsFromFileItem<CAlbum>(const CFileItem& item, CAlbum& album)
{
album.strAlbum = item.GetLabel();
album.strMusicBrainzAlbumID = FromString(item, "album.musicbrainzid");
@@ -777,10 +778,11 @@ void DetailsFromFileItem<CAlbum>(const CFileItem &item, CAlbum &album)
int nThumbs = item.GetProperty("album.thumbs").asInteger32();
ParseThumbs(album.thumbURL, item, nThumbs, "album.thumb");
+ return true;
}
template<>
-void DetailsFromFileItem<CArtist>(const CFileItem &item, CArtist &artist)
+bool DetailsFromFileItem<CArtist>(const CFileItem& item, CArtist& artist)
{
artist.strArtist = item.GetLabel();
artist.strMusicBrainzArtistID = FromString(item, "artist.musicbrainzid");
@@ -846,34 +848,58 @@ void DetailsFromFileItem<CArtist>(const CFileItem &item, CArtist &artist)
for (unsigned int i = 0; i < fanart.GetNumFanarts(); i++)
artist.thumbURL.AddParsedUrl(fanart.GetImageURL(i), "fanart", fanart.GetPreviewURL(i));
}
+ return true;
}
template<>
-void DetailsFromFileItem<CVideoInfoTag>(const CFileItem &item, CVideoInfoTag &tag)
+bool DetailsFromFileItem<CVideoInfoTag>(const CFileItem& item, CVideoInfoTag& tag)
{
if (item.HasVideoInfoTag())
+ {
tag = *item.GetVideoInfoTag();
+ return true;
+ }
+ return false;
}
template<class T>
-static bool PythonDetails(const std::string &ID,
- const std::string &key,
- const std::string &url,
- const std::string &action,
- const std::string &pathSettings,
- T &result)
+static bool PythonDetails(const std::string& ID,
+ const std::string& key,
+ const std::string& url,
+ const std::string& action,
+ const std::string& pathSettings,
+ const std::unordered_map<std::string, std::string>& uniqueIDs,
+ T& result)
{
+ CVariant ids;
+ for (const auto& [identifierType, identifier] : uniqueIDs)
+ ids[identifierType] = identifier;
+ std::string uids;
+ CJSONVariantWriter::Write(ids, uids, true);
std::stringstream str;
str << "plugin://" << ID << "?action=" << action << "&" << key << "=" << CURL::Encode(url);
str << "&pathSettings=" << CURL::Encode(pathSettings);
+ if (!uniqueIDs.empty())
+ str << "&uniqueIDs=" << CURL::Encode(uids);
CFileItem item(url, false);
if (!XFILE::CPluginDirectory::GetPluginResult(str.str(), item, false))
return false;
- DetailsFromFileItem(item, result);
- return true;
+ return DetailsFromFileItem(item, result);
+}
+
+template<class T>
+static bool PythonDetails(const std::string& ID,
+ const std::string& key,
+ const std::string& url,
+ const std::string& action,
+ const std::string& pathSettings,
+ T& result)
+{
+ const std::unordered_map<std::string, std::string> ids;
+ return PythonDetails(ID, key, url, action, pathSettings, ids, result);
}
// fetch list of matching movies sorted by relevance (may be empty);
@@ -1324,10 +1350,11 @@ EPISODELIST CScraper::GetEpisodeList(XFILE::CCurlFile &fcurl, const CScraperUrl
}
// takes URL; returns true and populates video details on success, false otherwise
-bool CScraper::GetVideoDetails(XFILE::CCurlFile &fcurl,
- const CScraperUrl &scurl,
+bool CScraper::GetVideoDetails(XFILE::CCurlFile& fcurl,
+ const std::unordered_map<std::string, std::string>& uniqueIDs,
+ const CScraperUrl& scurl,
bool fMovie /*else episode*/,
- CVideoInfoTag &video)
+ CVideoInfoTag& video)
{
CLog::Log(LOGDEBUG,
"{}: Reading {} '{}' using {} scraper "
@@ -1339,7 +1366,8 @@ bool CScraper::GetVideoDetails(XFILE::CCurlFile &fcurl,
if (m_isPython)
return PythonDetails(ID(), "url", scurl.GetFirstThumbUrl(),
- fMovie ? "getdetails" : "getepisodedetails", GetPathSettingsAsJSON(), video);
+ fMovie ? "getdetails" : "getepisodedetails", GetPathSettingsAsJSON(),
+ uniqueIDs, video);
std::string sFunc = fMovie ? "GetDetails" : "GetEpisodeDetails";
std::vector<std::string> vcsIn;
diff --git a/xbmc/addons/Scraper.h b/xbmc/addons/Scraper.h
index 62b0d38139..93d34be3d8 100644
--- a/xbmc/addons/Scraper.h
+++ b/xbmc/addons/Scraper.h
@@ -131,8 +131,11 @@ public:
XFILE::CCurlFile &fcurl, const std::string &sArtist);
VIDEO::EPISODELIST GetEpisodeList(XFILE::CCurlFile &fcurl, const CScraperUrl &scurl);
- bool GetVideoDetails(XFILE::CCurlFile &fcurl, const CScraperUrl &scurl,
- bool fMovie/*else episode*/, CVideoInfoTag &video);
+ bool GetVideoDetails(XFILE::CCurlFile& fcurl,
+ const std::unordered_map<std::string, std::string>& uniqueIDs,
+ const CScraperUrl& scurl,
+ bool fMovie /*else episode*/,
+ CVideoInfoTag& video);
bool GetAlbumDetails(XFILE::CCurlFile &fcurl, const CScraperUrl &scurl,
CAlbum &album);
bool GetArtistDetails(XFILE::CCurlFile &fcurl, const CScraperUrl &scurl,
diff --git a/xbmc/settings/AdvancedSettings.cpp b/xbmc/settings/AdvancedSettings.cpp
index bae673d187..85cba8597a 100644
--- a/xbmc/settings/AdvancedSettings.cpp
+++ b/xbmc/settings/AdvancedSettings.cpp
@@ -195,6 +195,7 @@ void CAdvancedSettings::Initialize()
m_fullScreenOnMovieStart = true;
m_cachePath = "special://temp/";
+ m_videoFilenameIdentifierRegExp = R"([\{\[](\w+?)(?:id)?[-=](\w+)[\}|\]])";
m_videoCleanDateTimeRegExp = "(.*[^ _\\,\\.\\(\\)\\[\\]\\-])[ _\\.\\(\\)\\[\\]\\-]+(19[0-9][0-9]|20[0-9][0-9])([ _\\,\\.\\(\\)\\[\\]\\-]|[^0-9]$)?";
m_videoCleanStringRegExps.clear();
@@ -632,6 +633,7 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file)
if (pVideoExcludes)
GetCustomRegexps(pVideoExcludes, m_videoCleanStringRegExps);
+ XMLUtils::GetString(pElement, "filenameidentifier", m_videoFilenameIdentifierRegExp);
XMLUtils::GetString(pElement,"cleandatetime", m_videoCleanDateTimeRegExp);
XMLUtils::GetString(pElement,"ppffmpegpostprocessing",m_videoPPFFmpegPostProc);
XMLUtils::GetInt(pElement,"vdpauscaling",m_videoVDPAUScaling);
diff --git a/xbmc/settings/AdvancedSettings.h b/xbmc/settings/AdvancedSettings.h
index b972933b29..a18e7aaacf 100644
--- a/xbmc/settings/AdvancedSettings.h
+++ b/xbmc/settings/AdvancedSettings.h
@@ -199,6 +199,7 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler
bool m_fullScreenOnMovieStart;
std::string m_cachePath;
std::string m_videoCleanDateTimeRegExp;
+ std::string m_videoFilenameIdentifierRegExp;
std::vector<std::string> m_videoCleanStringRegExps;
std::vector<std::string> m_videoExcludeFromListingRegExps;
std::vector<std::string> m_allExcludeFromScanRegExps;
diff --git a/xbmc/test/TestUtil.cpp b/xbmc/test/TestUtil.cpp
index 6215b9356e..57767ea67f 100644
--- a/xbmc/test/TestUtil.cpp
+++ b/xbmc/test/TestUtil.cpp
@@ -97,6 +97,8 @@ struct TestUtilCleanStringData
std::string expTitle;
std::string expTitleYear;
std::string expYear;
+ std::string expIdentifierType{};
+ std::string expIdentifier{};
};
std::ostream& operator<<(std::ostream& os, const TestUtilCleanStringData& rhs)
@@ -110,6 +112,15 @@ class TestUtilCleanString : public Test, public WithParamInterface<TestUtilClean
{
};
+TEST_P(TestUtilCleanString, GetFilenameIdentifier)
+{
+ std::string identifierType;
+ std::string identifier;
+ CUtil::GetFilenameIdentifier(GetParam().input, identifierType, identifier);
+ EXPECT_EQ(identifierType, GetParam().expIdentifierType);
+ EXPECT_EQ(identifier, GetParam().expIdentifier);
+}
+
TEST_P(TestUtilCleanString, CleanString)
{
std::string title, titleYear, year;
@@ -131,6 +142,12 @@ const TestUtilCleanStringData values[] = {
{"Some.Movie.1954.BDRip.1080p.mkv", true, "Some Movie", "Some Movie (1954)", "1954"},
{"Some «Movie».2021.WEB-DL.2160p.HDR.mkv", true, "Some «Movie»", "Some «Movie» (2021)", "2021"},
{"Some Movie (2013).mp4", true, "Some Movie", "Some Movie (2013)", "2013"},
+ {"Some Movie (2013) [imdbid-tt123].mp4", true, "Some Movie", "Some Movie (2013)", "2013",
+ "imdb", "tt123"},
+ {"Some Movie (2013) {tmdb-123}.mp4", true, "Some Movie", "Some Movie (2013)", "2013", "tmdb",
+ "123"},
+ {"Some Movie (2013) {tmdb=123}.mp4", true, "Some Movie", "Some Movie (2013)", "2013", "tmdb",
+ "123"},
// no result because of the text (Director Cut), it can also a be a movie translation
{"Some (Director Cut).BDRemux.mkv", true, "Some (Director Cut)", "Some (Director Cut)", ""}};
diff --git a/xbmc/video/VideoInfoDownloader.cpp b/xbmc/video/VideoInfoDownloader.cpp
index 5d0fb1f1b7..cd0a1d850d 100644
--- a/xbmc/video/VideoInfoDownloader.cpp
+++ b/xbmc/video/VideoInfoDownloader.cpp
@@ -80,7 +80,7 @@ void CVideoInfoDownloader::Process()
}
else if (m_state == GET_DETAILS)
{
- if (!GetDetails(m_url, m_movieDetails))
+ if (!GetDetails(m_uniqueIDs, m_url, m_movieDetails))
CLog::Log(LOGERROR, "{}: Error getting details from {}", __FUNCTION__,
m_url.GetFirstThumbUrl());
}
@@ -147,12 +147,14 @@ bool CVideoInfoDownloader::GetArtwork(CVideoInfoTag &details)
return m_info->GetArtwork(*m_http, details);
}
-bool CVideoInfoDownloader::GetDetails(const CScraperUrl &url,
- CVideoInfoTag &movieDetails,
- CGUIDialogProgress *pProgress /* = NULL */)
+bool CVideoInfoDownloader::GetDetails(const std::unordered_map<std::string, std::string>& uniqueIDs,
+ const CScraperUrl& url,
+ CVideoInfoTag& movieDetails,
+ CGUIDialogProgress* pProgress /* = NULL */)
{
//CLog::Log(LOGDEBUG,"CVideoInfoDownloader::GetDetails({})", url.m_strURL);
m_url = url;
+ m_uniqueIDs = uniqueIDs;
m_movieDetails = movieDetails;
// fill in the defaults
@@ -179,7 +181,7 @@ bool CVideoInfoDownloader::GetDetails(const CScraperUrl &url,
return true;
}
else // unthreaded
- return m_info->GetVideoDetails(*m_http, url, true/*fMovie*/, movieDetails);
+ return m_info->GetVideoDetails(*m_http, m_uniqueIDs, url, true /*fMovie*/, movieDetails);
}
bool CVideoInfoDownloader::GetEpisodeDetails(const CScraperUrl &url,
@@ -214,7 +216,7 @@ bool CVideoInfoDownloader::GetEpisodeDetails(const CScraperUrl &url,
return true;
}
else // unthreaded
- return m_info->GetVideoDetails(*m_http, url, false/*fMovie*/, movieDetails);
+ return m_info->GetVideoDetails(*m_http, m_uniqueIDs, url, false /*fMovie*/, movieDetails);
}
bool CVideoInfoDownloader::GetEpisodeList(const CScraperUrl& url,
diff --git a/xbmc/video/VideoInfoDownloader.h b/xbmc/video/VideoInfoDownloader.h
index a85603fe06..4479522a33 100644
--- a/xbmc/video/VideoInfoDownloader.h
+++ b/xbmc/video/VideoInfoDownloader.h
@@ -54,7 +54,10 @@ public:
*/
bool GetArtwork(CVideoInfoTag &details);
- bool GetDetails(const CScraperUrl& url, CVideoInfoTag &movieDetails, CGUIDialogProgress *pProgress = NULL);
+ bool GetDetails(const std::unordered_map<std::string, std::string>& uniqueIDs,
+ const CScraperUrl& url,
+ CVideoInfoTag& movieDetails,
+ CGUIDialogProgress* pProgress = NULL);
bool GetEpisodeDetails(const CScraperUrl& url, CVideoInfoTag &movieDetails, CGUIDialogProgress *pProgress = NULL);
bool GetEpisodeList(const CScraperUrl& url, VIDEO::EPISODELIST& details, CGUIDialogProgress *pProgress = NULL);
@@ -70,6 +73,7 @@ protected:
XFILE::CCurlFile* m_http;
std::string m_movieTitle;
int m_movieYear;
+ std::unordered_map<std::string, std::string> m_uniqueIDs;
MOVIELIST m_movieList;
CVideoInfoTag m_movieDetails;
CScraperUrl m_url;
diff --git a/xbmc/video/VideoInfoScanner.cpp b/xbmc/video/VideoInfoScanner.cpp
index f1fcf6d4df..e70b1ee0a1 100644
--- a/xbmc/video/VideoInfoScanner.cpp
+++ b/xbmc/video/VideoInfoScanner.cpp
@@ -654,6 +654,35 @@ namespace VIDEO
movieTitle = tag->GetTitle();
movieYear = tag->GetYear(); // movieYear is expected to be >= 0
}
+
+ std::string identifierType;
+ std::string identifier;
+ long lResult = -1;
+ if (info2->IsPython() && CUtil::GetFilenameIdentifier(movieTitle, identifierType, identifier))
+ {
+ const std::unordered_map<std::string, std::string> uniqueIDs{{identifierType, identifier}};
+ if (GetDetails(pItem, uniqueIDs, url, info2,
+ (result == CInfoScanner::COMBINED_NFO || result == CInfoScanner::OVERRIDE_NFO)
+ ? loader.get()
+ : nullptr,
+ pDlgProgress))
+ {
+ if ((lResult = AddVideo(pItem, info2->Content(), false, useLocal)) < 0)
+ return INFO_ERROR;
+
+ if (fetchEpisodes)
+ {
+ INFO_RET ret = RetrieveInfoForEpisodes(pItem, lResult, info2, useLocal, pDlgProgress);
+ if (ret == INFO_ADDED)
+ {
+ m_database.SetPathHash(pItem->GetPath(), pItem->GetProperty("hash").asString());
+ return INFO_ADDED;
+ }
+ }
+ return INFO_ADDED;
+ }
+ }
+
if (pURL && pURL->HasUrls())
url = *pURL;
else if ((retVal = FindVideo(movieTitle, movieYear, info2, url, pDlgProgress)) <= 0)
@@ -661,11 +690,12 @@ namespace VIDEO
CLog::Log(LOGDEBUG, "VideoInfoScanner: Fetching url '{}' using {} scraper (content: '{}')",
url.GetFirstThumbUrl(), info2->Name(), TranslateContent(info2->Content()));
+ const std::unordered_map<std::string, std::string> uniqueIDs{{identifierType, identifier}};
- long lResult = -1;
- if (GetDetails(pItem, url, info2,
- (result == CInfoScanner::COMBINED_NFO ||
- result == CInfoScanner::OVERRIDE_NFO) ? loader.get() : nullptr,
+ if (GetDetails(pItem, {}, url, info2,
+ (result == CInfoScanner::COMBINED_NFO || result == CInfoScanner::OVERRIDE_NFO)
+ ? loader.get()
+ : nullptr,
pDlgProgress))
{
if ((lResult = AddVideo(pItem, info2->Content(), false, useLocal)) < 0)
@@ -736,6 +766,24 @@ namespace VIDEO
movieTitle = tag->GetTitle();
movieYear = tag->GetYear(); // movieYear is expected to be >= 0
}
+
+ std::string identifierType;
+ std::string identifier;
+ if (info2->IsPython() && CUtil::GetFilenameIdentifier(movieTitle, identifierType, identifier))
+ {
+ const std::unordered_map<std::string, std::string> uniqueIDs{{identifierType, identifier}};
+ if (GetDetails(pItem, uniqueIDs, url, info2,
+ (result == CInfoScanner::COMBINED_NFO || result == CInfoScanner::OVERRIDE_NFO)
+ ? loader.get()
+ : nullptr,
+ pDlgProgress))
+ {
+ if (AddVideo(pItem, info2->Content(), bDirNames, useLocal) < 0)
+ return INFO_ERROR;
+ return INFO_ADDED;
+ }
+ }
+
if (pURL && pURL->HasUrls())
url = *pURL;
else if ((retVal = FindVideo(movieTitle, movieYear, info2, url, pDlgProgress)) <= 0)
@@ -744,9 +792,10 @@ namespace VIDEO
CLog::Log(LOGDEBUG, "VideoInfoScanner: Fetching url '{}' using {} scraper (content: '{}')",
url.GetFirstThumbUrl(), info2->Name(), TranslateContent(info2->Content()));
- if (GetDetails(pItem, url, info2,
- (result == CInfoScanner::COMBINED_NFO ||
- result == CInfoScanner::OVERRIDE_NFO) ? loader.get() : nullptr,
+ if (GetDetails(pItem, {}, url, info2,
+ (result == CInfoScanner::COMBINED_NFO || result == CInfoScanner::OVERRIDE_NFO)
+ ? loader.get()
+ : nullptr,
pDlgProgress))
{
int dbId = AddVideo(pItem, info2->Content(), bDirNames, useLocal);
@@ -817,6 +866,24 @@ namespace VIDEO
movieTitle = tag->GetTitle();
movieYear = tag->GetYear(); // movieYear is expected to be >= 0
}
+
+ std::string identifierType;
+ std::string identifier;
+ if (info2->IsPython() && CUtil::GetFilenameIdentifier(movieTitle, identifierType, identifier))
+ {
+ const std::unordered_map<std::string, std::string> uniqueIDs{{identifierType, identifier}};
+ if (GetDetails(pItem, uniqueIDs, url, info2,
+ (result == CInfoScanner::COMBINED_NFO || result == CInfoScanner::OVERRIDE_NFO)
+ ? loader.get()
+ : nullptr,
+ pDlgProgress))
+ {
+ if (AddVideo(pItem, info2->Content(), bDirNames, useLocal) < 0)
+ return INFO_ERROR;
+ return INFO_ADDED;
+ }
+ }
+
if (pURL && pURL->HasUrls())
url = *pURL;
else if ((retVal = FindVideo(movieTitle, movieYear, info2, url, pDlgProgress)) <= 0)
@@ -825,9 +892,10 @@ namespace VIDEO
CLog::Log(LOGDEBUG, "VideoInfoScanner: Fetching url '{}' using {} scraper (content: '{}')",
url.GetFirstThumbUrl(), info2->Name(), TranslateContent(info2->Content()));
- if (GetDetails(pItem, url, info2,
- (result == CInfoScanner::COMBINED_NFO ||
- result == CInfoScanner::OVERRIDE_NFO) ? loader.get() : nullptr,
+ if (GetDetails(pItem, {}, url, info2,
+ (result == CInfoScanner::COMBINED_NFO || result == CInfoScanner::OVERRIDE_NFO)
+ ? loader.get()
+ : nullptr,
pDlgProgress))
{
if (AddVideo(pItem, info2->Content(), bDirNames, useLocal) < 0)
@@ -2031,7 +2099,9 @@ namespace VIDEO
return INFO_ADDED;
}
- bool CVideoInfoScanner::GetDetails(CFileItem *pItem, CScraperUrl &url,
+ bool CVideoInfoScanner::GetDetails(CFileItem* pItem,
+ const std::unordered_map<std::string, std::string>& uniqueIDs,
+ CScraperUrl& url,
const ScraperPtr& scraper,
IVideoInfoTagLoader* loader,
CGUIDialogProgress* pDialog /* = NULL */)
@@ -2042,7 +2112,7 @@ namespace VIDEO
m_handle->SetText(url.GetTitle());
CVideoInfoDownloader imdb(scraper);
- bool ret = imdb.GetDetails(url, movieDetails, pDialog);
+ bool ret = imdb.GetDetails(uniqueIDs, url, movieDetails, pDialog);
if (ret)
{
diff --git a/xbmc/video/VideoInfoScanner.h b/xbmc/video/VideoInfoScanner.h
index ba24585b59..9f49103be7 100644
--- a/xbmc/video/VideoInfoScanner.h
+++ b/xbmc/video/VideoInfoScanner.h
@@ -144,14 +144,17 @@ namespace VIDEO
/*! \brief Retrieve detailed information for an item from an online source, optionally supplemented with local data
@todo sort out some better return codes.
\param pItem item to retrieve online details for.
+ \param uniqueIDs Unique IDs for additional information for scrapers.
\param url URL to use to retrieve online details.
\param scraper Scraper that handles parsing the online data.
\param nfoFile if set, we override the online data with the locally supplied data. Defaults to NULL.
\param pDialog progress dialog to update and check for cancellation during processing. Defaults to NULL.
\return true if information is found, false if an error occurred, the lookup was cancelled, or no information was found.
*/
- bool GetDetails(CFileItem *pItem, CScraperUrl &url,
- const ADDON::ScraperPtr &scraper,
+ bool GetDetails(CFileItem* pItem,
+ const std::unordered_map<std::string, std::string>& uniqueIDs,
+ CScraperUrl& url,
+ const ADDON::ScraperPtr& scraper,
VIDEO::IVideoInfoTagLoader* nfoFile = nullptr,
CGUIDialogProgress* pDialog = nullptr);