Skip to content
This repository

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

Merged
merged 1 commit into from almost 2 years ago

5 participants

Sascha Montellese Jezz arnova Martijn Kaijser jmarshallnz
Sascha Montellese
Collaborator

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.

Jezz
Collaborator
JezzX commented April 22, 2012

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...

Martijn Kaijser
Owner

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.

Sascha Montellese
Collaborator

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.

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.

Sascha Montellese
Collaborator

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.

Martijn Kaijser
Owner

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

Martijn Kaijser
Owner

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

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

Showing 1 unique commit by 1 author.

May 14, 2012
Sascha Montellese add resume point to database if available (e.g. in <resume> from an N…
…FO, must be enabled in as.xml)
894f4c3
This page is out of date. Refresh to see the latest.
2  xbmc/settings/AdvancedSettings.cpp
@@ -214,6 +214,7 @@ void CAdvancedSettings::Initialize()
214 214
   m_bVideoLibraryCleanOnUpdate = false;
215 215
   m_bVideoLibraryExportAutoThumbs = false;
216 216
   m_bVideoLibraryImportWatchedState = false;
  217
+  m_bVideoLibraryImportResumePoint = false;
217 218
   m_bVideoScannerIgnoreErrors = false;
218 219
 
219 220
   m_iTuxBoxStreamtsPort = 31339;
@@ -616,6 +617,7 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file)
616 617
     XMLUtils::GetString(pElement, "itemseparator", m_videoItemSeparator);
617 618
     XMLUtils::GetBoolean(pElement, "exportautothumbs", m_bVideoLibraryExportAutoThumbs);
618 619
     XMLUtils::GetBoolean(pElement, "importwatchedstate", m_bVideoLibraryImportWatchedState);
  620
+    XMLUtils::GetBoolean(pElement, "importresumepoint", m_bVideoLibraryImportResumePoint);
619 621
   }
620 622
 
621 623
   pElement = pRootElement->FirstChildElement("videoscanner");
1  xbmc/settings/AdvancedSettings.h
@@ -237,6 +237,7 @@ class CAdvancedSettings
237 237
     bool m_bVideoLibraryCleanOnUpdate;
238 238
     bool m_bVideoLibraryExportAutoThumbs;
239 239
     bool m_bVideoLibraryImportWatchedState;
  240
+    bool m_bVideoLibraryImportResumePoint;
240 241
 
241 242
     bool m_bVideoScannerIgnoreErrors;
242 243
 
11  xbmc/video/VideoDatabase.cpp
@@ -7905,8 +7905,7 @@ void CVideoDatabase::ImportFromXML(const CStdString &path)
7905 7905
         if (ImportArtFromXML(movie->FirstChild("art"), artwork))
7906 7906
           item.SetArt(artwork);
7907 7907
         bool useFolders = info.m_basePath.IsEmpty() ? LookupByFolders(item.GetPath()) : false;
7908  
-        scanner.AddVideo(&item, CONTENT_MOVIES, useFolders);
7909  
-        SetPlayCount(item, info.m_playCount, info.m_lastPlayed);
  7908
+        scanner.AddVideo(&item, CONTENT_MOVIES, useFolders, true, -1, true);
7910 7909
         CStdString strFileName(info.m_strTitle);
7911 7910
         if (iVersion >= 1 && info.m_iYear > 0)
7912 7911
           strFileName.AppendFormat("_%i", info.m_iYear);
@@ -7920,8 +7919,7 @@ void CVideoDatabase::ImportFromXML(const CStdString &path)
7920 7919
         if (ImportArtFromXML(movie->FirstChild("art"), artwork))
7921 7920
           item.SetArt(artwork);
7922 7921
         bool useFolders = info.m_basePath.IsEmpty() ? LookupByFolders(item.GetPath()) : false;
7923  
-        scanner.AddVideo(&item, CONTENT_MUSICVIDEOS, useFolders);
7924  
-        SetPlayCount(item, info.m_playCount, info.m_lastPlayed);
  7922
+        scanner.AddVideo(&item, CONTENT_MUSICVIDEOS, useFolders, true, -1, true);
7925 7923
         CStdString strFileName(StringUtils::Join(info.m_artist, g_advancedSettings.m_videoItemSeparator) + "." + info.m_strTitle);
7926 7924
         if (iVersion >= 1 && info.m_iYear > 0)
7927 7925
           strFileName.AppendFormat("_%i", info.m_iYear);
