Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

5 participants

@Montellese
Owner

This adds a check if there's a valid resume point in a CVideoInfoTag to CVideoDatabase::SetDetailsForMovie and adds the resume point to the database. This allows us to actually make use of the resume point data we write to in an NFO when exporting the video database. Up until now the point has already been read by CVideoInfoTag when reading an NFO but we didn't actually do anything with it. IMO if we export to we should also import it again.

@JezzX
Collaborator

I'm against exporting and importing resume points it could be months later that you need tip reimport a file or maybe even a different PC and the information would be way way way out of date and your stuck with it unless you do the overwrite old files on export

@arnova
Collaborator

I'm also against doing this. I belief NFO files are not the place to store info like this. And if you really really must do this, make it at least optional in some way...

@MartijnKaijser

this would only be usefull if you are doing a direct reinstall of XBMC and watch to transfer your resume point. This data is much to volitile to store in an xml file for later use. and if it goes in it should indeed go through as.xml with something like
importresumepoints =True

@jmarshallnz
Owner

IMO the goal should be to export the resume point in a full db dump, but not in a single nfo dump.

We can detect this case already as ExportToXML passes in a flag to indicate exporting of file and path info I think?

Similarly, we can likely detect it in ImportFromXML as well.

@Montellese
Owner

OK I have changed the implementation to only import the resume point if the advancedsetting "importresumepoint" is set or if the user is running a full library import. While implementing that I noticed that the importing of the playcount is done in the same way but that on a full library import they may be a few extra and unnecessary calls to CVideoDatabase::SetPlayCount so I fixed that as well.

@Montellese Montellese was assigned
@jmarshallnz
Owner

looks ok to me, but why not just use the existing as.xml? Can't see a reason why you'd want one but not the other.

@Montellese
Owner

I'm pretty sure you'll find a user who want one but not the other ;-)
That being said I'd be ok with merging the two but we'd need to change the name to something more generic.

@MartijnKaijser

I'm such a user ;)

I do want playcount but don't care about resume points

@jmarshallnz
Owner

If you don't care, you don't mind if they're imported :p

@MartijnKaijser

hehe don't care in don't want them ;)
however i'm not against this ofcourse if majority does want this merged in one setting (and ease of coding).
I can image users wouldn't want this merged. Up to you ofcourse

@Montellese Montellese merged commit 5840e98 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 14, 2012
  1. @Montellese

    add resume point to database if available (e.g. in <resume> from an N…

    Montellese authored
    …FO, must be enabled in as.xml)
This page is out of date. Refresh to see the latest.
View
2  xbmc/settings/AdvancedSettings.cpp
@@ -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;
@@ -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");
View
1  xbmc/settings/AdvancedSettings.h
@@ -237,6 +237,7 @@ class CAdvancedSettings
bool m_bVideoLibraryCleanOnUpdate;
bool m_bVideoLibraryExportAutoThumbs;
bool m_bVideoLibraryImportWatchedState;
+ bool m_bVideoLibraryImportResumePoint;
bool m_bVideoScannerIgnoreErrors;
View
11 xbmc/video/VideoDatabase.cpp
@@ -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);
@@ -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);
@@ -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)
@@ -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");
}
}
View
8 xbmc/video/VideoInfoScanner.cpp
@@ -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())
@@ -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));
View
3  xbmc/video/VideoInfoScanner.h
@@ -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.
Something went wrong with that request. Please try again.