Skip to content

Commit

Permalink
Merge pull request #9141 from FernetMenta/recording
Browse files Browse the repository at this point in the history
video: fix false positive identification of pvr recordings
  • Loading branch information
FernetMenta committed Feb 15, 2016
2 parents 8b73715 + 5a43db5 commit fb7ff23
Showing 1 changed file with 47 additions and 42 deletions.
89 changes: 47 additions & 42 deletions xbmc/video/windows/GUIWindowVideoBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,63 +1127,68 @@ bool CGUIWindowVideoBase::OnPlayMedia(int iItem, const std::string &player)
CLog::Log(LOGDEBUG, "%s %s", __FUNCTION__, CURL::GetRedacted(item.GetPath()).c_str());


CPVRRecordingsPath path(item.GetPath());
if (path.IsValid() && path.IsActive())
// TODO: delete entire block in v18
// m_strStreamURL is deprecated
if (item.IsPVR())
{
if (!g_PVRManager.IsStarted())
return false;

/* For recordings we check here for a available stream URL */
CFileItemPtr tag = g_PVRRecordings->GetByPath(item.GetPath());
if (tag && tag->HasPVRRecordingInfoTag() && !tag->GetPVRRecordingInfoTag()->m_strStreamURL.empty())
CPVRRecordingsPath path(item.GetPath());
if (path.IsValid() && path.IsActive())
{
std::string stream = tag->GetPVRRecordingInfoTag()->m_strStreamURL;

/* Isolate the folder from the filename */
size_t found = stream.find_last_of("/");
if (found == std::string::npos)
found = stream.find_last_of("\\");
if (!g_PVRManager.IsStarted())
return false;

if (found != std::string::npos)
/* For recordings we check here for a available stream URL */
CFileItemPtr tag = g_PVRRecordings->GetByPath(item.GetPath());
if (tag && tag->HasPVRRecordingInfoTag() && !tag->GetPVRRecordingInfoTag()->m_strStreamURL.empty())
{
/* Check here for asterix at the begin of the filename */
if (stream[found+1] == '*')
{
/* Create a "stack://" url with all files matching the extension */
std::string ext = URIUtils::GetExtension(stream);
std::string dir = stream.substr(0, found).c_str();
std::string stream = tag->GetPVRRecordingInfoTag()->m_strStreamURL;

CFileItemList items;
CDirectory::GetDirectory(dir, items);
items.Sort(SortByFile, SortOrderAscending);
/* Isolate the folder from the filename */
size_t found = stream.find_last_of("/");
if (found == std::string::npos)
found = stream.find_last_of("\\");

std::vector<int> stack;
for (int i = 0; i < items.Size(); ++i)
if (found != std::string::npos)
{
/* Check here for asterix at the begin of the filename */
if (stream[found+1] == '*')
{
if (URIUtils::HasExtension(items[i]->GetPath(), ext))
stack.push_back(i);
/* Create a "stack://" url with all files matching the extension */
std::string ext = URIUtils::GetExtension(stream);
std::string dir = stream.substr(0, found).c_str();

CFileItemList items;
CDirectory::GetDirectory(dir, items);
items.Sort(SortByFile, SortOrderAscending);

std::vector<int> stack;
for (int i = 0; i < items.Size(); ++i)
{
if (URIUtils::HasExtension(items[i]->GetPath(), ext))
stack.push_back(i);
}

if (stack.size() > 0)
{
/* If we have a stack change the path of the item to it */
CStackDirectory dir;
std::string stackPath = dir.ConstructStackPath(items, stack);
item.SetPath(stackPath);
}
}

if (stack.size() > 0)
else
{
/* If we have a stack change the path of the item to it */
CStackDirectory dir;
std::string stackPath = dir.ConstructStackPath(items, stack);
item.SetPath(stackPath);
/* If no asterix is present play only the given stream URL */
item.SetPath(stream);
}
}
else
{
/* If no asterix is present play only the given stream URL */
item.SetPath(stream);
CLog::Log(LOGERROR, "CGUIWindowTV: Can't open recording, no valid filename!");
CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19036});
return false;
}
}
else
{
CLog::Log(LOGERROR, "CGUIWindowTV: Can't open recording, no valid filename!");
CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19036});
return false;
}
}
}

Expand Down

0 comments on commit fb7ff23

Please sign in to comment.