Permalink
Browse files

Merge pull request #895 from Montellese/import_resume

add resume point to database if available (e.g. in <resume> from an NFO)
  • Loading branch information...
2 parents 33cc54d + 894f4c3 commit 5840e982805b9674901a3e3855fc59e88b7add54 @Montellese Montellese committed Jun 1, 2012
@@ -215,6 +215,7 @@ void CAdvancedSettings::Initialize()
m_bVideoLibraryCleanOnUpdate = false;
m_bVideoLibraryExportAutoThumbs = false;
m_bVideoLibraryImportWatchedState = false;
+ m_bVideoLibraryImportResumePoint = false;
m_bVideoScannerIgnoreErrors = false;
m_iTuxBoxStreamtsPort = 31339;
@@ -618,6 +619,7 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file)
XMLUtils::GetString(pElement, "itemseparator", m_videoItemSeparator);
XMLUtils::GetBoolean(pElement, "exportautothumbs", m_bVideoLibraryExportAutoThumbs);
XMLUtils::GetBoolean(pElement, "importwatchedstate", m_bVideoLibraryImportWatchedState);
+ XMLUtils::GetBoolean(pElement, "importresumepoint", m_bVideoLibraryImportResumePoint);
}
pElement = pRootElement->FirstChildElement("videoscanner");
@@ -238,6 +238,7 @@ class CAdvancedSettings
bool m_bVideoLibraryCleanOnUpdate;
bool m_bVideoLibraryExportAutoThumbs;
bool m_bVideoLibraryImportWatchedState;
+ bool m_bVideoLibraryImportResumePoint;
bool m_bVideoScannerIgnoreErrors;
@@ -7909,8 +7909,7 @@ void CVideoDatabase::ImportFromXML(const CStdString &path)
if (ImportArtFromXML(movie->FirstChild("art"), artwork))
item.SetArt(artwork);
bool useFolders = info.m_basePath.IsEmpty() ? LookupByFolders(item.GetPath()) : false;
- scanner.AddVideo(&item, CONTENT_MOVIES, useFolders);
- SetPlayCount(item, info.m_playCount, info.m_lastPlayed);
+ scanner.AddVideo(&item, CONTENT_MOVIES, useFolders, true, -1, true);
CStdString strFileName(info.m_strTitle);
if (iVersion >= 1 && info.m_iYear > 0)
strFileName.AppendFormat("_%i", info.m_iYear);
@@ -7924,8 +7923,7 @@ void CVideoDatabase::ImportFromXML(const CStdString &path)
if (ImportArtFromXML(movie->FirstChild("art"), artwork))
item.SetArt(artwork);
bool useFolders = info.m_basePath.IsEmpty() ? LookupByFolders(item.GetPath()) : false;
- scanner.AddVideo(&item, CONTENT_MUSICVIDEOS, useFolders);
- SetPlayCount(item, info.m_playCount, info.m_lastPlayed);
+ scanner.AddVideo(&item, CONTENT_MUSICVIDEOS, useFolders, true, -1, true);
CStdString strFileName(StringUtils::Join(info.m_artist, g_advancedSettings.m_videoItemSeparator) + "." + info.m_strTitle);
if (iVersion >= 1 && info.m_iYear > 0)
strFileName.AppendFormat("_%i", info.m_iYear);
@@ -7943,7 +7941,7 @@ void CVideoDatabase::ImportFromXML(const CStdString &path)
if (ImportArtFromXML(movie->FirstChild("art"), artwork))
item.SetArt(artwork);
bool useFolders = info.m_basePath.IsEmpty() ? LookupByFolders(item.GetPath(), true) : false;
- int showID = scanner.AddVideo(&item, CONTENT_TVSHOWS, useFolders);
+ int showID = scanner.AddVideo(&item, CONTENT_TVSHOWS, useFolders, true, -1, true);
// season artwork
TiXmlNode *art = movie->FirstChild("art");
if (art)
@@ -7976,8 +7974,7 @@ void CVideoDatabase::ImportFromXML(const CStdString &path)
map<string, string> artwork;
if (ImportArtFromXML(movie->FirstChild("art"), artwork))
item.SetArt(artwork);
- scanner.AddVideo(&item,CONTENT_TVSHOWS,false,false,showID);
- SetPlayCount(item, info.m_playCount, info.m_lastPlayed);
+ scanner.AddVideo(&item,CONTENT_TVSHOWS, false, false, showID, true);
episode = episode->NextSiblingElement("episodedetails");
}
}
@@ -1011,7 +1011,7 @@ namespace VIDEO
return episodeInfo.cDate.IsValid();
}
- long CVideoInfoScanner::AddVideo(CFileItem *pItem, const CONTENT_TYPE &content, bool videoFolder, bool useLocal, int idShow)
+ long CVideoInfoScanner::AddVideo(CFileItem *pItem, const CONTENT_TYPE &content, bool videoFolder /* = false */, bool useLocal /* = true */, int idShow /* = -1 */, bool libraryImport /* = false */)
{
// ensure our database is open (this can get called via other classes)
if (!m_database.Open())
@@ -1102,9 +1102,13 @@ namespace VIDEO
movieDetails.m_iDbId = lResult;
}
- if (g_advancedSettings.m_bVideoLibraryImportWatchedState)
+ if (g_advancedSettings.m_bVideoLibraryImportWatchedState || libraryImport)
m_database.SetPlayCount(*pItem, movieDetails.m_playCount, movieDetails.m_lastPlayed);
+ if ((g_advancedSettings.m_bVideoLibraryImportResumePoint || libraryImport) &&
+ movieDetails.m_resumePoint.timeInSeconds > 0.0f && movieDetails.m_resumePoint.totalTimeInSeconds > 0.0f)
+ m_database.AddBookMarkToFile(pItem->GetPath(), movieDetails.m_resumePoint, CBookmark::EType::RESUME);
+
m_database.Close();
CFileItemPtr itemCopy = CFileItemPtr(new CFileItem(*pItem));
@@ -98,9 +98,10 @@ namespace VIDEO
\param videoFolder whether the video is represented by a folder (single movie per folder). Defaults to false.
\param useLocal whether to use local information for artwork etc.
\param idShow database id of the tvshow if we're adding an episode. Defaults to -1.
+ \param libraryImport Whether this call belongs to a full library import or not. Defaults to false.
\return database id of the added item, or -1 on failure.
*/
- long AddVideo(CFileItem *pItem, const CONTENT_TYPE &content, bool videoFolder = false, bool useLocal = true, int idShow = -1);
+ long AddVideo(CFileItem *pItem, const CONTENT_TYPE &content, bool videoFolder = false, bool useLocal = true, int idShow = -1, bool libraryImport = false);
/*! \brief Retrieve information for a list of items and add them to the database.
\param items list of items to retrieve info for.

0 comments on commit 5840e98

Please sign in to comment.