Add some YouTube related preferences

This commit is contained in:
Rafał Dzięgiel
2021-04-16 10:35:34 +02:00
parent 3a998fb91e
commit 2fd94fdc70
5 changed files with 32 additions and 4 deletions

View File

@@ -102,7 +102,11 @@
<!-- YouTube --> <!-- YouTube -->
<key name="yt-adaptive-enabled" type="b"> <key name="yt-adaptive-enabled" type="b">
<default>false</default> <default>false</default>
<summary>Enable to use adaptive streaming</summary> <summary>Enable to use adaptive streaming for YouTube</summary>
</key>
<key name="yt-quality-type" type="s">
<default>"hfr"</default>
<summary>Max YouTube video quality type</summary>
</key> </key>
<!-- Other --> <!-- Other -->

View File

@@ -228,6 +228,10 @@ class ClapperPrefsDialog extends Gtk.Dialog
{ {
title: 'Network', title: 'Network',
widget: Prefs.NetworkPage, widget: Prefs.NetworkPage,
},
{
title: 'YouTube',
widget: Prefs.YouTubePage,
} }
] ]
}, },

View File

@@ -132,6 +132,22 @@ class ClapperNetworkPage extends PrefsBase.Grid
} }
}); });
var YouTubePage = GObject.registerClass(
class ClapperYouTubePage extends PrefsBase.Grid
{
_init()
{
super._init();
this.addTitle('YouTube');
this.addCheckButton('Adaptive streaming', 'yt-adaptive-enabled');
this.addComboBoxText('Max quality', [
['normal', "Normal"],
['hfr', "HFR"],
], 'yt-quality-type');
}
});
var GStreamerPage = GObject.registerClass( var GStreamerPage = GObject.registerClass(
class ClapperGStreamerPage extends PrefsBase.Grid class ClapperGStreamerPage extends PrefsBase.Grid
{ {

View File

@@ -317,7 +317,7 @@ var YouTubeClient = GObject.registerClass({
width: monitor.geometry.width * monitor.scale_factor, width: monitor.geometry.width * monitor.scale_factor,
height: monitor.geometry.height * monitor.scale_factor, height: monitor.geometry.height * monitor.scale_factor,
codec: 'h264', codec: 'h264',
types: ['standard', 'hfr'], type: settings.get_string('yt-quality-type'),
}; };
const dashInfo = await this.getDashInfoAsync(info, itagOpts).catch(debug); const dashInfo = await this.getDashInfoAsync(info, itagOpts).catch(debug);

View File

@@ -1,7 +1,7 @@
const Itags = { const Itags = {
video: { video: {
h264: { h264: {
standard: { normal: {
240: 133, 240: 133,
360: 134, 360: 134,
480: 135, 480: 135,
@@ -49,10 +49,14 @@ function getDashItags(opts)
? Itags.audio.aac ? Itags.audio.aac
: Itags.audio.opus : Itags.audio.opus
}; };
const types = Object.keys(Itags.video[opts.codec]);
for(let type of opts.types) { for(let type of types) {
const formats = Itags.video[opts.codec][type]; const formats = Itags.video[opts.codec][type];
_appendItagArray(allowed.video, opts, formats); _appendItagArray(allowed.video, opts, formats);
if(type === opts.type)
break;
} }
return allowed; return allowed;