Solved VideoInfoScanner fails to update from pvr://recordings/
#1
I'm using home compiled OpenElec 5.0.8 (Kodi 14.2) based build on RPi and Janbar's excellent pvr.mythv 1.12.18 to talk to a mythtv 0.27.4 backend.
To keep track of the latest films myth has recorded, I added pvr://recordings/Films as a 'MovieDB' scan path, and installed XBMC Library Auto updater. To my frustration it often failed to find anything - telling me 'Process directory 'pvr://recordings/Films/' does not exist - skipping scan.' It seems if the PVR Recordings screen was showing at the time it would work (as the directory was in a cache somewhere), but if not it couldn't find anything.

After a bit of investigation, I tracked the problem down to CPVRDirectory::Exists in xbmc/filesystem/PVRDirectory.cpp which always returns 'false'. [xbmc/URL.cpp Line 292 sets m_strHostName = "" if protocol is "pvr", so GetHostName() will always return false]

I have created something which works and I believe fulfils the spirit of CPVRDirectory::Exists (see patch below) using existing functions. There is almost certainly a more efficient way to do this but with my limited knowledge of PVR internals I couldn't find one easily.

Code:
diff --git a/xbmc/filesystem/PVRDirectory.cpp b/xbmc/filesystem/PVRDirectory.cpp
index 7680f58..233ebb9 100644
--- a/xbmc/filesystem/PVRDirectory.cpp
+++ b/xbmc/filesystem/PVRDirectory.cpp
@@ -46,7 +46,32 @@ CPVRDirectory::~CPVRDirectory()

bool CPVRDirectory::Exists(const CURL& url)
{
-  return (url.IsProtocol("pvr") && url.GetHostName() == "recordings");
+  /* The old way always fails because line 292 in xbmc/URL.cpp deliberately sets m_strHostName = ""
+   * if the protocol is pvr, iso9660, musicdb, videodb etc...
+   * return (url.IsProtocol("pvr") && url.GetHostName() == "recordings");
+  */
+  if (url.IsProtocol("pvr"))
+  {
+   if (!g_PVRManager.IsStarted())
+   {
+     CLog::Log(LOGWARNING, "CPVRDirectory::%s - can't confirm if %s exists as the PVRManager isn't started.",__FUNCTION__,url.GetRedacted().c_str());
+   } else
+   {
+     std::string pathName = url.GetFileName();
+     if (StringUtils::StartsWith(pathName, "recordings"))
+     {
+       CLog::Log(LOGDEBUG, "CPVRDirectory::%s - searching recordings for path (%s)",__FUNCTION__,pathName.c_str());
+       CFileItemList items;
+       const std::string pathToUrl(url.Get());
+       //there probably is a more efficient way to do this, but this works using existing functions
+       bool directoryHasRecordings = g_PVRRecordings->GetDirectory(pathToUrl, items);
+       //no memory leaks here please...
+       items.Reset();
+       return directoryHasRecordings;
+     }
+   }
+  }
+  return false;
}

bool CPVRDirectory::GetDirectory(const CURL& url, CFileItemList &items)

The disadvantages are:
1) VideoInfoScanner takes a couple of seconds to scan the PVR directory on an RPi showing 'preparing' before the update itself starts (not a problem in my opinion - it takes this long to enter the recordings screen!)
2) An update of the video database on startup always fails as the mythtv PVR manager hasn't finished initializing yet. It might be possible to delay 'CPVRDirectory::Exists' for a few seconds and then try again as nowhere else in the code seems to call it, but this seems out of scope for a simple function like this. Better to delay the video scan at source until other addins have finished loading.

Anyone out there able to take a look / confirm my findings / suggest a more elegant solution to the problem?
(Possibly @popcornmix who was nice enough to pull my previous patch into rbp-backports Smile )
Reply
#2
CPVRDirectory::Exists should definitely not return false all the time. Can you file a bug report on trac.kodi.tv and CC me? I'll take a look at it at some point.
Reply
#3
@negge - http://trac.kodi.tv/ticket/15997 Thanks for the encouragement.
Reply

Logout Mark Read Team Forum Stats Members Help
VideoInfoScanner fails to update from pvr://recordings/0