Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for external PGS/.sup subtitles #9559

Merged
merged 1 commit into from
Apr 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions xbmc/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2145,6 +2145,29 @@ std::string CUtil::GetVobSubIdxFromSub(const std::string& vobSub)
return std::string();
}

void CUtil::ScanForExternalDemuxSub(const std::string& videoPath, std::vector<std::string>& vecSubtitles)
{
CFileItem item(videoPath, false);
if (item.IsInternetStream()
|| item.IsPlayList()
|| item.IsLiveTV()
|| item.IsPVR()
|| !item.IsVideo())
return;

std::string strBasePath;
std::string strSubtitle;

GetVideoBasePathAndFileName(videoPath, strBasePath, strSubtitle);

CFileItemList items;
const std::vector<std::string> common_sub_dirs = { "subs", "subtitles", "vobsubs", "sub", "vobsub", "subtitle" };
const std::string DemuxSubExtensions = ".sup";
GetItemsToScan(strBasePath, DemuxSubExtensions, common_sub_dirs, items);

std::vector<std::string> exts = StringUtils::Split(g_advancedSettings.GetMusicExtensions(), "|");
ScanPathsForAssociatedItems(strSubtitle, items, exts, vecSubtitles);
}

void CUtil::ScanForExternalAudio(const std::string& videoPath, std::vector<std::string>& vecAudio)
{
Expand Down
1 change: 1 addition & 0 deletions xbmc/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class CUtil
* \param[out] vecAudio A vector containing the full paths of all found external audio files.
*/
static void ScanForExternalAudio(const std::string& videoPath, std::vector<std::string>& vecAudio);
static void ScanForExternalDemuxSub(const std::string& videoPath, std::vector<std::string>& vecSubtitles);
static int64_t ToInt64(uint32_t high, uint32_t low);
static std::string GetNextFilename(const std::string &fn_template, int max);
static std::string GetNextPathname(const std::string &path_template, int max);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ CDVDInputStream* CDVDFactoryInputStream::CreateInputStream(IVideoPlayer* pPlayer
std::vector<std::string> filenames;
filenames.push_back(file);
CUtil::ScanForExternalAudio(file, filenames);
CUtil::ScanForExternalDemuxSub(file, filenames);
if (filenames.size() >= 2)
{
return CreateInputStream(pPlayer, fileitem, filenames);
Expand Down
1 change: 1 addition & 0 deletions xbmc/utils/Mime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ std::map<std::string, std::string> fillMimeTypes()
mimeTypes.insert(std::pair<std::string, std::string>("step", "application/step"));
mimeTypes.insert(std::pair<std::string, std::string>("stl", "application/sla"));
mimeTypes.insert(std::pair<std::string, std::string>("stp", "application/step"));
mimeTypes.insert(std::pair<std::string, std::string>("sup", "application/x-pgs"));
mimeTypes.insert(std::pair<std::string, std::string>("sv4cpio", "application/x-sv4cpio"));
mimeTypes.insert(std::pair<std::string, std::string>("sv4crc", "application/x-sv4crc"));
mimeTypes.insert(std::pair<std::string, std::string>("svf", "image/vnd.dwg"));
Expand Down