Skip to content

Commit

Permalink
Merge pull request xbmc#23835 from enen92/streamdetails_subs
Browse files Browse the repository at this point in the history
[db][streamdetails] Reintroduce external subtitles into streamdetails
  • Loading branch information
enen92 authored Sep 30, 2023
2 parents 31cdd8f + 6ebfec6 commit 72dfef5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
29 changes: 29 additions & 0 deletions xbmc/cores/VideoPlayer/DVDFileInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ bool CDVDFileInfo::GetFileStreamDetails(CFileItem *pItem)
if (pDemuxer)
{
bool retVal = DemuxerToStreamDetails(pInputStream, pDemuxer, pItem->GetVideoInfoTag()->m_streamDetails, strFileNameAndPath);
ProcessExternalSubtitles(pItem);
delete pDemuxer;
return retVal;
}
Expand Down Expand Up @@ -429,6 +430,34 @@ bool CDVDFileInfo::DemuxerToStreamDetails(const std::shared_ptr<CDVDInputStream>
return retVal;
}

void CDVDFileInfo::ProcessExternalSubtitles(CFileItem* item)
{
std::vector<std::string> externalSubtitles;
const std::string videoPath = item->GetDynPath();

CUtil::ScanForExternalSubtitles(videoPath, externalSubtitles);

for (const auto& externalSubtitle : externalSubtitles)
{
// if vobsub subtitle:
if (URIUtils::GetExtension(externalSubtitle) == ".idx")
{
std::string subFile;
if (CUtil::FindVobSubPair(externalSubtitles, externalSubtitle, subFile))
AddExternalSubtitleToDetails(videoPath, item->GetVideoInfoTag()->m_streamDetails,
externalSubtitle, subFile);
}
else
{
if (!CUtil::IsVobSub(externalSubtitles, externalSubtitle))
{
AddExternalSubtitleToDetails(videoPath, item->GetVideoInfoTag()->m_streamDetails,
externalSubtitle);
}
}
}
}

bool CDVDFileInfo::AddExternalSubtitleToDetails(const std::string &path, CStreamDetails &details, const std::string& filename, const std::string& subfilename)
{
std::string ext = URIUtils::GetExtension(filename);
Expand Down
6 changes: 6 additions & 0 deletions xbmc/cores/VideoPlayer/DVDFileInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,10 @@ class CDVDFileInfo
* \param[out] details The external subtitle file's StreamDetails.
*/
static bool AddExternalSubtitleToDetails(const std::string &path, CStreamDetails &details, const std::string& filename, const std::string& subfilename = "");

/** \brief Checks external subtitles for a giving item and adds any existing to the item stream details
* \param item The video item
* \sa AddExternalSubtitleToDetails
*/
static void ProcessExternalSubtitles(CFileItem* item);
};

0 comments on commit 72dfef5

Please sign in to comment.