Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add resume point to database if available (e.g. in <resume> from an NFO) #895

Merged
merged 1 commit into from
Jun 1, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions xbmc/settings/AdvancedSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ void CAdvancedSettings::Initialize()
m_bVideoLibraryCleanOnUpdate = false;
m_bVideoLibraryExportAutoThumbs = false;
m_bVideoLibraryImportWatchedState = false;
m_bVideoLibraryImportResumePoint = false;
m_bVideoScannerIgnoreErrors = false;

m_iTuxBoxStreamtsPort = 31339;
Expand Down Expand Up @@ -616,6 +617,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");
Expand Down
1 change: 1 addition & 0 deletions xbmc/settings/AdvancedSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class CAdvancedSettings
bool m_bVideoLibraryCleanOnUpdate;
bool m_bVideoLibraryExportAutoThumbs;
bool m_bVideoLibraryImportWatchedState;
bool m_bVideoLibraryImportResumePoint;

bool m_bVideoScannerIgnoreErrors;

Expand Down
11 changes: 4 additions & 7 deletions xbmc/video/VideoDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7905,8 +7905,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);
Expand All @@ -7920,8 +7919,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);
Expand All @@ -7939,7 +7937,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)
Expand Down Expand Up @@ -7972,8 +7970,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");
}
}
Expand Down
8 changes: 6 additions & 2 deletions xbmc/video/VideoInfoScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,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())
Expand Down Expand Up @@ -1089,9 +1089,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));
Expand Down
3 changes: 2 additions & 1 deletion xbmc/video/VideoInfoScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,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.
Expand Down