diff --git a/data/com.github.rafostar.Clapper.gschema.xml b/data/com.github.rafostar.Clapper.gschema.xml index 2d5fe6e1..5e4ef144 100644 --- a/data/com.github.rafostar.Clapper.gschema.xml +++ b/data/com.github.rafostar.Clapper.gschema.xml @@ -102,7 +102,11 @@ false - Enable to use adaptive streaming + Enable to use adaptive streaming for YouTube + + + "hfr" + Max YouTube video quality type diff --git a/src/dialogs.js b/src/dialogs.js index d5e2d433..8b378a93 100644 --- a/src/dialogs.js +++ b/src/dialogs.js @@ -228,6 +228,10 @@ class ClapperPrefsDialog extends Gtk.Dialog { title: 'Network', widget: Prefs.NetworkPage, + }, + { + title: 'YouTube', + widget: Prefs.YouTubePage, } ] }, diff --git a/src/prefs.js b/src/prefs.js index 3bfe1989..dce737ad 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -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( class ClapperGStreamerPage extends PrefsBase.Grid { diff --git a/src/youtube.js b/src/youtube.js index a1be9294..8d11439b 100644 --- a/src/youtube.js +++ b/src/youtube.js @@ -317,7 +317,7 @@ var YouTubeClient = GObject.registerClass({ width: monitor.geometry.width * monitor.scale_factor, height: monitor.geometry.height * monitor.scale_factor, codec: 'h264', - types: ['standard', 'hfr'], + type: settings.get_string('yt-quality-type'), }; const dashInfo = await this.getDashInfoAsync(info, itagOpts).catch(debug); diff --git a/src/youtubeItags.js b/src/youtubeItags.js index 2f82d8bd..78ff465d 100644 --- a/src/youtubeItags.js +++ b/src/youtubeItags.js @@ -1,7 +1,7 @@ const Itags = { video: { h264: { - standard: { + normal: { 240: 133, 360: 134, 480: 135, @@ -49,10 +49,14 @@ function getDashItags(opts) ? Itags.audio.aac : 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]; _appendItagArray(allowed.video, opts, formats); + + if(type === opts.type) + break; } return allowed;