@@ -7939,7 +7937,7 @@ void CVideoDatabase::ImportFromXML(const CStdString &path)
7939 7937
         if (ImportArtFromXML(movie->FirstChild("art"), artwork))
7940 7938
           item.SetArt(artwork);
7941 7939
         bool useFolders = info.m_basePath.IsEmpty() ? LookupByFolders(item.GetPath(), true) : false;
7942  
-        int showID = scanner.AddVideo(&item, CONTENT_TVSHOWS, useFolders);
  7940
+        int showID = scanner.AddVideo(&item, CONTENT_TVSHOWS, useFolders, true, -1, true);
7943 7941
         // season artwork
7944 7942
         TiXmlNode *art = movie->FirstChild("art");
7945 7943
         if (art)
@@ -7972,8 +7970,7 @@ void CVideoDatabase::ImportFromXML(const CStdString &path)
7972 7970
           map<string, string> artwork;
7973 7971
           if (ImportArtFromXML(movie->FirstChild("art"), artwork))
7974 7972
             item.SetArt(artwork);
7975  
-          scanner.AddVideo(&item,CONTENT_TVSHOWS,false,false,showID);
7976  
-          SetPlayCount(item, info.m_playCount, info.m_lastPlayed);
  7973
+          scanner.AddVideo(&item,CONTENT_TVSHOWS, false, false, showID, true);
7977 7974
           episode = episode->NextSiblingElement("episodedetails");
7978 7975
         }
7979 7976
       }
8  xbmc/video/VideoInfoScanner.cpp
@@ -1002,7 +1002,7 @@ namespace VIDEO
1002 1002
     return episodeInfo.cDate.IsValid();
1003 1003
   }
1004 1004
 
1005  
-  long CVideoInfoScanner::AddVideo(CFileItem *pItem, const CONTENT_TYPE &content, bool videoFolder, bool useLocal, int idShow)
  1005
+  long CVideoInfoScanner::AddVideo(CFileItem *pItem, const CONTENT_TYPE &content, bool videoFolder /* = false */, bool useLocal /* = true */, int idShow /* = -1 */, bool libraryImport /* = false */)
1006 1006
   {
1007 1007
     // ensure our database is open (this can get called via other classes)
1008 1008
     if (!m_database.Open())
@@ -1089,9 +1089,13 @@ namespace VIDEO
1089 1089
       movieDetails.m_iDbId = lResult;
1090 1090
     }
1091 1091
 
1092  
-    if (g_advancedSettings.m_bVideoLibraryImportWatchedState)
  1092
+    if (g_advancedSettings.m_bVideoLibraryImportWatchedState || libraryImport)
1093 1093
       m_database.SetPlayCount(*pItem, movieDetails.m_playCount, movieDetails.m_lastPlayed);
1094 1094
 
  1095
+    if ((g_advancedSettings.m_bVideoLibraryImportResumePoint || libraryImport) &&
  1096
+        movieDetails.m_resumePoint.timeInSeconds > 0.0f && movieDetails.m_resumePoint.totalTimeInSeconds > 0.0f)
  1097
+      m_database.AddBookMarkToFile(pItem->GetPath(), movieDetails.m_resumePoint, CBookmark::EType::RESUME);
  1098
+
1095 1099
     m_database.Close();
1096 1100
 
1097 1101
     CFileItemPtr itemCopy = CFileItemPtr(new CFileItem(*pItem));
3  xbmc/video/VideoInfoScanner.h
@@ -97,9 +97,10 @@ namespace VIDEO
97 97
      \param videoFolder whether the video is represented by a folder (single movie per folder). Defaults to false.
98 98
      \param useLocal whether to use local information for artwork etc.
99 99
      \param idShow database id of the tvshow if we're adding an episode.  Defaults to -1.
  100
+     \param libraryImport Whether this call belongs to a full library import or not. Defaults to false.
100 101
      \return database id of the added item, or -1 on failure.
101 102
      */
102  
-    long AddVideo(CFileItem *pItem, const CONTENT_TYPE &content, bool videoFolder = false, bool useLocal = true, int idShow = -1);
  103
+    long AddVideo(CFileItem *pItem, const CONTENT_TYPE &content, bool videoFolder = false, bool useLocal = true, int idShow = -1, bool libraryImport = false);
103 104
 
104 105
     /*! \brief Retrieve information for a list of items and add them to the database.
105 106
      \param items list of items to retrieve info for.
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.