From 3f653c48935930c063f43df71340cd46ff932dc1 Mon Sep 17 00:00:00 2001 From: rainbownapkin Date: Thu, 14 Jul 2022 01:54:06 +0000 Subject: [PATCH] Added raw file youtube support as holdover until invidious embed is viable. This does not help with region locking, but at least allows age restricted videos with no sign in, doesnt run any google scripts, and does not run ads. --- src/channel/playlist.js | 12 +++++- src/get-info.js | 23 ++++++++++- src/media.js | 3 +- templates/useroptions.pug | 42 +++++++++----------- www/js/callbacks.js | 1 - www/js/data.js | 1 + www/js/fpanel.js | 7 +++- www/js/player.js | 80 ++++++++++++++++++++++++++------------- www/js/util.js | 10 +++++ 9 files changed, 122 insertions(+), 57 deletions(-) diff --git a/src/channel/playlist.js b/src/channel/playlist.js index c3248445..e012939f 100644 --- a/src/channel/playlist.js +++ b/src/channel/playlist.js @@ -1238,7 +1238,7 @@ PlaylistModule.prototype.startPlayback = function (time) { } /* Lead-in time of 3 seconds to allow clients to buffer */ - time = time || (media.seconds > 0 ? -3 : 0); + time = time || (media.seconds > 0 ? (media.type == "yt" ? -6 : -3) : 0); //if its a yt vid make it 6 for the link pull media.paused = time < 0; media.currentTime = time; @@ -1258,8 +1258,16 @@ PlaylistModule.prototype.startPlayback = function (time) { if (!self.current || !self.current.media) { return; } + + if(self.current.media.type == "yt"){//if its yt + InfoGetter.getYTRaw(self.current.media.id,function(url){//get raw link from invidious api + self.current.media.meta.rawLink = url;//set to meta + self.sendChangeMedia(self.channel.users);//fuggin SEND IT + }); - self.sendChangeMedia(self.channel.users); + }else{ + self.sendChangeMedia(self.channel.users); + } self.channel.notifyModules("onMediaChange", [self.current.media]); /* Only start the timer if the media item is not live, i.e. has a duration */ diff --git a/src/get-info.js b/src/get-info.js index bcd4b8e0..eabab281 100644 --- a/src/get-info.js +++ b/src/get-info.js @@ -594,5 +594,26 @@ module.exports = { } else { callback("Unknown media type '" + type + "'", null); } - } + }, + getYTRaw: function (id, cb){ + var options = { + host: Config.get("invidious-source"), + port: 443, + path: "/api/v1/videos/" + id, + method: "GET", + timeout: 1000 + }; + + urlRetrieve(https, options, function (status, data) { + if(status !== 200) { + console.log("Invidious HTTPS error code: " + status); + } + + var vid = JSON.parse(data); + + if(vid.formatStreams[0] != null){//TEMPORARY FOR FRONTEND DEV PURPOSES, PULL LINK AND SET AGAIN WHEN VIDEO QUEUED(shit expires) + cb(vid.formatStreams[vid.formatStreams.length - 1].url); + } + }); + } }; diff --git a/src/media.js b/src/media.js index bd1818b1..bcf7f830 100644 --- a/src/media.js +++ b/src/media.js @@ -41,7 +41,8 @@ Media.prototype = { embed: this.meta.embed, gdrive_subtitles: this.meta.gdrive_subtitles, textTracks: this.meta.textTracks, - mixer: this.meta.mixer + mixer: this.meta.mixer, + rawLink: this.meta.rawLink } }; diff --git a/templates/useroptions.pug b/templates/useroptions.pug index 28c6ca0e..9f6ed902 100644 --- a/templates/useroptions.pug +++ b/templates/useroptions.pug @@ -5,12 +5,12 @@ mixin lcheckbox(id, label) .checkbox input(type="checkbox", id=id) -mixin rcheckbox(id, label) +mixin rcheckbox(id, label, title) .form-group .col-sm-8.col-sm-offset-4 .checkbox - label(for=id) - input(type="checkbox", id=id) + label(for=id, title=title) + input(type="checkbox", id=id,title=title) = label mixin textbox(id, label, placeholder) @@ -33,7 +33,6 @@ mixin us-general option(value="/css/themes/fore.st.css") fore.st .col-sm-4 .col-sm-8 - p.text-danger Changing layouts may require refreshing to take effect. +rcheckbox("us-no-channelcss", "Ignore Channel CSS") +rcheckbox("us-no-channeljs", "Ignore Channel Javascript") .clear @@ -55,19 +54,21 @@ mixin us-playback form.form-horizontal(action="javascript:void(0)") +rcheckbox("us-synch", "Synchronize video playback") +textbox("us-synch-accuracy", "Synch threshold (seconds)", "2") - +rcheckbox("us-wmode-transparent", "Set wmode=transparent") - .form-group - .col-sm-4 - .col-sm-8 - p.text-info Setting wmode=transparent allows objects to be displayed above the video player, but may cause performance issues on some systems. + +rcheckbox("us-wmode-transparent", "Set wmode=transparent", "Allows elements to be placed over the video. May cause a bit of lag on toasters.") +rcheckbox("us-hidevideo", "Remove the video player") +rcheckbox("us-playlistbuttons", "Hide playlist buttons by default") +rcheckbox("us-oldbtns", "Compact playlist buttons") +rcheckbox("us-video-orientation", "Show video orientation buttons above player") .form-group - label.control-label.col-sm-4(for="#us-default-quality") Quality Preference + label.control-label.col-sm-4(for="#us-default-quality",title="Will not work automagically on official YT embeds because google are dicks.") Quality Preference .col-sm-8 - select#us-default-quality.form-control + select#us-yt-source.form-control(title="YT Embed may not work with all site features.") + option(value="vid.puffyan.us") Raw File Link(720p) + option(value="OFYT") Official YT Embed + .form-group + label.control-label.col-sm-4(for="#us-default-quality",title="Will not work automagically on official YT embeds because google are dicks.") Quality Preference + .col-sm-8 + select#us-default-quality.form-control(title="Will not work automagically on officialy YT embeds because google are dicks.") option(value="auto") Auto option(value="240") 240p option(value="360") 360p @@ -75,10 +76,6 @@ mixin us-playback option(value="720") 720p option(value="1080") 1080p option(value="best") Highest Available - .form-group - .col-sm-4 - .col-sm-8 - p.text-info Due to technical changes on YouTube's side, the CyTube quality preference can no longer be automatically applied on YouTube videos. See this GitHub issue for details. mixin us-chat #us-chat.tab-pane @@ -89,27 +86,24 @@ mixin us-chat +rcheckbox("us-sort-rank", "Sort userlist by rank") +rcheckbox("us-sort-afk", "Sort AFKers to bottom") +rcheckbox("us-legacy-emote", "Use legacy Cytube emote menu") - .col-sm-4 - .col-sm-8 - p.text-info The following 3 options apply to how and when you will be notified if a new chat message is received while CyTube is not the active window. .form-group - label.control-label.col-sm-4(for="#us-blink-title") Blink page title on new messages + label.control-label.col-sm-4(for="#us-blink-title",title="Only applies when not active window/tab.") Blink page title on new messages .col-sm-8 - select#us-blink-title.form-control + select#us-blink-title.form-control(title="Only applies when not active window/tab.") option(value="never") Never option(value="onlyping") Only when I am mentioned or PMed option(value="always") Always .form-group - label.control-label.col-sm-4(for="#us-ping-sound") Notification sound on new messages + label.control-label.col-sm-4(for="#us-ping-sound",title="Only applies when not active window/tab.") Notification sound on new messages .col-sm-8 - select#us-ping-sound.form-control + select#us-ping-sound.form-control(title="Only applies when not active window/tab.") option(value="never") Never option(value="onlyping") Only when I am mentioned or PMed option(value="always") Always .form-group - label.control-label.col-sm-4(for="#us-notifications") Desktop notifications on new messages + label.control-label.col-sm-4(for="#us-notifications",title="Only applies when not active window/tab.") Desktop notifications on new messages .col-sm-8 - select#us-notifications.form-control + select#us-notifications.form-control(title="Only applies when not active window/tab.") option(value="never") Never option(value="onlyping") Only when I am mentioned or PMed option(value="always") Always diff --git a/www/js/callbacks.js b/www/js/callbacks.js index d412bbdb..886289a8 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -859,7 +859,6 @@ Callbacks = { if (isNaN(VOLUME) || VOLUME > 1 || VOLUME < 0) { VOLUME = 1; } - function loadNext() { if(PLAYER){ PLAYER.latch(); diff --git a/www/js/data.js b/www/js/data.js index 03102f0c..ecc2ac45 100644 --- a/www/js/data.js +++ b/www/js/data.js @@ -170,6 +170,7 @@ var USEROPTS = { sort_rank : getOrDefault("sort_rank", true), sort_afk : getOrDefault("sort_afk", false), legacy_emote : getOrDefault("legacy_emote", false), + yt_source : getOrDefault("yt_source", "vid.puffyan.us"), show_seconds : getOrDefault("show_seconds", false), default_quality : getOrDefault("default_quality", "auto"), boop : getOrDefault("boop", "never"), diff --git a/www/js/fpanel.js b/www/js/fpanel.js index c33db493..fb530a46 100644 --- a/www/js/fpanel.js +++ b/www/js/fpanel.js @@ -250,7 +250,10 @@ fpset.ocall = function(){ $("
").append( $("