mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 08:21:59 +02:00
Append some common subtitle track titles
In order to not end up with multiple subitle tracks simply named for e.g. "English", add some common postfix to it when detected in track title.
This commit is contained in:
21
src/misc.js
21
src/misc.js
@@ -19,6 +19,16 @@ var settings = new Gio.Settings({
|
|||||||
|
|
||||||
var maxVolume = 1.5;
|
var maxVolume = 1.5;
|
||||||
|
|
||||||
|
/* Keys must be lowercase */
|
||||||
|
const subsTitles = {
|
||||||
|
sdh: 'SDH',
|
||||||
|
cc: 'CC',
|
||||||
|
traditional: 'Traditional',
|
||||||
|
simplified: 'Simplified',
|
||||||
|
honorifics: 'Honorifics',
|
||||||
|
};
|
||||||
|
const subsKeys = Object.keys(subsTitles);
|
||||||
|
|
||||||
let inhibitCookie;
|
let inhibitCookie;
|
||||||
|
|
||||||
function getClapperPath()
|
function getClapperPath()
|
||||||
@@ -90,6 +100,17 @@ function getClapperThemeIconUri()
|
|||||||
return iconUri;
|
return iconUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSubsTitle(infoTitle)
|
||||||
|
{
|
||||||
|
if(!infoTitle)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
const searchName = infoTitle.toLowerCase();
|
||||||
|
const found = subsKeys.find(key => key === searchName);
|
||||||
|
|
||||||
|
return (found) ? subsTitles[found] : null;
|
||||||
|
}
|
||||||
|
|
||||||
function loadCustomCss()
|
function loadCustomCss()
|
||||||
{
|
{
|
||||||
const clapperPath = getClapperPath();
|
const clapperPath = getClapperPath();
|
||||||
|
@@ -231,7 +231,11 @@ class ClapperWidget extends Gtk.Grid
|
|||||||
break;
|
break;
|
||||||
case GstClapper.ClapperSubtitleInfo:
|
case GstClapper.ClapperSubtitleInfo:
|
||||||
type = 'subtitle';
|
type = 'subtitle';
|
||||||
text = info.get_language() || 'Undetermined';
|
const subsLang = info.get_language();
|
||||||
|
text = (subsLang) ? subsLang.split(',')[0] : 'Undetermined';
|
||||||
|
const subsTitle = Misc.getSubsTitle(info.get_title());
|
||||||
|
if(subsTitle)
|
||||||
|
text += ', ' + subsTitle;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
debug(`unrecognized media info type: ${info.constructor}`);
|
debug(`unrecognized media info type: ${info.constructor}`);
|
||||||
|
Reference in New Issue
Block a user