diff options
42 files changed, 658 insertions, 323 deletions
diff --git a/.travis.yml b/.travis.yml index f5918bb1..314abc73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,18 +3,24 @@ dist: bionic jobs: include: - stage: build + # TODO: Shallowly clone again once the .git folder is no longer required for building + git: + depth: false language: crystal crystal: latest before_install: - shards update - shards install install: - - crystal build --error-on-warnings src/invidious.cr + - crystal build --warnings all --error-on-warnings src/invidious.cr script: - crystal tool format --check - crystal spec - stage: build_docker + # TODO: Shallowly clone again once the .git folder is no longer required for building + git: + depth: false language: minimal services: - docker diff --git a/assets/css/default.css b/assets/css/default.css index 4daa9f16..f9d52281 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -282,10 +282,10 @@ input[type="search"]::-webkit-search-cancel-button { } /* Control Bar */ -@media screen and (max-width: 480px) { +@media screen and (max-width: 640px) { .video-js .vjs-control-bar, .vjs-menu-button-popup .vjs-menu .vjs-menu-content { - overflow: -webkit-paged-x; + overflow-x: scroll; } } diff --git a/assets/js/silvermine-videojs-quality-selector.min.js b/assets/js/silvermine-videojs-quality-selector.min.js index 9d27202e..3ad2c2ab 100644 --- a/assets/js/silvermine-videojs-quality-selector.min.js +++ b/assets/js/silvermine-videojs-quality-selector.min.js @@ -1,4 +1,4 @@ -/*! silvermine-videojs-quality-selector 2018-01-09 v1.1.2 */ +/*! @silvermine/videojs-quality-selector 2019-09-26 v1.2.2-4-gc134430-dirty */ -!function n(t,e,r){function i(o,c){if(!e[o]){if(!t[o]){var a="function"==typeof require&&require;if(!c&&a)return a(o,!0);if(u)return u(o,!0);var s=new Error("Cannot find module '"+o+"'");throw s.code="MODULE_NOT_FOUND",s}var l=e[o]={exports:{}};t[o][0].call(l.exports,function(n){var e=t[o][1][n];return i(e||n)},l,l.exports,n,t,e,r)}return e[o].exports}for(var u="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}({1:[function(n,t,e){!function(){var n=!1,e=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){},Class.extend=function(t,r){function i(){!n&&this.init&&this.init.apply(this,arguments)}void 0==r&&(r=t,t="Class");var u=this.prototype;n=!0;var o=new this;n=!1;for(var c in r)o[c]="function"==typeof r[c]&&"function"==typeof u[c]&&e.test(r[c])?function(n,t){return function(){var e=this._super;this._super=u[n];var r=t.apply(this,arguments);return this._super=e,r}}(c,r[c]):r[c];i.prototype=o;var a=new Function("return function "+t+"(){ }")();return i.prototype.constructor=a,i.extend=arguments.callee,i},t.exports=Class}()},{}],2:[function(n,t,e){(function(){function n(n){function t(t,e,r,i,u,o){for(;u>=0&&u<o;u+=n){var c=i?i[u]:u;r=e(r,t[c],c,t)}return r}return function(e,r,i,u){r=b(r,u,4);var o=!A(e)&&m.keys(e),c=(o||e).length,a=n>0?0:c-1;return arguments.length<3&&(i=e[o?o[a]:a],a+=n),t(e,r,i,o,a,c)}}function r(n){return function(t,e,r){e=x(e,r);for(var i=T(t),u=n>0?0:i-1;u>=0&&u<i;u+=n)if(e(t[u],u,t))return u;return-1}}function i(n,t,e){return function(r,i,u){var o=0,c=T(r);if("number"==typeof u)n>0?o=u>=0?u:Math.max(u+c,o):c=u>=0?Math.min(u+1,c):u+c+1;else if(e&&u&&c)return u=e(r,i),r[u]===i?u:-1;if(i!==i)return(u=t(p.call(r,o,c),m.isNaN))>=0?u+o:-1;for(u=n>0?o:c-1;u>=0&&u<c;u+=n)if(r[u]===i)return u;return-1}}function u(n,t){var e=q.length,r=n.constructor,i=m.isFunction(r)&&r.prototype||s,u="constructor";for(m.has(n,u)&&!m.contains(t,u)&&t.push(u);e--;)(u=q[e])in n&&n[u]!==i[u]&&!m.contains(t,u)&&t.push(u)}var o=this,c=o._,a=Array.prototype,s=Object.prototype,l=Function.prototype,f=a.push,p=a.slice,h=s.toString,v=s.hasOwnProperty,d=Array.isArray,y=Object.keys,g=l.bind,S=Object.create,_=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};void 0!==e?(void 0!==t&&t.exports&&(e=t.exports=m),e._=m):o._=m,m.VERSION="1.8.3";var b=function(n,t,e){if(void 0===t)return n;switch(null==e?3:e){case 1:return function(e){return n.call(t,e)};case 2:return function(e,r){return n.call(t,e,r)};case 3:return function(e,r,i){return n.call(t,e,r,i)};case 4:return function(e,r,i,u){return n.call(t,e,r,i,u)}}return function(){return n.apply(t,arguments)}},x=function(n,t,e){return null==n?m.identity:m.isFunction(n)?b(n,t,e):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var k=function(n,t){return function(e){var r=arguments.length;if(r<2||null==e)return e;for(var i=1;i<r;i++)for(var u=arguments[i],o=n(u),c=o.length,a=0;a<c;a++){var s=o[a];t&&void 0!==e[s]||(e[s]=u[s])}return e}},w=function(n){if(!m.isObject(n))return{};if(S)return S(n);_.prototype=n;var t=new _;return _.prototype=null,t},j=function(n){return function(t){return null==t?void 0:t[n]}},E=Math.pow(2,53)-1,T=j("length"),A=function(n){var t=T(n);return"number"==typeof t&&t>=0&&t<=E};m.each=m.forEach=function(n,t,e){t=b(t,e);var r,i;if(A(n))for(r=0,i=n.length;r<i;r++)t(n[r],r,n);else{var u=m.keys(n);for(r=0,i=u.length;r<i;r++)t(n[u[r]],u[r],n)}return n},m.map=m.collect=function(n,t,e){t=x(t,e);for(var r=!A(n)&&m.keys(n),i=(r||n).length,u=Array(i),o=0;o<i;o++){var c=r?r[o]:o;u[o]=t(n[c],c,n)}return u},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,e){var r;if(void 0!==(r=A(n)?m.findIndex(n,t,e):m.findKey(n,t,e))&&-1!==r)return n[r]},m.filter=m.select=function(n,t,e){var r=[];return t=x(t,e),m.each(n,function(n,e,i){t(n,e,i)&&r.push(n)}),r},m.reject=function(n,t,e){return m.filter(n,m.negate(x(t)),e)},m.every=m.all=function(n,t,e){t=x(t,e);for(var r=!A(n)&&m.keys(n),i=(r||n).length,u=0;u<i;u++){var o=r?r[u]:u;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,e){t=x(t,e);for(var r=!A(n)&&m.keys(n),i=(r||n).length,u=0;u<i;u++){var o=r?r[u]:u;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,e,r){return A(n)||(n=m.values(n)),("number"!=typeof e||r)&&(e=0),m.indexOf(n,t,e)>=0},m.invoke=function(n,t){var e=p.call(arguments,2),r=m.isFunction(t);return m.map(n,function(n){var i=r?t:n[t];return null==i?i:i.apply(n,e)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,e){var r,i,u=-1/0,o=-1/0;if(null==t&&null!=n)for(var c=0,a=(n=A(n)?n:m.values(n)).length;c<a;c++)(r=n[c])>u&&(u=r);else t=x(t,e),m.each(n,function(n,e,r){((i=t(n,e,r))>o||i===-1/0&&u===-1/0)&&(u=n,o=i)});return u},m.min=function(n,t,e){var r,i,u=1/0,o=1/0;if(null==t&&null!=n)for(var c=0,a=(n=A(n)?n:m.values(n)).length;c<a;c++)(r=n[c])<u&&(u=r);else t=x(t,e),m.each(n,function(n,e,r){((i=t(n,e,r))<o||i===1/0&&u===1/0)&&(u=n,o=i)});return u},m.shuffle=function(n){for(var t,e=A(n)?n:m.values(n),r=e.length,i=Array(r),u=0;u<r;u++)(t=m.random(0,u))!==u&&(i[u]=i[t]),i[t]=e[u];return i},m.sample=function(n,t,e){return null==t||e?(A(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,e){return t=x(t,e),m.pluck(m.map(n,function(n,e,r){return{value:n,index:e,criteria:t(n,e,r)}}).sort(function(n,t){var e=n.criteria,r=t.criteria;if(e!==r){if(e>r||void 0===e)return 1;if(e<r||void 0===r)return-1}return n.index-t.index}),"value")};var O=function(n){return function(t,e,r){var i={};return e=x(e,r),m.each(t,function(r,u){var o=e(r,u,t);n(i,r,o)}),i}};m.groupBy=O(function(n,t,e){m.has(n,e)?n[e].push(t):n[e]=[t]}),m.indexBy=O(function(n,t,e){n[e]=t}),m.countBy=O(function(n,t,e){m.has(n,e)?n[e]++:n[e]=1}),m.toArray=function(n){return n?m.isArray(n)?p.call(n):A(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:A(n)?n.length:m.keys(n).length},m.partition=function(n,t,e){t=x(t,e);var r=[],i=[];return m.each(n,function(n,e,u){(t(n,e,u)?r:i).push(n)}),[r,i]},m.first=m.head=m.take=function(n,t,e){if(null!=n)return null==t||e?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,e){return p.call(n,0,Math.max(0,n.length-(null==t||e?1:t)))},m.last=function(n,t,e){if(null!=n)return null==t||e?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,e){return p.call(n,null==t||e?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var C=function(n,t,e,r){for(var i=[],u=0,o=r||0,c=T(n);o<c;o++){var a=n[o];if(A(a)&&(m.isArray(a)||m.isArguments(a))){t||(a=C(a,t,e));var s=0,l=a.length;for(i.length+=l;s<l;)i[u++]=a[s++]}else e||(i[u++]=a)}return i};m.flatten=function(n,t){return C(n,t,!1)},m.without=function(n){return m.difference(n,p.call(arguments,1))},m.uniq=m.unique=function(n,t,e,r){m.isBoolean(t)||(r=e,e=t,t=!1),null!=e&&(e=x(e,r));for(var i=[],u=[],o=0,c=T(n);o<c;o++){var a=n[o],s=e?e(a,o,n):a;t?(o&&u===s||i.push(a),u=s):e?m.contains(u,s)||(u.push(s),i.push(a)):m.contains(i,a)||i.push(a)}return i},m.union=function(){return m.uniq(C(arguments,!0,!0))},m.intersection=function(n){for(var t=[],e=arguments.length,r=0,i=T(n);r<i;r++){var u=n[r];if(!m.contains(t,u)){for(var o=1;o<e&&m.contains(arguments[o],u);o++);o===e&&t.push(u)}}return t},m.difference=function(n){var t=C(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,T).length||0,e=Array(t),r=0;r<t;r++)e[r]=m.pluck(n,r);return e},m.object=function(n,t){for(var e={},r=0,i=T(n);r<i;r++)t?e[n[r]]=t[r]:e[n[r][0]]=n[r][1];return e},m.findIndex=r(1),m.findLastIndex=r(-1),m.sortedIndex=function(n,t,e,r){for(var i=(e=x(e,r,1))(t),u=0,o=T(n);u<o;){var c=Math.floor((u+o)/2);e(n[c])<i?u=c+1:o=c}return u},m.indexOf=i(1,m.findIndex,m.sortedIndex),m.lastIndexOf=i(-1,m.findLastIndex),m.range=function(n,t,e){null==t&&(t=n||0,n=0),e=e||1;for(var r=Math.max(Math.ceil((t-n)/e),0),i=Array(r),u=0;u<r;u++,n+=e)i[u]=n;return i};var I=function(n,t,e,r,i){if(!(r instanceof t))return n.apply(e,i);var u=w(n.prototype),o=n.apply(u,i);return m.isObject(o)?o:u};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,p.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var e=p.call(arguments,2),r=function(){return I(n,r,t,this,e.concat(p.call(arguments)))};return r},m.partial=function(n){var t=p.call(arguments,1),e=function(){for(var r=0,i=t.length,u=Array(i),o=0;o<i;o++)u[o]=t[o]===m?arguments[r++]:t[o];for(;r<arguments.length;)u.push(arguments[r++]);return I(n,e,this,this,u)};return e},m.bindAll=function(n){var t,e,r=arguments.length;if(r<=1)throw new Error("bindAll must be passed function names");for(t=1;t<r;t++)n[e=arguments[t]]=m.bind(n[e],n);return n},m.memoize=function(n,t){var e=function(r){var i=e.cache,u=""+(t?t.apply(this,arguments):r);return m.has(i,u)||(i[u]=n.apply(this,arguments)),i[u]};return e.cache={},e},m.delay=function(n,t){var e=p.call(arguments,2);return setTimeout(function(){return n.apply(null,e)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,e){var r,i,u,o=null,c=0;e||(e={});var a=function(){c=!1===e.leading?0:m.now(),o=null,u=n.apply(r,i),o||(r=i=null)};return function(){var s=m.now();c||!1!==e.leading||(c=s);var l=t-(s-c);return r=this,i=arguments,l<=0||l>t?(o&&(clearTimeout(o),o=null),c=s,u=n.apply(r,i),o||(r=i=null)):o||!1===e.trailing||(o=setTimeout(a,l)),u}},m.debounce=function(n,t,e){var r,i,u,o,c,a=function(){var s=m.now()-o;s<t&&s>=0?r=setTimeout(a,t-s):(r=null,e||(c=n.apply(u,i),r||(u=i=null)))};return function(){u=this,i=arguments,o=m.now();var s=e&&!r;return r||(r=setTimeout(a,t)),s&&(c=n.apply(u,i),u=i=null),c}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var e=t,r=n[t].apply(this,arguments);e--;)r=n[e].call(this,r);return r}},m.after=function(n,t){return function(){if(--n<1)return t.apply(this,arguments)}},m.before=function(n,t){var e;return function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=null),e}},m.once=m.partial(m.before,2);var F=!{toString:null}.propertyIsEnumerable("toString"),q=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(y)return y(n);var t=[];for(var e in n)m.has(n,e)&&t.push(e);return F&&u(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var e in n)t.push(e);return F&&u(n,t),t},m.values=function(n){for(var t=m.keys(n),e=t.length,r=Array(e),i=0;i<e;i++)r[i]=n[t[i]];return r},m.mapObject=function(n,t,e){t=x(t,e);for(var r,i=m.keys(n),u=i.length,o={},c=0;c<u;c++)o[r=i[c]]=t(n[r],r,n);return o},m.pairs=function(n){for(var t=m.keys(n),e=t.length,r=Array(e),i=0;i<e;i++)r[i]=[t[i],n[t[i]]];return r},m.invert=function(n){for(var t={},e=m.keys(n),r=0,i=e.length;r<i;r++)t[n[e[r]]]=e[r];return t},m.functions=m.methods=function(n){var t=[];for(var e in n)m.isFunction(n[e])&&t.push(e);return t.sort()},m.extend=k(m.allKeys),m.extendOwn=m.assign=k(m.keys),m.findKey=function(n,t,e){t=x(t,e);for(var r,i=m.keys(n),u=0,o=i.length;u<o;u++)if(r=i[u],t(n[r],r,n))return r},m.pick=function(n,t,e){var r,i,u={},o=n;if(null==o)return u;m.isFunction(t)?(i=m.allKeys(o),r=b(t,e)):(i=C(arguments,!1,!1,1),r=function(n,t,e){return t in e},o=Object(o));for(var c=0,a=i.length;c<a;c++){var s=i[c],l=o[s];r(l,s,o)&&(u[s]=l)}return u},m.omit=function(n,t,e){if(m.isFunction(t))t=m.negate(t);else{var r=m.map(C(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(r,t)}}return m.pick(n,t,e)},m.defaults=k(m.allKeys,!0),m.create=function(n,t){var e=w(n);return t&&m.extendOwn(e,t),e},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var e=m.keys(t),r=e.length;if(null==n)return!r;for(var i=Object(n),u=0;u<r;u++){var o=e[u];if(t[o]!==i[o]||!(o in i))return!1}return!0};var Q=function(n,t,e,r){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var i=h.call(n);if(i!==h.call(t))return!1;switch(i){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!=+n?+t!=+t:0==+n?1/+n==1/t:+n==+t;case"[object Date]":case"[object Boolean]":return+n==+t}var u="[object Array]"===i;if(!u){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,c=t.constructor;if(o!==c&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(c)&&c instanceof c)&&"constructor"in n&&"constructor"in t)return!1}e=e||[],r=r||[];for(var a=e.length;a--;)if(e[a]===n)return r[a]===t;if(e.push(n),r.push(t),u){if((a=n.length)!==t.length)return!1;for(;a--;)if(!Q(n[a],t[a],e,r))return!1}else{var s,l=m.keys(n);if(a=l.length,m.keys(t).length!==a)return!1;for(;a--;)if(s=l[a],!m.has(t,s)||!Q(n[s],t[s],e,r))return!1}return e.pop(),r.pop(),!0};m.isEqual=function(n,t){return Q(n,t)},m.isEmpty=function(n){return null==n||(A(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length)},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=d||function(n){return"[object Array]"===h.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return h.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return!0===n||!1===n||"[object Boolean]"===h.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return void 0===n},m.has=function(n,t){return null!=n&&v.call(n,t)},m.noConflict=function(){return o._=c,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=j,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,e){var r=Array(Math.max(0,n));t=b(t,e,1);for(var i=0;i<n;i++)r[i]=t(i);return r},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var M={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},N=m.invert(M),L=function(n){var t=function(t){return n[t]},e="(?:"+m.keys(n).join("|")+")",r=RegExp(e),i=RegExp(e,"g");return function(n){return n=null==n?"":""+n,r.test(n)?n.replace(i,t):n}};m.escape=L(M),m.unescape=L(N),m.result=function(n,t,e){var r=null==n?void 0:n[t];return void 0===r&&(r=e),m.isFunction(r)?r.call(n):r};var U=0;m.uniqueId=function(n){var t=++U+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var D=/(.)^/,R={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},W=/\\|'|\r|\n|\u2028|\u2029/g,P=function(n){return"\\"+R[n]};m.template=function(n,t,e){!t&&e&&(t=e),t=m.defaults({},t,m.templateSettings);var r=RegExp([(t.escape||D).source,(t.interpolate||D).source,(t.evaluate||D).source].join("|")+"|$","g"),i=0,u="__p+='";n.replace(r,function(t,e,r,o,c){return u+=n.slice(i,c).replace(W,P),i=c+t.length,e?u+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'":r?u+="'+\n((__t=("+r+"))==null?'':__t)+\n'":o&&(u+="';\n"+o+"\n__p+='"),t}),u+="';\n",t.variable||(u="with(obj||{}){\n"+u+"}\n"),u="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+u+"return __p;\n";try{var o=new Function(t.variable||"obj","_",u)}catch(n){throw n.source=u,n}var c=function(n){return o.call(this,n,m)},a=t.variable||"obj";return c.source="function("+a+"){\n"+u+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var B=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var e=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),B(this,e.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=a[n];m.prototype[n]=function(){var e=this._wrapped;return t.apply(e,arguments),"shift"!==n&&"splice"!==n||0!==e.length||delete e[0],B(this,e)}}),m.each(["concat","join","slice"],function(n){var t=a[n];m.prototype[n]=function(){return B(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this)},{}],3:[function(n,t,e){"use strict";var r=n("underscore"),i=n("../events");t.exports=function(n){var t=n.getComponent("MenuItem");return n.extend(t,{constructor:function(n,e){var i=e.source;if(!r.isObject(i))throw new Error('was not provided a "source" object, but rather: '+typeof i);e=r.extend({selectable:!0,label:i.label},e),t.call(this,n,e),this.source=i},handleClick:function(n){t.prototype.handleClick.call(this,n),this.player().trigger(i.QUALITY_REQUESTED,this.source)}})}},{"../events":5,underscore:2}],4:[function(n,t,e){"use strict";var r=n("underscore"),i=n("../events"),u=n("./QualityOption");t.exports=function(n){var t,e=n.getComponent("MenuButton"),o=u(n);return t=n.extend(e,{constructor:function(n,t){e.call(this,n,t),n.on(i.QUALITY_REQUESTED,function(t,e){this.setSelectedSource(e),n.addClass("vjs-quality-changing"),n.one("loadeddata",function(){n.removeClass("vjs-quality-changing")})}.bind(this)),n.on(i.QUALITY_SELECTED,function(n,t){this.setSelectedSource(t)}.bind(this)),n.one("ready",function(){this.selectedSrc=n.src(),this.update()}.bind(this)),this.controlText("Open quality selector menu")},setSelectedSource:function(n){var t=n?n.src:void 0;this.selectedSrc!==t&&(this.selectedSrc=t,this.update())},createItems:function(){var n=this.player(),t=n.currentSources();return!t||t.length<2?[]:r.map(t,function(t){return new o(n,{source:t,selected:t.src===this.selectedSrc})}.bind(this))},buildWrapperCSSClass:function(){return"vjs-quality-selector "+e.prototype.buildWrapperCSSClass.call(this)}}),n.registerComponent("QualitySelector",t),t}},{"../events":5,"./QualityOption":3,underscore:2}],5:[function(n,t,e){"use strict";t.exports={QUALITY_REQUESTED:"qualityRequested",QUALITY_SELECTED:"qualitySelected"}},{}],6:[function(n,t,e){"use strict";var r=n("underscore"),i=n("./events"),u=n("./components/QualitySelector"),o=n("./middleware/SourceInterceptor"),c=n("./util/SafeSeek");t.exports=function(n){n=n||window.videojs,u(n),o(n),n.hook("setup",function(n){n.on(i.QUALITY_REQUESTED,function(t,e){var i=n.currentSources(),u=n.currentTime(),o=n.paused();r.each(i,function(n){n.selected=!1}),r.findWhere(i,{src:e.src}).selected=!0,n._qualitySelectorSafeSeek&&n._qualitySelectorSafeSeek.onQualitySelectionChange(),n.src(i),n.ready(function(){n._qualitySelectorSafeSeek&&!n._qualitySelectorSafeSeek.hasFinished()||(n._qualitySelectorSafeSeek=new c(n,u)),o||n.play()})})})},t.exports.EVENTS=i},{"./components/QualitySelector":4,"./events":5,"./middleware/SourceInterceptor":7,"./util/SafeSeek":9,underscore:2}],7:[function(n,t,e){"use strict";var r=n("underscore"),i=n("../events");t.exports=function(n){n.use("*",function(n){return{setSource:function(t,e){var u,o=n.currentSources();n._qualitySelectorSafeSeek&&n._qualitySelectorSafeSeek.onPlayerSourcesChange(),u=r.find(o,function(n){return!0===n.selected||"true"===n.selected})||t,n.trigger(i.QUALITY_SELECTED,u),e(null,u)}}})}},{"../events":5,underscore:2}],8:[function(n,t,e){"use strict";n("./index")()},{"./index":6}],9:[function(n,t,e){"use strict";var r=n("class.extend");t.exports=r.extend({init:function(n,t){this._player=n,this._seekToTime=t,this._hasFinished=!1,this._keepThisInstanceWhenPlayerSourcesChange=!1,this._seekWhenSafe()},_seekWhenSafe:function(){this._player.readyState()<3?(this._seekFn=this._seek.bind(this),this._player.one("canplay",this._seekFn)):this._seek()},onPlayerSourcesChange:function(){this._keepThisInstanceWhenPlayerSourcesChange?this._keepThisInstanceWhenPlayerSourcesChange=!1:this.cancel()},onQualitySelectionChange:function(){this.hasFinished()||(this._keepThisInstanceWhenPlayerSourcesChange=!0)},_seek:function(){this._player.currentTime(this._seekToTime),this._keepThisInstanceWhenPlayerSourcesChange=!1,this._hasFinished=!0},hasFinished:function(){return this._hasFinished},cancel:function(){this._player.off("canplay",this._seekFn),this._keepThisInstanceWhenPlayerSourcesChange=!1,this._hasFinished=!0}})},{"class.extend":1}]},{},[8]); +!function u(o,c,a){function l(e,n){if(!c[e]){if(!o[e]){var t="function"==typeof require&&require;if(!n&&t)return t(e,!0);if(s)return s(e,!0);var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}var i=c[e]={exports:{}};o[e][0].call(i.exports,function(n){return l(o[e][1][n]||n)},i,i.exports,u,o,c,a)}return c[e].exports}for(var s="function"==typeof require&&require,n=0;n<a.length;n++)l(a[n]);return l}({1:[function(n,e,t){!function(){var c=!1,a=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){},Class.extend=function(n,e){null==e&&(e=n,n="Class");var i=this.prototype;c=!0;var t=new this;for(var r in c=!1,e)t[r]="function"==typeof e[r]&&"function"==typeof i[r]&&a.test(e[r])?function(t,r){return function(){var n=this._super;this._super=i[t];var e=r.apply(this,arguments);return this._super=n,e}}(r,e[r]):e[r];function u(){!c&&this.init&&this.init.apply(this,arguments)}u.prototype=t;var o=new Function("return function "+n+"(){ }")();return u.prototype.constructor=o,u.extend=arguments.callee,u},e.exports=Class}()},{}],2:[function(n,G,H){(function($){!function(){function t(){}var n="object"==typeof self&&self.self===self&&self||"object"==typeof $&&$.global===$&&$||this||{},e=n._,r=Array.prototype,o=Object.prototype,f="undefined"!=typeof Symbol?Symbol.prototype:null,i=r.push,a=r.slice,p=o.toString,u=o.hasOwnProperty,c=Array.isArray,l=Object.keys,s=Object.create,h=function(n){return n instanceof h?n:this instanceof h?void(this._wrapped=n):new h(n)};void 0===H||H.nodeType?n._=h:(void 0!==G&&!G.nodeType&&G.exports&&(H=G.exports=h),H._=h),h.VERSION="1.9.1";function v(i,u,n){if(void 0===u)return i;switch(null==n?3:n){case 1:return function(n){return i.call(u,n)};case 3:return function(n,e,t){return i.call(u,n,e,t)};case 4:return function(n,e,t,r){return i.call(u,n,e,t,r)}}return function(){return i.apply(u,arguments)}}function y(n,e,t){return h.iteratee!==d?h.iteratee(n,e):null==n?h.identity:h.isFunction(n)?v(n,e,t):h.isObject(n)&&!h.isArray(n)?h.matcher(n):h.property(n)}var d;h.iteratee=d=function(n,e){return y(n,e,1/0)};function g(i,u){return u=null==u?i.length-1:+u,function(){for(var n=Math.max(arguments.length-u,0),e=Array(n),t=0;t<n;t++)e[t]=arguments[t+u];switch(u){case 0:return i.call(this,e);case 1:return i.call(this,arguments[0],e);case 2:return i.call(this,arguments[0],arguments[1],e)}var r=Array(u+1);for(t=0;t<u;t++)r[t]=arguments[t];return r[u]=e,i.apply(this,r)}}function m(n){if(!h.isObject(n))return{};if(s)return s(n);t.prototype=n;var e=new t;return t.prototype=null,e}function S(e){return function(n){return null==n?void 0:n[e]}}function b(n,e){return null!=n&&u.call(n,e)}function _(n,e){for(var t=e.length,r=0;r<t;r++){if(null==n)return;n=n[e[r]]}return t?n:void 0}function x(n){var e=j(n);return"number"==typeof e&&0<=e&&e<=k}var k=Math.pow(2,53)-1,j=S("length");h.each=h.forEach=function(n,e,t){var r,i;if(e=v(e,t),x(n))for(r=0,i=n.length;r<i;r++)e(n[r],r,n);else{var u=h.keys(n);for(r=0,i=u.length;r<i;r++)e(n[u[r]],u[r],n)}return n},h.map=h.collect=function(n,e,t){e=y(e,t);for(var r=!x(n)&&h.keys(n),i=(r||n).length,u=Array(i),o=0;o<i;o++){var c=r?r[o]:o;u[o]=e(n[c],c,n)}return u};function w(a){return function(n,e,t,r){var i=3<=arguments.length;return function(n,e,t,r){var i=!x(n)&&h.keys(n),u=(i||n).length,o=0<a?0:u-1;for(r||(t=n[i?i[o]:o],o+=a);0<=o&&o<u;o+=a){var c=i?i[o]:o;t=e(t,n[c],c,n)}return t}(n,v(e,r,4),t,i)}}h.reduce=h.foldl=h.inject=w(1),h.reduceRight=h.foldr=w(-1),h.find=h.detect=function(n,e,t){var r=(x(n)?h.findIndex:h.findKey)(n,e,t);if(void 0!==r&&-1!==r)return n[r]},h.filter=h.select=function(n,r,e){var i=[];return r=y(r,e),h.each(n,function(n,e,t){r(n,e,t)&&i.push(n)}),i},h.reject=function(n,e,t){return h.filter(n,h.negate(y(e)),t)},h.every=h.all=function(n,e,t){e=y(e,t);for(var r=!x(n)&&h.keys(n),i=(r||n).length,u=0;u<i;u++){var o=r?r[u]:u;if(!e(n[o],o,n))return!1}return!0},h.some=h.any=function(n,e,t){e=y(e,t);for(var r=!x(n)&&h.keys(n),i=(r||n).length,u=0;u<i;u++){var o=r?r[u]:u;if(e(n[o],o,n))return!0}return!1},h.contains=h.includes=h.include=function(n,e,t,r){return x(n)||(n=h.values(n)),"number"==typeof t&&!r||(t=0),0<=h.indexOf(n,e,t)},h.invoke=g(function(n,t,r){var i,u;return h.isFunction(t)?u=t:h.isArray(t)&&(i=t.slice(0,-1),t=t[t.length-1]),h.map(n,function(n){var e=u;if(!e){if(i&&i.length&&(n=_(n,i)),null==n)return;e=n[t]}return null==e?e:e.apply(n,r)})}),h.pluck=function(n,e){return h.map(n,h.property(e))},h.where=function(n,e){return h.filter(n,h.matcher(e))},h.findWhere=function(n,e){return h.find(n,h.matcher(e))},h.max=function(n,r,e){var t,i,u=-1/0,o=-1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var c=0,a=(n=x(n)?n:h.values(n)).length;c<a;c++)null!=(t=n[c])&&u<t&&(u=t);else r=y(r,e),h.each(n,function(n,e,t){i=r(n,e,t),(o<i||i===-1/0&&u===-1/0)&&(u=n,o=i)});return u},h.min=function(n,r,e){var t,i,u=1/0,o=1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var c=0,a=(n=x(n)?n:h.values(n)).length;c<a;c++)null!=(t=n[c])&&t<u&&(u=t);else r=y(r,e),h.each(n,function(n,e,t){((i=r(n,e,t))<o||i===1/0&&u===1/0)&&(u=n,o=i)});return u},h.shuffle=function(n){return h.sample(n,1/0)},h.sample=function(n,e,t){if(null==e||t)return x(n)||(n=h.values(n)),n[h.random(n.length-1)];var r=x(n)?h.clone(n):h.values(n),i=j(r);e=Math.max(Math.min(e,i),0);for(var u=i-1,o=0;o<e;o++){var c=h.random(o,u),a=r[o];r[o]=r[c],r[c]=a}return r.slice(0,e)},h.sortBy=function(n,r,e){var i=0;return r=y(r,e),h.pluck(h.map(n,function(n,e,t){return{value:n,index:i++,criteria:r(n,e,t)}}).sort(function(n,e){var t=n.criteria,r=e.criteria;if(t!==r){if(r<t||void 0===t)return 1;if(t<r||void 0===r)return-1}return n.index-e.index}),"value")};function A(o,e){return function(r,i,n){var u=e?[[],[]]:{};return i=y(i,n),h.each(r,function(n,e){var t=i(n,e,r);o(u,n,t)}),u}}h.groupBy=A(function(n,e,t){b(n,t)?n[t].push(e):n[t]=[e]}),h.indexBy=A(function(n,e,t){n[t]=e}),h.countBy=A(function(n,e,t){b(n,t)?n[t]++:n[t]=1});var E=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;h.toArray=function(n){return n?h.isArray(n)?a.call(n):h.isString(n)?n.match(E):x(n)?h.map(n,h.identity):h.values(n):[]},h.size=function(n){return null==n?0:x(n)?n.length:h.keys(n).length},h.partition=A(function(n,e,t){n[t?0:1].push(e)},!0),h.first=h.head=h.take=function(n,e,t){return null==n||n.length<1?null==e?void 0:[]:null==e||t?n[0]:h.initial(n,n.length-e)},h.initial=function(n,e,t){return a.call(n,0,Math.max(0,n.length-(null==e||t?1:e)))},h.last=function(n,e,t){return null==n||n.length<1?null==e?void 0:[]:null==e||t?n[n.length-1]:h.rest(n,Math.max(0,n.length-e))},h.rest=h.tail=h.drop=function(n,e,t){return a.call(n,null==e||t?1:e)},h.compact=function(n){return h.filter(n,Boolean)};var T=function(n,e,t,r){for(var i=(r=r||[]).length,u=0,o=j(n);u<o;u++){var c=n[u];if(x(c)&&(h.isArray(c)||h.isArguments(c)))if(e)for(var a=0,l=c.length;a<l;)r[i++]=c[a++];else T(c,e,t,r),i=r.length;else t||(r[i++]=c)}return r};h.flatten=function(n,e){return T(n,e,!1)},h.without=g(function(n,e){return h.difference(n,e)}),h.uniq=h.unique=function(n,e,t,r){h.isBoolean(e)||(r=t,t=e,e=!1),null!=t&&(t=y(t,r));for(var i=[],u=[],o=0,c=j(n);o<c;o++){var a=n[o],l=t?t(a,o,n):a;e&&!t?(o&&u===l||i.push(a),u=l):t?h.contains(u,l)||(u.push(l),i.push(a)):h.contains(i,a)||i.push(a)}return i},h.union=g(function(n){return h.uniq(T(n,!0,!0))}),h.intersection=function(n){for(var e=[],t=arguments.length,r=0,i=j(n);r<i;r++){var u=n[r];if(!h.contains(e,u)){var o;for(o=1;o<t&&h.contains(arguments[o],u);o++);o===t&&e.push(u)}}return e},h.difference=g(function(n,e){return e=T(e,!0,!0),h.filter(n,function(n){return!h.contains(e,n)})}),h.unzip=function(n){for(var e=n&&h.max(n,j).length||0,t=Array(e),r=0;r<e;r++)t[r]=h.pluck(n,r);return t},h.zip=g(h.unzip),h.object=function(n,e){for(var t={},r=0,i=j(n);r<i;r++)e?t[n[r]]=e[r]:t[n[r][0]]=n[r][1];return t};function O(u){return function(n,e,t){e=y(e,t);for(var r=j(n),i=0<u?0:r-1;0<=i&&i<r;i+=u)if(e(n[i],i,n))return i;return-1}}h.findIndex=O(1),h.findLastIndex=O(-1),h.sortedIndex=function(n,e,t,r){for(var i=(t=y(t,r,1))(e),u=0,o=j(n);u<o;){var c=Math.floor((u+o)/2);t(n[c])<i?u=c+1:o=c}return u};function C(u,o,c){return function(n,e,t){var r=0,i=j(n);if("number"==typeof t)0<u?r=0<=t?t:Math.max(t+i,r):i=0<=t?Math.min(t+1,i):t+i+1;else if(c&&t&&i)return n[t=c(n,e)]===e?t:-1;if(e!=e)return 0<=(t=o(a.call(n,r,i),h.isNaN))?t+r:-1;for(t=0<u?r:i-1;0<=t&&t<i;t+=u)if(n[t]===e)return t;return-1}}h.indexOf=C(1,h.findIndex,h.sortedIndex),h.lastIndexOf=C(-1,h.findLastIndex),h.range=function(n,e,t){null==e&&(e=n||0,n=0),t=t||(e<n?-1:1);for(var r=Math.max(Math.ceil((e-n)/t),0),i=Array(r),u=0;u<r;u++,n+=t)i[u]=n;return i},h.chunk=function(n,e){if(null==e||e<1)return[];for(var t=[],r=0,i=n.length;r<i;)t.push(a.call(n,r,r+=e));return t};function I(n,e,t,r,i){if(!(r instanceof e))return n.apply(t,i);var u=m(n.prototype),o=n.apply(u,i);return h.isObject(o)?o:u}h.bind=g(function(e,t,r){if(!h.isFunction(e))throw new TypeError("Bind must be called on a function");var i=g(function(n){return I(e,i,t,this,r.concat(n))});return i}),h.partial=g(function(i,u){var o=h.partial.placeholder,c=function(){for(var n=0,e=u.length,t=Array(e),r=0;r<e;r++)t[r]=u[r]===o?arguments[n++]:u[r];for(;n<arguments.length;)t.push(arguments[n++]);return I(i,c,this,this,t)};return c}),(h.partial.placeholder=h).bindAll=g(function(n,e){var t=(e=T(e,!1,!1)).length;if(t<1)throw new Error("bindAll must be passed function names");for(;t--;){var r=e[t];n[r]=h.bind(n[r],n)}}),h.memoize=function(r,i){var u=function(n){var e=u.cache,t=""+(i?i.apply(this,arguments):n);return b(e,t)||(e[t]=r.apply(this,arguments)),e[t]};return u.cache={},u},h.delay=g(function(n,e,t){return setTimeout(function(){return n.apply(null,t)},e)}),h.defer=h.partial(h.delay,h,1),h.throttle=function(t,r,i){var u,o,c,a,l=0;i=i||{};function s(){l=!1===i.leading?0:h.now(),u=null,a=t.apply(o,c),u||(o=c=null)}function n(){var n=h.now();l||!1!==i.leading||(l=n);var e=r-(n-l);return o=this,c=arguments,e<=0||r<e?(u&&(clearTimeout(u),u=null),l=n,a=t.apply(o,c),u||(o=c=null)):u||!1===i.trailing||(u=setTimeout(s,e)),a}return n.cancel=function(){clearTimeout(u),l=0,u=o=c=null},n},h.debounce=function(t,r,i){function u(n,e){o=null,e&&(c=t.apply(n,e))}var o,c,n=g(function(n){if(o&&clearTimeout(o),i){var e=!o;o=setTimeout(u,r),e&&(c=t.apply(this,n))}else o=h.delay(u,r,this,n);return c});return n.cancel=function(){clearTimeout(o),o=null},n},h.wrap=function(n,e){return h.partial(e,n)},h.negate=function(n){return function(){return!n.apply(this,arguments)}},h.compose=function(){var t=arguments,r=t.length-1;return function(){for(var n=r,e=t[r].apply(this,arguments);n--;)e=t[n].call(this,e);return e}},h.after=function(n,e){return function(){if(--n<1)return e.apply(this,arguments)}},h.before=function(n,e){var t;return function(){return 0<--n&&(t=e.apply(this,arguments)),n<=1&&(e=null),t}},h.once=h.partial(h.before,2),h.restArguments=g;function F(n,e){var t=M.length,r=n.constructor,i=h.isFunction(r)&&r.prototype||o,u="constructor";for(b(n,u)&&!h.contains(e,u)&&e.push(u);t--;)(u=M[t])in n&&n[u]!==i[u]&&!h.contains(e,u)&&e.push(u)}var q=!{toString:null}.propertyIsEnumerable("toString"),M=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];h.keys=function(n){if(!h.isObject(n))return[];if(l)return l(n);var e=[];for(var t in n)b(n,t)&&e.push(t);return q&&F(n,e),e},h.allKeys=function(n){if(!h.isObject(n))return[];var e=[];for(var t in n)e.push(t);return q&&F(n,e),e},h.values=function(n){for(var e=h.keys(n),t=e.length,r=Array(t),i=0;i<t;i++)r[i]=n[e[i]];return r},h.mapObject=function(n,e,t){e=y(e,t);for(var r=h.keys(n),i=r.length,u={},o=0;o<i;o++){var c=r[o];u[c]=e(n[c],c,n)}return u},h.pairs=function(n){for(var e=h.keys(n),t=e.length,r=Array(t),i=0;i<t;i++)r[i]=[e[i],n[e[i]]];return r},h.invert=function(n){for(var e={},t=h.keys(n),r=0,i=t.length;r<i;r++)e[n[t[r]]]=t[r];return e},h.functions=h.methods=function(n){var e=[];for(var t in n)h.isFunction(n[t])&&e.push(t);return e.sort()};function N(a,l){return function(n){var e=arguments.length;if(l&&(n=Object(n)),e<2||null==n)return n;for(var t=1;t<e;t++)for(var r=arguments[t],i=a(r),u=i.length,o=0;o<u;o++){var c=i[o];l&&void 0!==n[c]||(n[c]=r[c])}return n}}h.extend=N(h.allKeys),h.extendOwn=h.assign=N(h.keys),h.findKey=function(n,e,t){e=y(e,t);for(var r,i=h.keys(n),u=0,o=i.length;u<o;u++)if(e(n[r=i[u]],r,n))return r};function Q(n,e,t){return e in t}var L,R;h.pick=g(function(n,e){var t={},r=e[0];if(null==n)return t;h.isFunction(r)?(1<e.length&&(r=v(r,e[1])),e=h.allKeys(n)):(r=Q,e=T(e,!1,!1),n=Object(n));for(var i=0,u=e.length;i<u;i++){var o=e[i],c=n[o];r(c,o,n)&&(t[o]=c)}return t}),h.omit=g(function(n,t){var e,r=t[0];return h.isFunction(r)?(r=h.negate(r),1<t.length&&(e=t[1])):(t=h.map(T(t,!1,!1),String),r=function(n,e){return!h.contains(t,e)}),h.pick(n,r,e)}),h.defaults=N(h.allKeys,!0),h.create=function(n,e){var t=m(n);return e&&h.extendOwn(t,e),t},h.clone=function(n){return h.isObject(n)?h.isArray(n)?n.slice():h.extend({},n):n},h.tap=function(n,e){return e(n),n},h.isMatch=function(n,e){var t=h.keys(e),r=t.length;if(null==n)return!r;for(var i=Object(n),u=0;u<r;u++){var o=t[u];if(e[o]!==i[o]||!(o in i))return!1}return!0},L=function(n,e,t,r){if(n===e)return 0!==n||1/n==1/e;if(null==n||null==e)return!1;if(n!=n)return e!=e;var i=typeof n;return("function"==i||"object"==i||"object"==typeof e)&&R(n,e,t,r)},R=function(n,e,t,r){n instanceof h&&(n=n._wrapped),e instanceof h&&(e=e._wrapped);var i=p.call(n);if(i!==p.call(e))return!1;switch(i){case"[object RegExp]":case"[object String]":return""+n==""+e;case"[object Number]":return+n!=+n?+e!=+e:0==+n?1/+n==1/e:+n==+e;case"[object Date]":case"[object Boolean]":return+n==+e;case"[object Symbol]":return f.valueOf.call(n)===f.valueOf.call(e)}var u="[object Array]"===i;if(!u){if("object"!=typeof n||"object"!=typeof e)return!1;var o=n.constructor,c=e.constructor;if(o!==c&&!(h.isFunction(o)&&o instanceof o&&h.isFunction(c)&&c instanceof c)&&"constructor"in n&&"constructor"in e)return!1}r=r||[];for(var a=(t=t||[]).length;a--;)if(t[a]===n)return r[a]===e;if(t.push(n),r.push(e),u){if((a=n.length)!==e.length)return!1;for(;a--;)if(!L(n[a],e[a],t,r))return!1}else{var l,s=h.keys(n);if(a=s.length,h.keys(e).length!==a)return!1;for(;a--;)if(l=s[a],!b(e,l)||!L(n[l],e[l],t,r))return!1}return t.pop(),r.pop(),!0},h.isEqual=function(n,e){return L(n,e)},h.isEmpty=function(n){return null==n||(x(n)&&(h.isArray(n)||h.isString(n)||h.isArguments(n))?0===n.length:0===h.keys(n).length)},h.isElement=function(n){return!(!n||1!==n.nodeType)},h.isArray=c||function(n){return"[object Array]"===p.call(n)},h.isObject=function(n){var e=typeof n;return"function"==e||"object"==e&&!!n},h.each(["Arguments","Function","String","Number","Date","RegExp","Error","Symbol","Map","WeakMap","Set","WeakSet"],function(e){h["is"+e]=function(n){return p.call(n)==="[object "+e+"]"}}),h.isArguments(arguments)||(h.isArguments=function(n){return b(n,"callee")});var U=n.document&&n.document.childNodes;"function"!=typeof/./&&"object"!=typeof Int8Array&&"function"!=typeof U&&(h.isFunction=function(n){return"function"==typeof n||!1}),h.isFinite=function(n){return!h.isSymbol(n)&&isFinite(n)&&!isNaN(parseFloat(n))},h.isNaN=function(n){return h.isNumber(n)&&isNaN(n)},h.isBoolean=function(n){return!0===n||!1===n||"[object Boolean]"===p.call(n)},h.isNull=function(n){return null===n},h.isUndefined=function(n){return void 0===n},h.has=function(n,e){if(!h.isArray(e))return b(n,e);for(var t=e.length,r=0;r<t;r++){var i=e[r];if(null==n||!u.call(n,i))return!1;n=n[i]}return!!t},h.noConflict=function(){return n._=e,this},h.identity=function(n){return n},h.constant=function(n){return function(){return n}},h.noop=function(){},h.property=function(e){return h.isArray(e)?function(n){return _(n,e)}:S(e)},h.propertyOf=function(e){return null==e?function(){}:function(n){return h.isArray(n)?_(e,n):e[n]}},h.matcher=h.matches=function(e){return e=h.extendOwn({},e),function(n){return h.isMatch(n,e)}},h.times=function(n,e,t){var r=Array(Math.max(0,n));e=v(e,t,1);for(var i=0;i<n;i++)r[i]=e(i);return r},h.random=function(n,e){return null==e&&(e=n,n=0),n+Math.floor(Math.random()*(e-n+1))},h.now=Date.now||function(){return(new Date).getTime()};function W(e){function t(n){return e[n]}var n="(?:"+h.keys(e).join("|")+")",r=RegExp(n),i=RegExp(n,"g");return function(n){return n=null==n?"":""+n,r.test(n)?n.replace(i,t):n}}var D={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},B=h.invert(D);h.escape=W(D),h.unescape=W(B),h.result=function(n,e,t){h.isArray(e)||(e=[e]);var r=e.length;if(!r)return h.isFunction(t)?t.call(n):t;for(var i=0;i<r;i++){var u=null==n?void 0:n[e[i]];void 0===u&&(u=t,i=r),n=h.isFunction(u)?u.call(n):u}return n};var P=0;h.uniqueId=function(n){var e=++P+"";return n?n+e:e},h.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};function z(n){return"\\"+K[n]}var Y=/(.)^/,K={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},V=/\\|'|\r|\n|\u2028|\u2029/g;h.template=function(u,n,e){!n&&e&&(n=e),n=h.defaults({},n,h.templateSettings);var t,r=RegExp([(n.escape||Y).source,(n.interpolate||Y).source,(n.evaluate||Y).source].join("|")+"|$","g"),o=0,c="__p+='";u.replace(r,function(n,e,t,r,i){return c+=u.slice(o,i).replace(V,z),o=i+n.length,e?c+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'":t?c+="'+\n((__t=("+t+"))==null?'':__t)+\n'":r&&(c+="';\n"+r+"\n__p+='"),n}),c+="';\n",n.variable||(c="with(obj||{}){\n"+c+"}\n"),c="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+c+"return __p;\n";try{t=new Function(n.variable||"obj","_",c)}catch(n){throw n.source=c,n}function i(n){return t.call(this,n,h)}var a=n.variable||"obj";return i.source="function("+a+"){\n"+c+"}",i},h.chain=function(n){var e=h(n);return e._chain=!0,e};function J(n,e){return n._chain?h(e).chain():e}h.mixin=function(t){return h.each(h.functions(t),function(n){var e=h[n]=t[n];h.prototype[n]=function(){var n=[this._wrapped];return i.apply(n,arguments),J(this,e.apply(h,n))}}),h},h.mixin(h),h.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];h.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!==e&&"splice"!==e||0!==n.length||delete n[0],J(this,n)}}),h.each(["concat","join","slice"],function(n){var e=r[n];h.prototype[n]=function(){return J(this,e.apply(this._wrapped,arguments))}}),h.prototype.value=function(){return this._wrapped},h.prototype.valueOf=h.prototype.toJSON=h.prototype.value,h.prototype.toString=function(){return String(this._wrapped)},"function"==typeof define&&define.amd&&define("underscore",[],function(){return h})}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(n,e,t){"use strict";var i=n("underscore"),u=n("../events");e.exports=function(n){var r=n.getComponent("MenuItem");return n.extend(r,{constructor:function(n,e){var t=e.source;if(!i.isObject(t))throw new Error('was not provided a "source" object, but rather: '+typeof t);e=i.extend({selectable:!0,label:t.label},e),r.call(this,n,e),this.source=t},handleClick:function(n){r.prototype.handleClick.call(this,n),this.player().trigger(u.QUALITY_REQUESTED,this.source)}})}},{"../events":5,underscore:2}],4:[function(n,e,t){"use strict";var i=n("underscore"),u=n("../events"),o=n("./QualityOption"),c="vjs-quality-changing";e.exports=function(n){var e,r=n.getComponent("MenuButton"),t=o(n);return e=n.extend(r,{constructor:function(t,n){r.call(this,t,n),t.on(u.QUALITY_REQUESTED,function(n,e){this.setSelectedSource(e),t.addClass(c),t.one("loadeddata",function(){t.removeClass(c)})}.bind(this)),t.on(u.QUALITY_SELECTED,function(n,e){this.setSelectedSource(e)}.bind(this)),t.one("ready",function(){this.selectedSrc=t.src(),this.update()}.bind(this)),this.controlText("Open quality selector menu")},setSelectedSource:function(n){var e=n?n.src:void 0;this.selectedSrc!==e&&(this.selectedSrc=e,i.each(this.items,function(n){n.selected(n.source.src===e)}))},createItems:function(){var e=this.player(),n=e.currentSources();return i.map(n,function(n){return new t(e,{source:n,selected:n.src===this.selectedSrc})}.bind(this))},buildWrapperCSSClass:function(){return"vjs-quality-selector "+r.prototype.buildWrapperCSSClass.call(this)}}),n.registerComponent("QualitySelector",e),e}},{"../events":5,"./QualityOption":3,underscore:2}],5:[function(n,e,t){"use strict";e.exports={QUALITY_REQUESTED:"qualityRequested",QUALITY_SELECTED:"qualitySelected"}},{}],6:[function(n,e,t){"use strict";var c=n("underscore"),r=n("./events"),i=n("./components/QualitySelector"),u=n("./middleware/SourceInterceptor"),a=n("./util/SafeSeek");e.exports=function(n){n=n||window.videojs,i(n),u(n),n.hook("setup",function(o){o.on(r.QUALITY_REQUESTED,function(n,e){var t=o.currentSources(),r=o.currentTime(),i=o.playbackRate(),u=o.paused();c.each(t,function(n){n.selected=!1}),c.findWhere(t,{src:e.src}).selected=!0,o._qualitySelectorSafeSeek&&o._qualitySelectorSafeSeek.onQualitySelectionChange(),o.src(t),o.ready(function(){o._qualitySelectorSafeSeek&&!o._qualitySelectorSafeSeek.hasFinished()||(o._qualitySelectorSafeSeek=new a(o,r),o.playbackRate(i)),u||o.play()})})})},e.exports.EVENTS=r},{"./components/QualitySelector":4,"./events":5,"./middleware/SourceInterceptor":7,"./util/SafeSeek":9,underscore:2}],7:[function(n,e,t){"use strict";var u=n("underscore"),o=n("../events");e.exports=function(n){n.use("*",function(i){return{setSource:function(n,e){var t,r=i.currentSources();i._qualitySelectorSafeSeek&&i._qualitySelectorSafeSeek.onPlayerSourcesChange(),t=u.find(r,function(n){return!0===n.selected||"true"===n.selected})||n,i.trigger(o.QUALITY_SELECTED,t),e(null,t)}}})}},{"../events":5,underscore:2}],8:[function(n,e,t){"use strict";n("./index")()},{"./index":6}],9:[function(n,e,t){"use strict";var r=n("class.extend");e.exports=r.extend({init:function(n,e){this._player=n,this._seekToTime=e,this._hasFinished=!1,this._keepThisInstanceWhenPlayerSourcesChange=!1,this._seekWhenSafe()},_seekWhenSafe:function(){this._player.readyState()<3?(this._seekFn=this._seek.bind(this),this._player.one("canplay",this._seekFn)):this._seek()},onPlayerSourcesChange:function(){this._keepThisInstanceWhenPlayerSourcesChange?this._keepThisInstanceWhenPlayerSourcesChange=!1:this.cancel()},onQualitySelectionChange:function(){this.hasFinished()||(this._keepThisInstanceWhenPlayerSourcesChange=!0)},_seek:function(){this._player.currentTime(this._seekToTime),this._keepThisInstanceWhenPlayerSourcesChange=!1,this._hasFinished=!0},hasFinished:function(){return this._hasFinished},cancel:function(){this._player.off("canplay",this._seekFn),this._keepThisInstanceWhenPlayerSourcesChange=!1,this._hasFinished=!0}})},{"class.extend":1}]},{},[8]); //# sourceMappingURL=silvermine-videojs-quality-selector.min.js.map
\ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index f29de7e1..5cf5997d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,5 @@ FROM alpine:edge AS builder -RUN apk add -u crystal shards libc-dev \ +RUN apk add --no-cache crystal shards libc-dev \ yaml-dev libxml2-dev sqlite-dev zlib-dev openssl-dev \ sqlite-static zlib-static openssl-libs-static WORKDIR /invidious @@ -9,13 +9,13 @@ COPY ./src/ ./src/ # TODO: .git folder is required for building – this is destructive. # See definition of CURRENT_BRANCH, CURRENT_COMMIT and CURRENT_VERSION. COPY ./.git/ ./.git/ -RUN crystal build --static --release \ +RUN crystal build --static --release --warnings all --error-on-warnings \ # TODO: Remove next line, see https://github.com/crystal-lang/crystal/issues/7946 -Dmusl \ ./src/invidious.cr FROM alpine:latest -RUN apk add -u imagemagick ttf-opensans +RUN apk add --no-cache imagemagick ttf-opensans WORKDIR /invidious RUN addgroup -g 1000 -S invidious && \ adduser -u 1000 -S invidious -G invidious diff --git a/locales/el.json b/locales/el.json index 32f154a1..222b7d0a 100644 --- a/locales/el.json +++ b/locales/el.json @@ -1,10 +1,10 @@ { "`x` subscribers": { - "(\\D|^)1(\\D|$)": "`x` συνδρομητής", + "([^0-9]|^)1([^,0-9]|$)": "`x` συνδρομητής", "": "`x` συνδρομητές" }, "`x` videos": { - "(\\D|^)1(\\D|$)": "`x` βίντεο", + "([^0-9]|^)1([^,0-9]|$)": "`x` βίντεο", "": "`x` βίντεο" }, "LIVE": "ΖΩΝΤΑΝΑ", @@ -119,11 +119,11 @@ "Token manager": "Διαχειριστής διασυνδέσεων", "Token": "Διασύνδεση", "`x` subscriptions": { - "(\\D|^)1(\\D|$)": "`x` συνδρομή", + "([^0-9]|^)1([^,0-9]|$)": "`x` συνδρομή", "": "`x` συνδρομές" }, "`x` tokens": { - "(\\D|^)1(\\D|$)": "`x` διασύνδεση", + "([^0-9]|^)1([^,0-9]|$)": "`x` διασύνδεση", "": "`x` διασυνδέσεις" }, "Import/export": "Εισαγωγή/εξαγωγή", @@ -131,7 +131,7 @@ "revoke": "ανάκληση", "Subscriptions": "Συνδρομές", "`x` unseen notifications": { - "(\\D|^)1(\\D|$)": "`x` καινούρια ειδοποίηση", + "([^0-9]|^)1([^,0-9]|$)": "`x` καινούρια ειδοποίηση", "": "`x` καινούριες ειδοποιήσεις" }, "search": "αναζήτηση", @@ -154,7 +154,7 @@ "Blacklisted regions: ": "Μη-επιτρεπτές περιοχές: ", "Shared `x`": "Μοιράστηκε το `x`", "`x` views": { - "(\\D|^)1(\\D|$)": "`x` προβολή", + "([^0-9]|^)1([^,0-9]|$)": "`x` προβολή", "": "`x` προβολές" }, "Premieres in `x`": "Πρώτη προβολή σε `x`", @@ -188,13 +188,13 @@ "Could not get channel info.": "Αδύναμια εύρεσης πληροφοριών καναλιού.", "Could not fetch comments": "Αδυναμία λήψης σχολίων", "View `x` replies": { - "(\\D|^)1(\\D|$)": "Προβολή `x` απάντησης", + "([^0-9]|^)1([^,0-9]|$)": "Προβολή `x` απάντησης", "": "Προβολή `x` απαντήσεων" }, "`x` ago": "Πριν `x`", "Load more": "Φόρτωση περισσότερων", "`x` points": { - "(\\D|^)1(\\D|$)": "`x` βαθμός", + "([^0-9]|^)1([^,0-9]|$)": "`x` βαθμός", "": "`x` βαθμοί" }, "Could not create mix.": "Αδυναμία δημιουργίας μίξης.", @@ -315,31 +315,31 @@ "Yoruba": "Γιορούμπα", "Zulu": "Ζουλού", "`x` years": { - "(\\D|^)1(\\D|$)": "`x` χρόνο", + "([^0-9]|^)1([^,0-9]|$)": "`x` χρόνο", "": "`x` χρόνια" }, "`x` months": { - "(\\D|^)1(\\D|$)": "`x` μήνα", + "([^0-9]|^)1([^,0-9]|$)": "`x` μήνα", "": "`x` μήνες" }, "`x` weeks": { - "(\\D|^)1(\\D|$)": "`x` εβδομάδα", + "([^0-9]|^)1([^,0-9]|$)": "`x` εβδομάδα", "": "`x` εβδομάδες" }, "`x` days": { - "(\\D|^)1(\\D|$)": "`x` ημέρα", + "([^0-9]|^)1([^,0-9]|$)": "`x` ημέρα", "": "`x` ημέρες" }, "`x` hours": { - "(\\D|^)1(\\D|$)": "`x` ώρα", + "([^0-9]|^)1([^,0-9]|$)": "`x` ώρα", "": "`x` ώρες" }, "`x` minutes": { - "(\\D|^)1(\\D|$)": "`x` λεπτό", + "([^0-9]|^)1([^,0-9]|$)": "`x` λεπτό", "": "`x` λεπτά" }, "`x` seconds": { - "(\\D|^)1(\\D|$)": "`x` δευτερόλεπτο", + "([^0-9]|^)1([^,0-9]|$)": "`x` δευτερόλεπτο", "": "`x` δευτερόλεπτα" }, "Fallback comments: ": "Εναλλακτικά σχόλια: ", diff --git a/locales/en-US.json b/locales/en-US.json index 580d9ead..8aaeee48 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -1,10 +1,10 @@ { "`x` subscribers": { - "(\\D|^)1(\\D|$)": "`x` subscriber", + "([^0-9]|^)1([^,0-9]|$)": "`x` subscriber", "": "`x` subscribers" }, "`x` videos": { - "(\\D|^)1(\\D|$)": "`x` video", + "([^0-9]|^)1([^,0-9]|$)": "`x` video", "": "`x` videos" }, "LIVE": "LIVE", @@ -119,11 +119,11 @@ "Token manager": "Token manager", "Token": "Token", "`x` subscriptions": { - "(\\D|^)1(\\D|$)": "`x` subscription", + "([^0-9]|^)1([^,0-9]|$)": "`x` subscription", "": "`x` subscriptions" }, "`x` tokens": { - "(\\D|^)1(\\D|$)": "`x` token", + "([^0-9]|^)1([^,0-9]|$)": "`x` token", "": "`x` tokens" }, "Import/export": "Import/export", @@ -131,7 +131,7 @@ "revoke": "revoke", "Subscriptions": "Subscriptions", "`x` unseen notifications": { - "(\\D|^)1(\\D|$)": "`x` unseen notification", + "([^0-9]|^)1([^,0-9]|$)": "`x` unseen notification", "": "`x` unseen notifications" }, "search": "search", @@ -154,7 +154,7 @@ "Blacklisted regions: ": "Blacklisted regions: ", "Shared `x`": "Shared `x`", "`x` views": { - "(\\D|^)1(\\D|$)": "`x` views", + "([^0-9]|^)1([^,0-9]|$)": "`x` views", "": "`x` views" }, "Premieres in `x`": "Premieres in `x`", @@ -188,13 +188,13 @@ "Could not get channel info.": "Could not get channel info.", "Could not fetch comments": "Could not fetch comments", "View `x` replies": { - "(\\D|^)1(\\D|$)": "View `x` reply", + "([^0-9]|^)1([^,0-9]|$)": "View `x` reply", "": "View `x` replies" }, "`x` ago": "`x` ago", "Load more": "Load more", "`x` points": { - "(\\D|^)1(\\D|$)": "`x` point", + "([^0-9]|^)1([^,0-9]|$)": "`x` point", "": "`x` points" }, "Could not create mix.": "Could not create mix.", @@ -315,31 +315,31 @@ "Yoruba": "Yoruba", "Zulu": "Zulu", "`x` years": { - "(\\D|^)1(\\D|$)": "`x` year", + "([^0-9]|^)1([^,0-9]|$)": "`x` year", "": "`x` years" }, "`x` months": { - "(\\D|^)1(\\D|$)": "`x` month", + "([^0-9]|^)1([^,0-9]|$)": "`x` month", "": "`x` months" }, "`x` weeks": { - "(\\D|^)1(\\D|$)": "`x` week", + "([^0-9]|^)1([^,0-9]|$)": "`x` week", "": "`x` weeks" }, "`x` days": { - "(\\D|^)1(\\D|$)": "`x` day", + "([^0-9]|^)1([^,0-9]|$)": "`x` day", "": "`x` days" }, "`x` hours": { - "(\\D|^)1(\\D|$)": "`x` hour", + "([^0-9]|^)1([^,0-9]|$)": "`x` hour", "": "`x` hours" }, "`x` minutes": { - "(\\D|^)1(\\D|$)": "`x` minute", + "([^0-9]|^)1([^,0-9]|$)": "`x` minute", "": "`x` minutes" }, "`x` seconds": { - "(\\D|^)1(\\D|$)": "`x` second", + "([^0-9]|^)1([^,0-9]|$)": "`x` second", "": "`x` seconds" }, "Fallback comments: ": "Fallback comments: ", diff --git a/locales/it.json b/locales/it.json index 74d42675..c2cd5d30 100644 --- a/locales/it.json +++ b/locales/it.json @@ -1,10 +1,10 @@ { "`x` subscribers": { - "(\\D|^)1(\\D|$)": "`x` iscritto", + "([^0-9]|^)1([^,0-9]|$)": "`x` iscritto", "": "`x` iscritti" }, "`x` videos": { - "(\\D|^)1(\\D|$)": "`x` video", + "([^0-9]|^)1([^,0-9]|$)": "`x` video", "": "`x` video" }, "LIVE": "IN DIRETTA", @@ -119,11 +119,11 @@ "Token manager": "Gestione dei gettoni", "Token": "Gettone", "`x` subscriptions": { - "(\\D|^)1(\\D|$)": "`x` iscrizione", + "([^0-9]|^)1([^,0-9]|$)": "`x` iscrizione", "": "`x` iscrizioni" }, "`x` tokens": { - "(\\D|^)1(\\D|$)": "`x` gettone", + "([^0-9]|^)1([^,0-9]|$)": "`x` gettone", "": "`x` gettoni" }, "Import/export": "Importa/esporta", @@ -131,7 +131,7 @@ "revoke": "revoca", "Subscriptions": "Iscrizioni", "`x` unseen notifications": { - "(\\D|^)1(\\D|$)": "`x` notifica non visualizzata", + "([^0-9]|^)1([^,0-9]|$)": "`x` notifica non visualizzata", "": "`x` notifiche non visualizzate" }, "search": "Cerca", @@ -154,7 +154,7 @@ "Blacklisted regions: ": "Regioni in lista nera: ", "Shared `x`": "Condiviso `x`", "`x` views": { - "(\\D|^)1(\\D|$)": "`x` visualizzazione", + "([^0-9]|^)1([^,0-9]|$)": "`x` visualizzazione", "": "`x` visualizzazioni" }, "Premieres in `x`": "", @@ -188,13 +188,13 @@ "Could not get channel info.": "Impossibile ottenere le informazioni del canale.", "Could not fetch comments": "Impossibile recuperare i commenti", "View `x` replies": { - "(\\D|^)1(\\D|$)": "Visualizza `x` risposta", + "([^0-9]|^)1([^,0-9]|$)": "Visualizza `x` risposta", "": "Visualizza `x` risposte" }, "`x` ago": "`x` fa", "Load more": "Carica altro", "`x` points": { - "(\\D|^)1(\\D|$)": "`x` punto", + "([^0-9]|^)1([^,0-9]|$)": "`x` punto", "": "`x` punti" }, "Could not create mix.": "Impossibile creare il mix.", @@ -315,31 +315,31 @@ "Yoruba": "Yoruba", "Zulu": "Zulu", "`x` years": { - "(\\D|^)1(\\D|$)": "`x` anno", + "([^0-9]|^)1([^,0-9]|$)": "`x` anno", "": "`x` anni" }, "`x` months": { - "(\\D|^)1(\\D|$)": "`x` mese", + "([^0-9]|^)1([^,0-9]|$)": "`x` mese", "": "`x` mesi" }, "`x` weeks": { - "(\\D|^)1(\\D|$)": "`x` settimana", + "([^0-9]|^)1([^,0-9]|$)": "`x` settimana", "": "`x` settimane" }, "`x` days": { - "(\\D|^)1(\\D|$)": "`x` giorno", + "([^0-9]|^)1([^,0-9]|$)": "`x` giorno", "": "`x` giorni" }, "`x` hours": { - "(\\D|^)1(\\D|$)": "`x` ora", + "([^0-9]|^)1([^,0-9]|$)": "`x` ora", "": "`x` ore" }, "`x` minutes": { - "(\\D|^)1(\\D|$)": "`x` minuto", + "([^0-9]|^)1([^,0-9]|$)": "`x` minuto", "": "`x` minuti" }, "`x` seconds": { - "(\\D|^)1(\\D|$)": "`x` secondo", + "([^0-9]|^)1([^,0-9]|$)": "`x` secondo", "": "`x` secondi" }, "Fallback comments: ": "Commenti alternativi: ", @@ -367,4 +367,4 @@ "Playlists": "Playlist", "Community": "Comunità", "Current version: ": "Versione attuale: " -} +}
\ No newline at end of file diff --git a/locales/tr.json b/locales/tr.json new file mode 100644 index 00000000..c47170b9 --- /dev/null +++ b/locales/tr.json @@ -0,0 +1,325 @@ +{ + "`x` subscribers.": "`x` abone.", + "`x` videos.": "`x` video.", + "LIVE": "CANLI", + "Shared `x` ago": "`x` önce paylaşıldı", + "Unsubscribe": "Abonelikten çık", + "Subscribe": "Abone ol", + "View channel on YouTube": "Kanalı YouTube'da görüntüle", + "View playlist on YouTube": "Çalma listesini YouTube'da görüntüle", + "newest": "en yeni", + "oldest": "en eski", + "popular": "popüler", + "last": "son", + "Next page": "Sonraki sayfa", + "Previous page": "Önceki sayfa", + "Clear watch history?": "İzleme geçmisini temizle?", + "New password": "Yeni parola", + "New passwords must match": "Yeni parolalar eşleşmek zorunda", + "Cannot change password for Google accounts": "Google hesapları için parola değiştirilemez", + "Authorize token?": "Jetonu yetkilendir?", + "Authorize token for `x`?": "`x` için jetonu yetkilendir?", + "Yes": "Evet", + "No": "Hayır", + "Import and Export Data": "Verileri İçe ve Dışa Aktar", + "Import": "İçe aktar", + "Import Invidious data": "İnvidious verilerini içe aktar", + "Import YouTube subscriptions": "YouTube aboneliklerini içe aktar", + "Import FreeTube subscriptions (.db)": "FreeTube aboneliklerini içe aktar (.db)", + "Import NewPipe subscriptions (.json)": "NewPipe aboneliklerini içe aktar (.json)", + "Import NewPipe data (.zip)": "NewPipe verilerini içe aktar (.zip)", + "Export": "Dışa aktar", + "Export subscriptions as OPML": "Abonelikleri OPML olarak dışa aktar", + "Export subscriptions as OPML (for NewPipe & FreeTube)": "Abonelikleri OPML olarak dışa aktar (NewPipe ve FreeTube için)", + "Export data as JSON": "Verileri JSON olarak dışa aktar", + "Delete account?": "Hesabı sil?", + "History": "Geçmiş", + "An alternative front-end to YouTube": "YouTube için alternatif bir ön-yüz", + "JavaScript license information": "JavaScript lisans bilgileri", + "source": "kaynak", + "Log in": "Oturum aç", + "Log in/register": "Oturum aç/kayıt ol", + "Log in with Google": "Google ile oturum aç", + "User ID": "Kullanıcı kimliği", + "Password": "Parola", + "Time (h:mm:ss):": "Zaman (h:mm:ss):", + "Text CAPTCHA": "Metin CAPTCHA", + "Image CAPTCHA": "Resim CAPTCHA", + "Sign In": "Oturum Aç", + "Register": "Kayıt Ol", + "E-mail": "E-posta", + "Google verification code": "Google doğrulama kodu", + "Preferences": "Tercihler", + "Player preferences": "Oynatıcı tercihleri", + "Always loop: ": "Sürekli döngü: ", + "Autoplay: ": "Otomatik oynat: ", + "Play next by default: ": "Varsayılan olarak sonrakini oynat: ", + "Autoplay next video: ": "Sonraki videoyu otomatik oynat: ", + "Listen by default: ": "Varsayılan olarak dinle: ", + "Proxy videos: ": "Videoları proxy'le: ", + "Default speed: ": "Varsayılan hız: ", + "Preferred video quality: ": "Tercih edilen video kalitesi: ", + "Player volume: ": "Oynatıcı ses seviyesi: ", + "Default comments: ": "Varsayılan yorumlar: ", + "youtube": "youtube", + "reddit": "reddit", + "Default captions: ": "Varsayılan altyazılar: ", + "Fallback captions: ": "Yedek altyazılar: ", + "Show related videos: ": "İlgili videoları göster: ", + "Show annotations by default: ": "Varsayılan olarak ek açıklamaları göster: ", + "Visual preferences": "Görsel tercihler", + "Player style: ": "Oynatıcı biçimi: ", + "Dark mode: ": "Karanlık mod: ", + "Theme: ": "Tema: ", + "dark": "karanlık", + "light": "aydınlık", + "Thin mode: ": "İnce mod: ", + "Subscription preferences": "Abonelik tercihleri", + "Show annotations by default for subscribed channels: ": "Abone olunan kanallar için ek açıklamaları varsayılan olarak göster: ", + "Redirect homepage to feed: ": "Ana sayfayı akışa yönlendir: ", + "Number of videos shown in feed: ": "Akışta gösterilen video sayısı: ", + "Sort videos by: ": "Videoları sıralama kriteri: ", + "published": "yayınlandı", + "published - reverse": "yayınlandı - ters", + "alphabetically": "alfabetik olarak", + "alphabetically - reverse": "alfabetik olarak - ters", + "channel name": "kanal adı", + "channel name - reverse": "kanal adı - ters", + "Only show latest video from channel: ": "Sadece kanaldaki en son videoyu göster: ", + "Only show latest unwatched video from channel: ": "Sadece kanaldaki en son izlenmemiş videoyu göster: ", + "Only show unwatched: ": "Sadece izlenmemişleri göster: ", + "Only show notifications (if there are any): ": "Sadece bildirimleri göster (eğer varsa): ", + "Enable web notifications": "Ağ bildirimlerini etkinleştir", + "`x` uploaded a video": "`x` bir video yükledi", + "`x` is live": "`x` canlı yayında", + "Data preferences": "Veri tercihleri", + "Clear watch history": "İzleme geçmişini temizle", + "Import/export data": "Verileri içe/dışa aktar", + "Change password": "Parolayı değiştir", + "Manage subscriptions": "Abonelikleri yönet", + "Manage tokens": "Jetonları yönet", + "Watch history": "İzleme geçmişi", + "Delete account": "Hesap silme", + "Administrator preferences": "Yönetici tercihleri", + "Default homepage: ": "Varsayılan ana sayfa: ", + "Feed menu: ": "Akış menüsü: ", + "Top enabled: ": "Top etkin: ", + "CAPTCHA enabled: ": "CAPTCHA etkin: ", + "Login enabled: ": "Oturum açma etkin: ", + "Registration enabled: ": "Kayıt olma etkin: ", + "Report statistics: ": "Rapor istatistikleri: ", + "Save preferences": "Tercihleri kaydet", + "Subscription manager": "Abonelik yöneticisi", + "Token manager": "Jeton yöneticisi", + "Token": "Jeton", + "`x` subscriptions.": "`x` abonelik.", + "`x` tokens.": "`x` jeton.", + "Import/export": "İçe/dışa aktar", + "unsubscribe": "abonelikten çık", + "revoke": "geri al", + "Subscriptions": "Abonelikler", + "`x` unseen notifications.": "`x` okunmamış bildirim.", + "search": "ara", + "Log out": "Çıkış yap", + "Released under the AGPLv3 by Omar Roth.": "Omar Roth tarafından AGPLv3 altında yayımlandı.", + "Source available here.": "Kaynak kodu burada mevcut.", + "View JavaScript license information.": "JavaScript lisans bilgilerini görüntüle.", + "View privacy policy.": "Gizlilik politikasını görüntüle.", + "Trending": "Trendler", + "Unlisted": "Listelenmemiş", + "Watch on YouTube": "YouTube'da izle", + "Hide annotations": "Ek açıklamaları gizle", + "Show annotations": "Ek açıklamaları göster", + "Genre: ": "Tür: ", + "License: ": "Lisans: ", + "Family friendly? ": "Aile için uygun? ", + "Wilson score: ": "Wilson puanı: ", + "Engagement: ": "İzleyenlerin oy verme oranı: ", + "Whitelisted regions: ": "Beyaz listeye alınan bölgeler: ", + "Blacklisted regions: ": "Kara listeye alınan bölgeler: ", + "Shared `x`": "`x` paylaşıldı", + "`x` views.": "`x` izlenme.", + "Premieres in `x`": "`x`içinde ilk gösterim", + "Premieres `x`": "`x` ilk gösterim", + "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Merhaba! JavaScript'i kapatmış gibi görünüyorsun. Yorumları görüntülemek için buraya tıkla, yüklenmelerinin biraz uzun sürebileceğini unutma.", + "View YouTube comments": "YouTube yorumlarını görüntüle", + "View more comments on Reddit": "Reddit'te daha fazla yorum görüntüle", + "View `x` comments": "`x` yorum görüntüle", + "View Reddit comments": "Reddit yorumlarını görüntüle", + "Hide replies": "Cevapları gizle", + "Show replies": "Cevapları göster", + "Incorrect password": "Yanlış parola", + "Quota exceeded, try again in a few hours": "Kota aşıldı, birkaç saat içinde tekrar deneyin", + "Unable to log in, make sure two-factor authentication (Authenticator or SMS) is turned on.": "Oturum açılamadı, iki faktörlü kimlik doğrulamanın (Authenticator ya da SMS) açık olduğundan emin olun.", + "Invalid TFA code": "Geçersiz TFA kodu", + "Login failed. This may be because two-factor authentication is not turned on for your account.": "Giriş başarısız. Bunun nedeni, hesabınız için iki faktörlü kimlik doğrulamanın açık olmaması olabilir.", + "Wrong answer": "Yanlış cevap", + "Erroneous CAPTCHA": "Hatalı CAPTCHA", + "CAPTCHA is a required field": "CAPTCHA zorunlu bir alandır", + "User ID is a required field": "Kullanıcı kimliği zorunlu bir alandır", + "Password is a required field": "Parola zorunlu bir alandır", + "Wrong username or password": "Yanlış kullanıcı adı ya da parola", + "Please sign in using 'Log in with Google'": "Lütfen 'Google ile giriş yap' seçeneğini kullanarak oturum açın", + "Password cannot be empty": "Parola boş olamaz", + "Password cannot be longer than 55 characters": "Parola 55 karakterden uzun olamaz", + "Please log in": "Lütfen oturum açın", + "Invidious Private Feed for `x`": "`x` için İnvidious Özel Akışı", + "channel:`x`": "kanal:`x`", + "Deleted or invalid channel": "Silinmiş ya da geçersiz kanal", + "This channel does not exist.": "Bu kanal mevcut değil.", + "Could not get channel info.": "Kanal bilgisi alınamadı.", + "Could not fetch comments": "Yorumlar alınamadı", + "View `x` replies.": "`x` yanıtı görüntüle.", + "`x` ago": "`x` önce", + "Load more": "Daha fazla yükle", + "`x` points.": "`x` puan.", + "Could not create mix.": "Mix oluşturulamadı.", + "Empty playlist": "Boş oynatma listesi", + "Not a playlist.": "Oynatma listesi değil.", + "Playlist does not exist.": "Oynatma listesi mevcut değil.", + "Could not pull trending pages.": "Trend sayfaları alınamıyor.", + "Hidden field \"challenge\" is a required field": "Gizli alan \"challenge\" zorunlu bir alandır", + "Hidden field \"token\" is a required field": "Gizli alan \"jeton\" zorunlu bir alandır", + "Erroneous challenge": "Hatalı challenge", + "Erroneous token": "Hatalı jeton", + "No such user": "Böyle bir kullanıcı yok", + "Token is expired, please try again": "Jetonun süresi doldu, lütfen tekrar deneyin", + "English": "İngilizce", + "English (auto-generated)": "İngilizce (otomatik oluşturuldu)", + "Afrikaans": "Afrikanca", + "Albanian": "Arnavutça", + "Amharic": "Amharca", + "Arabic": "Arapça", + "Armenian": "Ermenice", + "Azerbaijani": "Azerice", + "Bangla": "Bengalce", + "Basque": "Baskça", + "Belarusian": "Belarusça", + "Bosnian": "Boşnakça", + "Bulgarian": "Bulgarca", + "Burmese": "Birmanca", + "Catalan": "Katalanca", + "Cebuano": "Sebuanca", + "Chinese (Simplified)": "Çince (Basitleştirilmiş)", + "Chinese (Traditional)": "Çince (Geleneksel)", + "Corsican": "Korsikaca", + "Croatian": "Hırvatça", + "Czech": "Çekçe", + "Danish": "Danca", + "Dutch": "Flemenkçe", + "Esperanto": "Esperanto", + "Estonian": "Estonca", + "Filipino": "Filipince", + "Finnish": "Fince", + "French": "Fransızca", + "Galician": "Galiçyaca", + "Georgian": "Gürcüce", + "German": "Almanca", + "Greek": "Yunanca", + "Gujarati": "Guceratça", + "Haitian Creole": "Haiti Creole dili", + "Hausa": "Hausaca", + "Hawaiian": "Hawaii dili", + "Hebrew": "İbranice", + "Hindi": "Hintçe", + "Hmong": "Hmong", + "Hungarian": "Macarca", + "Icelandic": "İzlandaca", + "Igbo": "İgbo", + "Indonesian": "Endonezce", + "Irish": "İrlandaca", + "Italian": "İtalyanca", + "Japanese": "Japonca", + "Javanese": "Cava dili", + "Kannada": "Kannada dili", + "Kazakh": "Kazakça", + "Khmer": "Kmerce", + "Korean": "Korece", + "Kurdish": "Kürtçe", + "Kyrgyz": "Kırgızca", + "Lao": "Laoca", + "Latin": "Latince", + "Latvian": "Letonca", + "Lithuanian": "Litvanyaca", + "Luxembourgish": "Lüksemburgca", + "Macedonian": "Makedonca", + "Malagasy": "Malgaşça", + "Malay": "Malayca", + "Malayalam": "Malayalam dili", + "Maltese": "Maltaca", + "Maori": "Maori dili", + "Marathi": "Marati dili", + "Mongolian": "Moğolca", + "Nepali": "Nepalce", + "Norwegian Bokmål": "Norveççe Bokmål", + "Nyanja": "Çevaca", + "Pashto": "Peştuca", + "Persian": "Farsça", + "Polish": "Lehçe", + "Portuguese": "Portekizce", + "Punjabi": "Pencap dili", + "Romanian": "Rumence", + "Russian": "Rusça", + "Samoan": "Samoa dili", + "Scottish Gaelic": "İskoç Galcesi", + "Serbian": "Sırpça", + "Shona": "Şona dili", + "Sindhi": "Sintçe", + "Sinhala": "Seylanca", + "Slovak": "Slovakça", + "Slovenian": "Slovence", + "Somali": "Somalice", + "Southern Sotho": "Güney Sotho dili", + "Spanish": "İspanyolca", + "Spanish (Latin America)": "İspanyolca (Latin Amerika)", + "Sundanese": "Sundaca", + "Swahili": "Svahili dili", + "Swedish": "İsveççe", + "Tajik": "Tacikçe", + "Tamil": "Tamilce", + "Telugu": "Telugu dili", + "Thai": "Tayca", + "Turkish": "Türkçe", + "Ukrainian": "Ukraynaca", + "Urdu": "Urduca", + "Uzbek": "Özbekçe", + "Vietnamese": "Vietnamca", + "Welsh": "Galce", + "Western Frisian": "Batı Frizcesi", + "Xhosa": "Xhosa dili", + "Yiddish": "Yiddiş", + "Yoruba": "Yoruba dili", + "Zulu": "Zuluca", + "`x` years": "`x` yıl", + "`x` months": "`x` ay", + "`x` weeks": "`x` hafta", + "`x` days": "`x` gün", + "`x` hours": "`x` saat", + "`x` minutes": "`x` dakika", + "`x` seconds": "`x` saniye", + "Fallback comments: ": "Yedek yorumlar: ", + "Popular": "Popüler", + "Top": "Enler", + "About": "Hakkında", + "Rating: ": "Değerlendirme: ", + "Language: ": "Dil: ", + "View as playlist": "Oynatma listesi olarak görüntüle", + "Default": "Varsayılan", + "Music": "Müzik", + "Gaming": "Oyun", + "News": "Haberler", + "Movies": "Filmler", + "Download": "İndir", + "Download as: ": "Şu şekilde indir: ", + "%A %B %-d, %Y": "%A %B %-d, %Y", + "(edited)": "(düzenlendi)", + "YouTube comment permalink": "YouTube yorumu kalıcı linki", + "permalink": "kalıcı link", + "`x` marked it with a ❤": "`x` ❤ ile işaretlendi", + "Audio mode": "Ses modu", + "Video mode": "Video modu", + "Videos": "Videolar", + "Playlists": "Oynatma listeleri", + "Community": "Topluluk", + "Current version: ": "Şu anki versiyon: " +}
\ No newline at end of file @@ -11,14 +11,14 @@ targets: dependencies: pg: github: will/crystal-pg - version: ~> 0.18.1 + version: ~> 0.19.0 sqlite3: github: crystal-lang/crystal-sqlite3 - version: ~> 0.13.0 + version: ~> 0.14.0 kemal: github: kemalcr/kemal version: ~> 0.26.0 -crystal: 0.30.1 +crystal: 0.31.0 license: AGPLv3 diff --git a/src/invidious.cr b/src/invidious.cr index 42a2b23a..c5101e4f 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -17,7 +17,6 @@ require "digest/md5" require "file_utils" require "kemal" -require "markdown" require "openssl/hmac" require "option_parser" require "pg" @@ -86,6 +85,7 @@ LOCALES = { "nl" => load_locale("nl"), "pl" => load_locale("pl"), "ru" => load_locale("ru"), + "tr" => load_locale("tr"), "uk" => load_locale("uk"), "zh-CN" => load_locale("zh-CN"), } @@ -296,7 +296,7 @@ before_all do |env| current_page += "?#{query}" end - env.set "current_page", URI.escape(current_page) + env.set "current_page", URI.encode_www_form(current_page) end get "/" do |env| @@ -391,7 +391,7 @@ get "/watch" do |env| begin video = get_video(id, PG_DB, region: params.region) rescue ex : VideoRedirect - next env.redirect "/watch?v=#{ex.message}" + next env.redirect env.request.resource.gsub(id, ex.video_id) rescue ex error_message = ex.message env.response.status_code = 500 @@ -668,7 +668,7 @@ get "/embed/:id" do |env| begin video = get_video(id, PG_DB, region: params.region) rescue ex : VideoRedirect - next env.redirect "/embed/#{ex.message}" + next env.redirect env.request.resource.gsub(id, ex.video_id) rescue ex error_message = ex.message env.response.status_code = 500 @@ -841,7 +841,7 @@ get "/results" do |env| page ||= 1 if query - env.redirect "/search?q=#{URI.escape(query)}&page=#{page}" + env.redirect "/search?q=#{URI.encode_www_form(query)}&page=#{page}" else env.redirect "/" end @@ -1018,6 +1018,7 @@ post "/login" do |env| headers["Content-Type"] = "application/x-www-form-urlencoded;charset=utf-8" headers["Google-Accounts-XSRF"] = "1" + headers["User-Agent"] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36" response = client.post("/_/signin/sl/lookup", headers, login_req(lookup_req)) lookup_results = JSON.parse(response.body[5..-1]) @@ -1049,7 +1050,7 @@ post "/login" do |env| traceback << "done, returned #{response.status_code}.<br/>" - headers["Cookie"] = URI.unescape(headers["Cookie"]) + headers["Cookie"] = URI.decode_www_form(headers["Cookie"]) if challenge_results[0][3]?.try &.== 7 error_message = translate(locale, "Account has temporarily been disabled") @@ -1057,6 +1058,13 @@ post "/login" do |env| next templated "error" end + # TODO: Handle Google's CAPTCHA + if captcha = challenge_results[0][-1]?.try &.[-1]?.try &.as_h?.try &.["5001"]?.try &.[-1].as_a? + error_message = "Unhandled CAPTCHA. Please try again later." + env.response.status_code = 401 + next templated "error" + end + if challenge_results[0][-1]?.try &.[5] == "INCORRECT_ANSWER_ENTERED" error_message = translate(locale, "Incorrect password") env.response.status_code = 401 @@ -1074,7 +1082,7 @@ post "/login" do |env| end # Prefer Authenticator app and SMS over unsupported protocols - if !{6, 9, 12, 15}.includes?(challenge_results[0][-1][0][0][8]) && prompt_type == 4 + if !{6, 9, 12, 15}.includes?(challenge_results[0][-1][0][0][8].as_i) && prompt_type == 2 tfa = challenge_results[0][-1][0].as_a.select { |auth_type| {6, 9, 12, 15}.includes? auth_type[8] }[0] traceback << "Selecting challenge #{tfa[8]}..." @@ -1182,8 +1190,12 @@ post "/login" do |env| break end - # TODO: Occasionally there will be a second page after login confirming - # the user's phone number ("/b/0/SmsAuthInterstitial"), which we currently choke on. + # Occasionally there will be a second page after login confirming + # the user's phone number ("/b/0/SmsAuthInterstitial"), which we currently don't handle. + + if location.includes? "/b/0/SmsAuthInterstitial" + traceback << "Unhandled dialog /b/0/SmsAuthInterstitial." + end login = client.get(location, headers) headers = login.cookies.add_request_headers(headers) @@ -1384,7 +1396,7 @@ post "/login" do |env| user_array[4] = user_array[4].to_json args = arg_array(user_array) - PG_DB.exec("INSERT INTO users VALUES (#{args})", user_array) + PG_DB.exec("INSERT INTO users VALUES (#{args})", args: user_array) PG_DB.exec("INSERT INTO session_ids VALUES ($1, $2, $3)", sid, email, Time.utc) view_name = "subscriptions_#{sha256(user.email)}" @@ -2411,7 +2423,7 @@ post "/authorize_token" do |env| access_token = generate_token(user.email, scopes, expire, HMAC_KEY, PG_DB) if callback_url - access_token = URI.escape(access_token) + access_token = URI.encode_www_form(access_token) url = URI.parse(callback_url) if url.query @@ -2634,6 +2646,8 @@ get "/feed/channel/:ucid" do |env| begin channel = get_about_info(ucid, locale) + rescue ex : ChannelRedirect + next env.redirect env.request.resource.gsub(ucid, ex.channel_id) rescue ex error_message = ex.message env.response.status_code = 500 @@ -2900,7 +2914,7 @@ post "/feed/webhook/:token" do |env| PG_DB.exec("INSERT INTO channel_videos VALUES (#{args}) \ ON CONFLICT (id) DO UPDATE SET title = $2, published = $3, \ updated = $4, ucid = $5, author = $6, length_seconds = $7, \ - live_now = $8, premiere_timestamp = $9, views = $10", video_array) + live_now = $8, premiere_timestamp = $9, views = $10", args: video_array) # Update all users affected by insert if emails.empty? @@ -3041,6 +3055,8 @@ get "/channel/:ucid" do |env| begin channel = get_about_info(ucid, locale) + rescue ex : ChannelRedirect + next env.redirect env.request.resource.gsub(ucid, ex.channel_id) rescue ex error_message = ex.message env.response.status_code = 500 @@ -3108,6 +3124,8 @@ get "/channel/:ucid/playlists" do |env| begin channel = get_about_info(ucid, locale) + rescue ex : ChannelRedirect + next env.redirect env.request.resource.gsub(ucid, ex.channel_id) rescue ex error_message = ex.message env.response.status_code = 500 @@ -3146,6 +3164,8 @@ get "/channel/:ucid/community" do |env| begin channel = get_about_info(ucid, locale) + rescue ex : ChannelRedirect + next env.redirect env.request.resource.gsub(ucid, ex.channel_id) rescue ex error_message = ex.message env.response.status_code = 500 @@ -3201,7 +3221,10 @@ get "/api/v1/storyboards/:id" do |env| begin video = get_video(id, PG_DB, region: region) rescue ex : VideoRedirect - next env.redirect "/api/v1/storyboards/#{ex.message}" + error_message = {"error" => "Video is unavailable", "videoId" => ex.video_id}.to_json + env.response.status_code = 302 + env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id) + next error_message rescue ex env.response.status_code = 500 next @@ -3286,7 +3309,10 @@ get "/api/v1/captions/:id" do |env| begin video = get_video(id, PG_DB, region: region) rescue ex : VideoRedirect - next env.redirect "/api/v1/captions/#{ex.message}" + error_message = {"error" => "Video is unavailable", "videoId" => ex.video_id}.to_json + env.response.status_code = 302 + env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id) + next error_message rescue ex env.response.status_code = 500 next @@ -3307,7 +3333,7 @@ get "/api/v1/captions/:id" do |env| json.object do json.field "label", caption.name.simpleText json.field "languageCode", caption.languageCode - json.field "url", "/api/v1/captions/#{id}?label=#{URI.escape(caption.name.simpleText)}" + json.field "url", "/api/v1/captions/#{id}?label=#{URI.encode_www_form(caption.name.simpleText)}" end end end @@ -3386,7 +3412,7 @@ get "/api/v1/captions/:id" do |env| if title = env.params.query["title"]? # https://blog.fastmail.com/2011/06/24/download-non-english-filenames/ - env.response.headers["Content-Disposition"] = "attachment; filename=\"#{URI.escape(title)}\"; filename*=UTF-8''#{URI.escape(title)}" + env.response.headers["Content-Disposition"] = "attachment; filename=\"#{URI.encode_www_form(title)}\"; filename*=UTF-8''#{URI.encode_www_form(title)}" end webvtt @@ -3574,7 +3600,7 @@ get "/api/v1/annotations/:id" do |env| id = id.sub(/^-/, 'A') end - file = URI.escape("#{id[0, 3]}/#{id}.xml") + file = URI.encode_www_form("#{id[0, 3]}/#{id}.xml") client = make_client(ARCHIVE_URL) location = client.get("/download/youtubeannotations_#{index}/#{id[0, 2]}.tar/#{file}") @@ -3626,7 +3652,10 @@ get "/api/v1/videos/:id" do |env| begin video = get_video(id, PG_DB, region: region) rescue ex : VideoRedirect - next env.redirect "/api/v1/videos/#{ex.message}" + error_message = {"error" => "Video is unavailable", "videoId" => ex.video_id}.to_json + env.response.status_code = 302 + env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id) + next error_message rescue ex error_message = {"error" => ex.message}.to_json env.response.status_code = 500 @@ -3729,6 +3758,11 @@ get "/api/v1/channels/:ucid" do |env| begin channel = get_about_info(ucid, locale) + rescue ex : ChannelRedirect + error_message = {"error" => "Channel is unavailable", "authorId" => ex.channel_id}.to_json + env.response.status_code = 302 + env.response.headers["Location"] = env.request.resource.gsub(ucid, ex.channel_id) + next error_message rescue ex error_message = {"error" => ex.message}.to_json env.response.status_code = 500 @@ -3859,6 +3893,11 @@ end begin channel = get_about_info(ucid, locale) + rescue ex : ChannelRedirect + error_message = {"error" => "Channel is unavailable", "authorId" => ex.channel_id}.to_json + env.response.status_code = 302 + env.response.headers["Location"] = env.request.resource.gsub(ucid, ex.channel_id) + next error_message rescue ex error_message = {"error" => ex.message}.to_json env.response.status_code = 500 @@ -3923,6 +3962,11 @@ end begin channel = get_about_info(ucid, locale) + rescue ex : ChannelRedirect + error_message = {"error" => "Channel is unavailable", "authorId" => ex.channel_id}.to_json + env.response.status_code = 302 + env.response.headers["Location"] = env.request.resource.gsub(ucid, ex.channel_id) + next error_message rescue ex error_message = {"error" => ex.message}.to_json env.response.status_code = 500 @@ -4055,7 +4099,7 @@ get "/api/v1/search/suggestions" do |env| begin client = make_client(URI.parse("https://suggestqueries.google.com")) - response = client.get("/complete/search?hl=en&gl=#{region}&client=youtube&ds=yt&q=#{URI.escape(query)}&callback=suggestCallback").body + response = client.get("/complete/search?hl=en&gl=#{region}&client=youtube&ds=yt&q=#{URI.encode_www_form(query)}&callback=suggestCallback").body body = response[35..-2] body = JSON.parse(body).as_a @@ -4439,7 +4483,7 @@ post "/api/v1/auth/tokens/register" do |env| access_token = generate_token(user.email, authorized_scopes, expire, HMAC_KEY, PG_DB) if callback_url - access_token = URI.escape(access_token) + access_token = URI.encode_www_form(access_token) if query = callback_url.query query = HTTP::Params.parse(query.not_nil!) @@ -4507,11 +4551,7 @@ get "/api/manifest/dash/id/:id" do |env| begin video = get_video(id, PG_DB, region: region) rescue ex : VideoRedirect - url = "/api/manifest/dash/id/#{ex.message}" - if env.params.query - url += "?#{env.params.query}" - end - next env.redirect url + next env.redirect env.request.resource.gsub(id, ex.video_id) rescue ex env.response.status_code = 403 next @@ -4678,7 +4718,7 @@ get "/api/manifest/hls_playlist/*" do |env| raw_params = {} of String => Array(String) path.each_slice(2) do |pair| key, value = pair - value = URI.unescape(value) + value = URI.decode_www_form(value) if raw_params[key]? raw_params[key] << value @@ -4803,7 +4843,7 @@ get "/videoplayback/*" do |env| raw_params = {} of String => Array(String) path.each_slice(2) do |pair| key, value = pair - value = URI.unescape(value) + value = URI.decode_www_form(value) if raw_params[key]? raw_params[key] << value @@ -4977,7 +5017,7 @@ get "/videoplayback" do |env| if title = query_params["title"]? # https://blog.fastmail.com/2011/06/24/download-non-english-filenames/ - env.response.headers["Content-Disposition"] = "attachment; filename=\"#{URI.escape(title)}\"; filename*=UTF-8''#{URI.escape(title)}" + env.response.headers["Content-Disposition"] = "attachment; filename=\"#{URI.encode_www_form(title)}\"; filename*=UTF-8''#{URI.encode_www_form(title)}" end if !response.headers.includes_word?("Transfer-Encoding", "chunked") @@ -5290,4 +5330,6 @@ add_context_storage_type(Preferences) add_context_storage_type(User) Kemal.config.logger = logger +Kemal.config.host_binding = Kemal.config.host_binding != "0.0.0.0" ? Kemal.config.host_binding : CONFIG.host_binding +Kemal.config.port = Kemal.config.port != 3000 ? Kemal.config.port : CONFIG.port Kemal.run diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr index 85502505..cce98310 100644 --- a/src/invidious/channels.cr +++ b/src/invidious/channels.cr @@ -120,7 +120,7 @@ struct AboutChannel description_html: String, paid: Bool, total_views: Int64, - sub_count: Int64, + sub_count: Int32, joined: Time, is_family_friendly: Bool, allowed_regions: Array(String), @@ -129,6 +129,13 @@ struct AboutChannel }) end +class ChannelRedirect < Exception + property channel_id : String + + def initialize(@channel_id) + end +end + def get_batch_channels(channels, db, refresh = false, pull_all_videos = true, max_threads = 10) finished_channel = Channel(String | Nil).new @@ -174,14 +181,14 @@ def get_channel(id, db, refresh = true, pull_all_videos = true) args = arg_array(channel_array) db.exec("INSERT INTO channels VALUES (#{args}) \ - ON CONFLICT (id) DO UPDATE SET author = $2, updated = $3", channel_array) + ON CONFLICT (id) DO UPDATE SET author = $2, updated = $3", args: channel_array) end else channel = fetch_channel(id, db, pull_all_videos: pull_all_videos) channel_array = channel.to_a args = arg_array(channel_array) - db.exec("INSERT INTO channels VALUES (#{args})", channel_array) + db.exec("INSERT INTO channels VALUES (#{args})", args: channel_array) end return channel @@ -270,7 +277,7 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil) db.exec("INSERT INTO channel_videos VALUES (#{args}) \ ON CONFLICT (id) DO UPDATE SET title = $2, published = $3, \ updated = $4, ucid = $5, author = $6, length_seconds = $7, \ - live_now = $8, views = $10", video_array) + live_now = $8, views = $10", args: video_array) # Update all users affected by insert if emails.empty? @@ -338,7 +345,7 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil) db.exec("INSERT INTO channel_videos VALUES (#{args}) \ ON CONFLICT (id) DO UPDATE SET title = $2, published = $3, \ updated = $4, ucid = $5, author = $6, length_seconds = $7, \ - live_now = $8, views = $10", video_array) + live_now = $8, views = $10", args: video_array) # Update all users affected by insert if emails.empty? @@ -471,7 +478,7 @@ def produce_channel_videos_url(ucid, page = 1, auto_generated = nil, sort_by = " end data = Base64.urlsafe_encode(data) - cursor = URI.escape(data) + cursor = URI.encode_www_form(data) data = IO::Memory.new @@ -492,7 +499,7 @@ def produce_channel_videos_url(ucid, page = 1, auto_generated = nil, sort_by = " IO.copy data, buffer continuation = Base64.urlsafe_encode(buffer) - continuation = URI.escape(continuation) + continuation = URI.encode_www_form(continuation) url = "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" @@ -542,7 +549,7 @@ def produce_channel_playlists_url(ucid, cursor, sort = "newest", auto_generated data.rewind data = Base64.urlsafe_encode(data) - continuation = URI.escape(data) + continuation = URI.encode_www_form(data) data = IO::Memory.new @@ -563,7 +570,7 @@ def produce_channel_playlists_url(ucid, cursor, sort = "newest", auto_generated IO.copy data, buffer continuation = Base64.urlsafe_encode(buffer) - continuation = URI.escape(continuation) + continuation = URI.encode_www_form(continuation) url = "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" @@ -573,7 +580,7 @@ end def extract_channel_playlists_cursor(url, auto_generated) continuation = HTTP::Params.parse(URI.parse(url).query.not_nil!)["continuation"] - continuation = URI.unescape(continuation) + continuation = URI.decode_www_form(continuation) data = IO::Memory.new(Base64.decode(continuation)) # 0xe2 0xa9 0x85 0xb2 0x02 @@ -592,7 +599,7 @@ def extract_channel_playlists_cursor(url, auto_generated) data.read inner_continuation continuation = String.new(inner_continuation) - continuation = URI.unescape(continuation) + continuation = URI.decode_www_form(continuation) data = IO::Memory.new(Base64.decode(continuation)) # 0x12 0x09 playlists @@ -609,7 +616,7 @@ def extract_channel_playlists_cursor(url, auto_generated) cursor = String.new(cursor) if !auto_generated - cursor = URI.unescape(cursor) + cursor = URI.decode_www_form(cursor) cursor = Base64.decode_string(cursor) end @@ -872,7 +879,7 @@ def fetch_channel_community(ucid, continuation, locale, config, kemal_config, fo end def produce_channel_community_continuation(ucid, cursor) - cursor = URI.escape(cursor) + cursor = URI.encode_www_form(cursor) data = IO::Memory.new @@ -893,13 +900,13 @@ def produce_channel_community_continuation(ucid, cursor) IO.copy data, buffer continuation = Base64.urlsafe_encode(buffer) - continuation = URI.escape(continuation) + continuation = URI.encode_www_form(continuation) return continuation end def extract_channel_community_cursor(continuation) - continuation = URI.unescape(continuation) + continuation = URI.decode_www_form(continuation) data = IO::Memory.new(Base64.decode(continuation)) # 0xe2 0xa9 0x85 0xb2 0x02 @@ -918,7 +925,7 @@ def extract_channel_community_cursor(continuation) data.read_byte end - return URI.unescape(data.gets_to_end) + return URI.decode_www_form(data.gets_to_end) end def get_about_info(ucid, locale) @@ -929,6 +936,10 @@ def get_about_info(ucid, locale) about = client.get("/user/#{ucid}/about?disable_polymer=1&gl=US&hl=en") end + if md = about.headers["location"]?.try &.match(/\/channel\/(?<ucid>UC[a-zA-Z0-9_-]{22})/) + raise ChannelRedirect.new(channel_id: md["ucid"]) + end + about = XML.parse_html(about.body) if about.xpath_node(%q(//div[contains(@class, "channel-empty-message")])) @@ -942,12 +953,6 @@ def get_about_info(ucid, locale) raise error_message end - sub_count = about.xpath_node(%q(//span[contains(text(), "subscribers")])) - if sub_count - sub_count = sub_count.content.delete(", subscribers").to_i? - end - sub_count ||= 0 - author = about.xpath_node(%q(//span[contains(@class,"qualified-channel-title-text")]/a)).not_nil!.content author_url = about.xpath_node(%q(//span[contains(@class,"qualified-channel-title-text")]/a)).not_nil!["href"] author_thumbnail = about.xpath_node(%q(//img[@class="channel-header-profile-image"])).not_nil!["src"] @@ -991,21 +996,14 @@ def get_about_info(ucid, locale) ) end - total_views = 0_i64 - sub_count = 0_i64 - - joined = Time.unix(0) - metadata = about.xpath_nodes(%q(//span[@class="about-stat"])) - metadata.each do |item| - case item.content - when .includes? "views" - total_views = item.content.gsub(/\D/, "").to_i64 - when .includes? "subscribers" - sub_count = item.content.delete("subscribers").gsub(/\D/, "").to_i64 - when .includes? "Joined" - joined = Time.parse(item.content.lchop("Joined "), "%b %-d, %Y", Time::Location.local) - end - end + joined = about.xpath_node(%q(//span[contains(., "Joined")])) + .try &.content.try { |text| Time.parse(text, "Joined %b %-d, %Y", Time::Location.local) } || Time.unix(0) + + total_views = about.xpath_node(%q(//span[contains(., "views")]/b)) + .try &.content.try &.gsub(/\D/, "").to_i64? || 0_i64 + + sub_count = about.xpath_node(%q(.//span[contains(@class, "subscriber-count")])) + .try &.["title"].try { |text| short_text_to_number(text) } || 0 # Auto-generated channels # https://support.google.com/youtube/answer/2579942 @@ -1017,7 +1015,7 @@ def get_about_info(ucid, locale) tabs = about.xpath_nodes(%q(//ul[@id="channel-navigation-menu"]/li/a/span)).map { |node| node.content.downcase } - return AboutChannel.new( + AboutChannel.new( ucid: ucid, author: author, auto_generated: auto_generated, diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 04ba6f5d..740449d3 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -573,7 +573,7 @@ def content_to_comment_html(content) end def extract_comment_cursor(continuation) - continuation = URI.unescape(continuation) + continuation = URI.decode_www_form(continuation) data = IO::Memory.new(Base64.decode(continuation)) # 0x12 0x26 @@ -653,7 +653,7 @@ def produce_comment_continuation(video_id, cursor = "", sort_by = "top") end continuation = Base64.urlsafe_encode(data) - continuation = URI.escape(continuation) + continuation = URI.encode_www_form(continuation) return continuation end @@ -695,7 +695,7 @@ def produce_comment_reply_continuation(video_id, ucid, comment_id) data.write(Bytes[0x48, 0x0a]) continuation = Base64.urlsafe_encode(data.to_slice) - continuation = URI.escape(continuation) + continuation = URI.encode_www_form(continuation) return continuation end diff --git a/src/invidious/helpers/handlers.cr b/src/invidious/helpers/handlers.cr index 56c1c488..949eb335 100644 --- a/src/invidious/helpers/handlers.cr +++ b/src/invidious/helpers/handlers.cr @@ -95,8 +95,8 @@ class AuthHandler < Kemal::Handler begin if token = env.request.headers["Authorization"]? - token = JSON.parse(URI.unescape(token.lchop("Bearer "))) - session = URI.unescape(token["session"].as_s) + token = JSON.parse(URI.decode_www_form(token.lchop("Bearer "))) + session = URI.decode_www_form(token["session"].as_s) scopes, expire, signature = validate_request(token, session, env.request, HMAC_KEY, PG_DB, nil) if email = PG_DB.query_one?("SELECT email FROM session_ids WHERE id = $1", session, as: String) @@ -238,40 +238,15 @@ class HTTP::Client end end -# https://github.com/will/crystal-pg/pull/171 -class PG::Statement < ::DB::Statement - protected def perform_query(args : Enumerable) : ResultSet - params = args.map { |arg| PQ::Param.encode(arg) } - conn = self.conn - conn.send_parse_message(@sql) - conn.send_bind_message params - conn.send_describe_portal_message - conn.send_execute_message - conn.send_sync_message - conn.expect_frame PQ::Frame::ParseComplete - conn.expect_frame PQ::Frame::BindComplete - frame = conn.read - case frame - when PQ::Frame::RowDescription - fields = frame.fields - when PQ::Frame::NoData - fields = nil +struct Crystal::ThreadLocalValue(T) + @values = Hash(Thread, T).new + + def get(&block : -> T) + th = Thread.current + if !@values[th]? + @values[th] = yield else - raise "expected RowDescription or NoData, got #{frame}" + @values[th] end - ResultSet.new(self, fields) - rescue IO::Error - raise DB::ConnectionLost.new(connection) - end - - protected def perform_exec(args : Enumerable) : ::DB::ExecResult - result = perform_query(args) - result.each { } - ::DB::ExecResult.new( - rows_affected: result.rows_affected, - last_insert_id: 0_i64 # postgres doesn't support this - ) - rescue IO::Error - raise DB::ConnectionLost.new(connection) end end diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index 331f6360..615e62df 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -235,6 +235,8 @@ struct Config hsts: {type: Bool?, default: true}, # Enables 'Strict-Transport-Security'. Ensure that `domain` and all subdomains are served securely disable_proxy: {type: Bool? | Array(String)?, default: false}, # Disable proxying server-wide: options: 'dash', 'livestreams', 'downloads', 'local' force_resolve: {type: Socket::Family, default: Socket::Family::UNSPEC, converter: FamilyConverter}, # Connect to YouTube over 'ipv6', 'ipv4'. Will sometimes resolve fix issues with rate-limiting (see https://github.com/ytdl-org/youtube-dl/issues/21729) + port: {type: Int32, default: 3000}, # Port to listen for connections (overrided by command line argument) + host_binding: {type: String, default: "0.0.0.0"}, # Host to bind (overrided by command line argument) }) end @@ -415,19 +417,19 @@ def extract_items(nodeset, ucid = nil, author_name = nil) author_thumbnail ||= "" - subscriber_count = node.xpath_node(%q(.//span[contains(@class, "yt-subscriber-count")])).try &.["title"].gsub(/\D/, "").to_i? - subscriber_count ||= 0 + subscriber_count = node.xpath_node(%q(.//span[contains(@class, "subscriber-count")])) + .try &.["title"].try { |text| short_text_to_number(text) } || 0 video_count = node.xpath_node(%q(.//ul[@class="yt-lockup-meta-info"]/li)).try &.content.split(" ")[0].gsub(/\D/, "").to_i? - video_count ||= 0 items << SearchChannel.new( author: author, ucid: ucid, author_thumbnail: author_thumbnail, subscriber_count: subscriber_count, - video_count: video_count, - description_html: description_html + video_count: video_count || 0, + description_html: description_html, + auto_generated: video_count ? false : true, ) else id = id.lchop("/watch?v=") diff --git a/src/invidious/helpers/patch_mapping.cr b/src/invidious/helpers/patch_mapping.cr index e138aa1c..19bd8ca1 100644 --- a/src/invidious/helpers/patch_mapping.cr +++ b/src/invidious/helpers/patch_mapping.cr @@ -50,7 +50,7 @@ macro patched_json_mapping(_properties_, strict = false) rescue exc : ::JSON::ParseException raise ::JSON::MappingError.new(exc.message, self.class.to_s, nil, *%location, exc) end - while %pull.kind != :end_object + until %pull.kind.end_object? %key_location = %pull.location key = %pull.read_object_key case key diff --git a/src/invidious/helpers/static_file_handler.cr b/src/invidious/helpers/static_file_handler.cr index 87edbcd3..20d92b9c 100644 --- a/src/invidious/helpers/static_file_handler.cr +++ b/src/invidious/helpers/static_file_handler.cr @@ -119,7 +119,7 @@ module Kemal config = Kemal.config.serve_static original_path = context.request.path.not_nil! - request_path = URI.unescape(original_path) + request_path = URI.decode_www_form(original_path) # File path cannot contains '\0' (NUL) because all filesystem I know # don't accept '\0' character as file name. diff --git a/src/invidious/helpers/tokens.cr b/src/invidious/helpers/tokens.cr index f946fc2c..30f7d4f4 100644 --- a/src/invidious/helpers/tokens.cr +++ b/src/invidious/helpers/tokens.cr @@ -69,7 +69,7 @@ end def validate_request(token, session, request, key, db, locale = nil) case token when String - token = JSON.parse(URI.unescape(token)).as_h + token = JSON.parse(URI.decode_www_form(token)).as_h when JSON::Any token = token.as_h when Nil diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index 5a813486..ed55dc9c 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -157,7 +157,7 @@ def number_with_separator(number) number.to_s.reverse.gsub(/(\d{3})(?=\d)/, "\\1,").reverse end -def short_text_to_number(short_text) +def short_text_to_number(short_text : String) : Int32 case short_text when .ends_with? "M" number = short_text.rstrip(" mM").to_f @@ -246,7 +246,7 @@ def get_referer(env, fallback = "/", unroll = true) if referer.query params = HTTP::Params.parse(referer.query.not_nil!) if params["referer"]? - referer = URI.parse(URI.unescape(params["referer"])) + referer = URI.parse(URI.decode_www_form(params["referer"])) else break end diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 7965d990..a5383daf 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -172,7 +172,7 @@ def produce_playlist_url(id, index) continuation.print data data = Base64.urlsafe_encode(continuation) - cursor = URI.escape(data) + cursor = URI.encode_www_form(data) data = IO::Memory.new @@ -193,7 +193,7 @@ def produce_playlist_url(id, index) IO.copy data, buffer continuation = Base64.urlsafe_encode(buffer) - continuation = URI.escape(continuation) + continuation = URI.encode_www_form(continuation) url = "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" diff --git a/src/invidious/search.cr b/src/invidious/search.cr index 56035160..08171ffe 100644 --- a/src/invidious/search.cr +++ b/src/invidious/search.cr @@ -187,8 +187,10 @@ struct SearchChannel end end + json.field "autoGenerated", self.auto_generated json.field "subCount", self.subscriber_count json.field "videoCount", self.video_count + json.field "description", html_to_content(self.description_html) json.field "descriptionHtml", self.description_html end @@ -211,6 +213,7 @@ struct SearchChannel subscriber_count: Int32, video_count: Int32, description_html: String, + auto_generated: Bool, }) end @@ -265,7 +268,7 @@ def search(query, page = 1, search_params = produce_search_params(content_type: return {0, [] of SearchItem} end - html = client.get("/results?q=#{URI.escape(query)}&page=#{page}&sp=#{search_params}&hl=en&disable_polymer=1").body + html = client.get("/results?q=#{URI.encode_www_form(query)}&page=#{page}&sp=#{search_params}&hl=en&disable_polymer=1").body if html.empty? return {0, [] of SearchItem} end @@ -370,7 +373,7 @@ def produce_search_params(sort : String = "relevance", date : String = "", conte end token = Base64.urlsafe_encode(token.to_slice) - token = URI.escape(token) + token = URI.encode_www_form(token) return token end @@ -395,7 +398,7 @@ def produce_channel_search_url(ucid, query, page) data.rewind data = Base64.urlsafe_encode(data) - continuation = URI.escape(data) + continuation = URI.encode_www_form(data) data = IO::Memory.new @@ -420,7 +423,7 @@ def produce_channel_search_url(ucid, query, page) IO.copy data, buffer continuation = Base64.urlsafe_encode(buffer) - continuation = URI.escape(continuation) + continuation = URI.encode_www_form(continuation) url = "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" diff --git a/src/invidious/trending.cr b/src/invidious/trending.cr index 32908157..26db51ea 100644 --- a/src/invidious/trending.cr +++ b/src/invidious/trending.cr @@ -42,7 +42,7 @@ end def extract_plid(url) wrapper = HTTP::Params.parse(URI.parse(url).query.not_nil!)["bp"] - wrapper = URI.unescape(wrapper) + wrapper = URI.decode_www_form(wrapper) wrapper = Base64.decode(wrapper) # 0xe2 0x02 0x2e diff --git a/src/invidious/users.cr b/src/invidious/users.cr index d3da28d7..6149ae7a 100644 --- a/src/invidious/users.cr +++ b/src/invidious/users.cr @@ -107,7 +107,7 @@ def get_user(sid, headers, db, refresh = true) args = arg_array(user_array) db.exec("INSERT INTO users VALUES (#{args}) \ - ON CONFLICT (email) DO UPDATE SET updated = $1, subscriptions = $3", user_array) + ON CONFLICT (email) DO UPDATE SET updated = $1, subscriptions = $3", args: user_array) db.exec("INSERT INTO session_ids VALUES ($1,$2,$3) \ ON CONFLICT (id) DO NOTHING", sid, user.email, Time.utc) @@ -126,7 +126,7 @@ def get_user(sid, headers, db, refresh = true) args = arg_array(user.to_a) db.exec("INSERT INTO users VALUES (#{args}) \ - ON CONFLICT (email) DO UPDATE SET updated = $1, subscriptions = $3", user_array) + ON CONFLICT (email) DO UPDATE SET updated = $1, subscriptions = $3", args: user_array) db.exec("INSERT INTO session_ids VALUES ($1,$2,$3) \ ON CONFLICT (id) DO NOTHING", sid, user.email, Time.utc) @@ -295,7 +295,7 @@ def get_subscription_feed(db, user, max_results = 40, page = 1) args = arg_array(notifications) - notifications = db.query_all("SELECT * FROM channel_videos WHERE id IN (#{args}) ORDER BY published DESC", notifications, as: ChannelVideo) + notifications = db.query_all("SELECT * FROM channel_videos WHERE id IN (#{args}) ORDER BY published DESC", args: notifications, as: ChannelVideo) videos = [] of ChannelVideo notifications.sort_by! { |video| video.published }.reverse! diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index ef3f4d4b..e175ae39 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -316,10 +316,10 @@ struct Video json.field "premiereTimestamp", self.premiere_timestamp.not_nil!.to_unix end - if self.player_response["streamingData"]?.try &.["hlsManifestUrl"]? + if player_response["streamingData"]?.try &.["hlsManifestUrl"]? host_url = make_host_url(config, kemal_config) - hlsvp = self.player_response["streamingData"]["hlsManifestUrl"].as_s + hlsvp = player_response["streamingData"]["hlsManifestUrl"].as_s hlsvp = hlsvp.gsub("https://manifest.googlevideo.com", host_url) json.field "hlsUrl", hlsvp @@ -408,7 +408,7 @@ struct Video json.object do json.field "label", caption.name.simpleText json.field "languageCode", caption.languageCode - json.field "url", "/api/v1/captions/#{id}?label=#{URI.escape(caption.name.simpleText)}" + json.field "url", "/api/v1/captions/#{id}?label=#{URI.encode_www_form(caption.name.simpleText)}" end end end @@ -489,7 +489,7 @@ struct Video end def live_now - live_now = self.player_response["videoDetails"]?.try &.["isLive"]?.try &.as_bool + live_now = player_response["videoDetails"]?.try &.["isLive"]?.try &.as_bool if live_now.nil? return false @@ -536,7 +536,7 @@ struct Video end def keywords - keywords = self.player_response["videoDetails"]?.try &.["keywords"]?.try &.as_a + keywords = player_response["videoDetails"]?.try &.["keywords"]?.try &.as_a keywords ||= [] of String return keywords @@ -545,7 +545,7 @@ struct Video def fmt_stream(decrypt_function) streams = [] of HTTP::Params - if fmt_streams = self.player_response["streamingData"]?.try &.["formats"]? + if fmt_streams = player_response["streamingData"]?.try &.["formats"]? fmt_streams.as_a.each do |fmt_stream| if !fmt_stream.as_h? next @@ -619,7 +619,7 @@ struct Video def adaptive_fmts(decrypt_function) adaptive_fmts = [] of HTTP::Params - if fmts = self.player_response["streamingData"]?.try &.["adaptiveFormats"]? + if fmts = player_response["streamingData"]?.try &.["adaptiveFormats"]? fmts.as_a.each do |adaptive_fmt| if !adaptive_fmt.as_h? next @@ -706,23 +706,18 @@ struct Video return audio_streams end - def recommended_videos - @recommended_json = JSON.parse(@info["recommended_videos"]) if !@recommended_json - @recommended_json.not_nil! - end - def player_response @player_json = JSON.parse(@info["player_response"]) if !@player_json @player_json.not_nil! end def storyboards - storyboards = self.player_response["storyboards"]? + storyboards = player_response["storyboards"]? .try &.as_h .try &.["playerStoryboardSpecRenderer"]? if !storyboards - storyboards = self.player_response["storyboards"]? + storyboards = player_response["storyboards"]? .try &.as_h .try &.["playerLiveStoryboardSpecRenderer"]? @@ -789,13 +784,8 @@ struct Video end def paid - reason = self.player_response["playabilityStatus"]?.try &.["reason"]? - - if reason == "This video requires payment to watch." - paid = true - else - paid = false - end + reason = player_response["playabilityStatus"]?.try &.["reason"]? + paid = reason == "This video requires payment to watch." ? true : false return paid end @@ -841,7 +831,7 @@ struct Video end def length_seconds - self.player_response["videoDetails"]["lengthSeconds"].as_s.to_i + player_response["videoDetails"]["lengthSeconds"].as_s.to_i end db_mapping({ @@ -887,6 +877,10 @@ struct CaptionName end class VideoRedirect < Exception + property video_id : String + + def initialize(@video_id) + end end def get_video(id, db, refresh = true, region = nil, force_refresh = false) @@ -906,7 +900,7 @@ def get_video(id, db, refresh = true, region = nil, force_refresh = false) db.exec("UPDATE videos SET (info,updated,title,views,likes,dislikes,wilson_score,\ published,description,language,author,ucid,allowed_regions,is_family_friendly,\ genre,genre_url,license,sub_count_text,author_thumbnail)\ - = (#{args}) WHERE id = $1", video_array) + = (#{args}) WHERE id = $1", args: video_array) rescue ex db.exec("DELETE FROM videos * WHERE id = $1", id) raise ex @@ -919,7 +913,7 @@ def get_video(id, db, refresh = true, region = nil, force_refresh = false) args = arg_array(video_array) if !region - db.exec("INSERT INTO videos VALUES (#{args}) ON CONFLICT (id) DO NOTHING", video_array) + db.exec("INSERT INTO videos VALUES (#{args}) ON CONFLICT (id) DO NOTHING", args: video_array) end end @@ -936,6 +930,9 @@ def extract_recommended(recommended_videos) recommended_video = HTTP::Params.new recommended_video["id"] = video_renderer["videoId"].as_s recommended_video["title"] = video_renderer["title"]["simpleText"].as_s + + next if !video_renderer["shortBylineText"]? + recommended_video["author"] = video_renderer["shortBylineText"]["runs"].as_a[0]["text"].as_s recommended_video["ucid"] = video_renderer["shortBylineText"]["runs"].as_a[0]["navigationEndpoint"]["browseEndpoint"]["browseId"].as_s recommended_video["author_thumbnail"] = video_renderer["channelThumbnail"]["thumbnails"][0]["url"].as_s @@ -1113,15 +1110,18 @@ def extract_player_config(body, html) .try &.["results"]? .try &.as_a - rvs = extract_recommended(rvs) - rvs.each_with_index do |rv, i| - if !rv["view_count"]? + rvs = extract_recommended(rvs).compact_map do |rv| + if !rv["short_view_count_text"]? rv_params = rvs_params.select { |rv_params| rv_params["id"]? == (rv["id"]? || "") }[0]? - if rv_params - rvs[i]["short_view_count_text"] = rv_params["short_view_count_text"] + + if rv_params.try &.["short_view_count_text"]? + rv["short_view_count_text"] = rv_params.not_nil!["short_view_count_text"] + rv else - rvs.delete_at(i) + nil end + else + rv end end params["rvs"] = (rvs.map &.to_s).join(",") @@ -1151,7 +1151,7 @@ def fetch_video(id, region) response = client.get("/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999") if md = response.headers["location"]?.try &.match(/v=(?<id>[a-zA-Z0-9_-]{11})/) - raise VideoRedirect.new(md["id"]) + raise VideoRedirect.new(video_id: md["id"]) end html = XML.parse_html(response.body) @@ -1205,6 +1205,11 @@ def fetch_video(id, region) player_json = JSON.parse(info["player_response"]) + reason = player_json["playabilityStatus"]?.try &.["reason"]?.try &.as_s + if reason == "This video is not available." + raise "This video is not available." + end + title = player_json["videoDetails"]["title"].as_s author = player_json["videoDetails"]["author"]?.try &.as_s || "" ucid = player_json["videoDetails"]["channelId"]?.try &.as_s || "" @@ -1257,7 +1262,7 @@ def fetch_video(id, region) end license = html.xpath_node(%q(//h4[contains(text(),"License")]/parent::*/ul/li)).try &.content || "" - sub_count_text = html.xpath_node(%q(//span[contains(@class, "yt-subscriber-count")])).try &.["title"]? || "0" + sub_count_text = html.xpath_node(%q(//span[contains(@class, "subscriber-count")])).try &.["title"]? || "0" author_thumbnail = html.xpath_node(%(//span[@class="yt-thumb-clip"]/img)).try &.["data-thumb"]?.try &.gsub(/^\/\//, "https://") || "" video = Video.new(id, info, Time.utc, title, views, likes, dislikes, wilson_score, published, description_html, diff --git a/src/invidious/views/authorize_token.ecr b/src/invidious/views/authorize_token.ecr index 53b8f001..8ea99010 100644 --- a/src/invidious/views/authorize_token.ecr +++ b/src/invidious/views/authorize_token.ecr @@ -72,7 +72,7 @@ <input type="hidden" name="expire" value="<%= expire %>"> <% end %> - <input type="hidden" name="csrf_token" value="<%= URI.escape(csrf_token) %>"> + <input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(csrf_token) %>"> </form> </div> <% end %> diff --git a/src/invidious/views/change_password.ecr b/src/invidious/views/change_password.ecr index 2e68556b..fb558f1d 100644 --- a/src/invidious/views/change_password.ecr +++ b/src/invidious/views/change_password.ecr @@ -6,7 +6,7 @@ <div class="pure-u-1 pure-u-lg-1-5"></div> <div class="pure-u-1 pure-u-lg-3-5"> <div class="h-box"> - <form class="pure-form pure-form-aligned" action="/change_password?referer=<%= URI.escape(referer) %>" method="post"> + <form class="pure-form pure-form-aligned" action="/change_password?referer=<%= URI.encode_www_form(referer) %>" method="post"> <legend><%= translate(locale, "Change password") %></legend> <fieldset> @@ -23,7 +23,7 @@ <%= translate(locale, "Change password") %> </button> - <input type="hidden" name="csrf_token" value="<%= URI.escape(csrf_token) %>"> + <input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(csrf_token) %>"> </fieldset> </form> </div> diff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecr index 1074598d..b5eb46ea 100644 --- a/src/invidious/views/channel.ecr +++ b/src/invidious/views/channel.ecr @@ -34,7 +34,7 @@ <div class="h-box"> <% ucid = channel.ucid %> <% author = channel.author %> - <% sub_count_text = channel.sub_count.format %> + <% sub_count_text = number_to_short_text(channel.sub_count) %> <%= rendered "components/subscribe_widget" %> </div> diff --git a/src/invidious/views/clear_watch_history.ecr b/src/invidious/views/clear_watch_history.ecr index 2bb9884c..5f9d1032 100644 --- a/src/invidious/views/clear_watch_history.ecr +++ b/src/invidious/views/clear_watch_history.ecr @@ -3,7 +3,7 @@ <% end %> <div class="h-box"> - <form class="pure-form pure-form-aligned" action="/clear_watch_history?referer=<%= URI.escape(referer) %>" method="post"> + <form class="pure-form pure-form-aligned" action="/clear_watch_history?referer=<%= URI.encode_www_form(referer) %>" method="post"> <legend><%= translate(locale, "Clear watch history?") %></legend> <div class="pure-g"> @@ -13,12 +13,12 @@ </button> </div> <div class="pure-u-1-2"> - <a class="pure-button" href="<%= URI.escape(referer) %>"> + <a class="pure-button" href="<%= URI.encode_www_form(referer) %>"> <%= translate(locale, "No") %> </a> </div> </div> - <input type="hidden" name="csrf_token" value="<%= URI.escape(csrf_token) %>"> + <input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(csrf_token) %>"> </form> </div> diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr index 9d086b5d..218cc2d4 100644 --- a/src/invidious/views/community.ecr +++ b/src/invidious/views/community.ecr @@ -33,7 +33,7 @@ <div class="h-box"> <% ucid = channel.ucid %> <% author = channel.author %> - <% sub_count_text = channel.sub_count.format %> + <% sub_count_text = number_to_short_text(channel.sub_count) %> <%= rendered "components/subscribe_widget" %> </div> diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr index 71ae70df..d78d8c4b 100644 --- a/src/invidious/views/components/item.ecr +++ b/src/invidious/views/components/item.ecr @@ -11,7 +11,7 @@ <p><%= item.author %></p> </a> <p><%= translate(locale, "`x` subscribers", number_with_separator(item.subscriber_count)) %></p> - <p><%= translate(locale, "`x` videos", number_with_separator(item.video_count)) %></p> + <% if !item.auto_generated %><p><%= translate(locale, "`x` videos", number_with_separator(item.video_count)) %></p><% end %> <h5><%= item.description_html %></h5> <% when SearchPlaylist %> <% if item.id.starts_with? "RD" %> @@ -91,7 +91,7 @@ <img class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/> <% if env.get? "show_watched" %> <form onsubmit="return false" action="/watch_ajax?action_mark_watched=1&id=<%= item.id %>&referer=<%= env.get("current_page") %>" method="post"> - <input type="hidden" name="csrf_token" value="<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>"> + <input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>"> <p class="watched"> <a onclick="mark_watched(this)" data-id="<%= item.id %>" href="javascript:void(0)"> <button type="submit" style="all:unset"> diff --git a/src/invidious/views/components/subscribe_widget.ecr b/src/invidious/views/components/subscribe_widget.ecr index 1d9966b3..471e6c1c 100644 --- a/src/invidious/views/components/subscribe_widget.ecr +++ b/src/invidious/views/components/subscribe_widget.ecr @@ -2,7 +2,7 @@ <% if subscriptions.includes? ucid %> <p> <form action="/subscription_ajax?action_remove_subscriptions=1&c=<%= ucid %>&referer=<%= env.get("current_page") %>" method="post"> - <input type="hidden" name="csrf_token" value="<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>"> + <input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>"> <button data-type="unsubscribe" id="subscribe" class="pure-button pure-button-primary"> <b><input style="all:unset" type="submit" value="<%= translate(locale, "Unsubscribe") %> | <%= sub_count_text %>"></b> </button> @@ -11,7 +11,7 @@ <% else %> <p> <form action="/subscription_ajax?action_create_subscription_to_channel=1&c=<%= ucid %>&referer=<%= env.get("current_page") %>" method="post"> - <input type="hidden" name="csrf_token" value="<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>"> + <input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>"> <button data-type="subscribe" id="subscribe" class="pure-button pure-button-primary"> <b><input style="all:unset" type="submit" value="<%= translate(locale, "Subscribe") %> | <%= sub_count_text %>"></b> </button> @@ -24,7 +24,7 @@ ucid: '<%= ucid %>', author: '<%= HTML.escape(author) %>', sub_count_text: '<%= HTML.escape(sub_count_text) %>', - csrf_token: '<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>', + csrf_token: '<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>', subscribe_text: '<%= HTML.escape(translate(locale, "Subscribe")) %>', unsubscribe_text: '<%= HTML.escape(translate(locale, "Unsubscribe")) %>' } diff --git a/src/invidious/views/data_control.ecr b/src/invidious/views/data_control.ecr index 463d5fd4..e3edb9ea 100644 --- a/src/invidious/views/data_control.ecr +++ b/src/invidious/views/data_control.ecr @@ -3,7 +3,7 @@ <% end %> <div class="h-box"> - <form class="pure-form pure-form-aligned" enctype="multipart/form-data" action="/data_control?referer=<%= URI.escape(referer) %>" method="post"> + <form class="pure-form pure-form-aligned" enctype="multipart/form-data" action="/data_control?referer=<%= URI.encode_www_form(referer) %>" method="post"> <fieldset> <legend><%= translate(locale, "Import") %></legend> diff --git a/src/invidious/views/delete_account.ecr b/src/invidious/views/delete_account.ecr index 0fa1e77c..9103d5b7 100644 --- a/src/invidious/views/delete_account.ecr +++ b/src/invidious/views/delete_account.ecr @@ -3,7 +3,7 @@ <% end %> <div class="h-box"> - <form class="pure-form pure-form-aligned" action="/delete_account?referer=<%= URI.escape(referer) %>" method="post"> + <form class="pure-form pure-form-aligned" action="/delete_account?referer=<%= URI.encode_www_form(referer) %>" method="post"> <legend><%= translate(locale, "Delete account?") %></legend> <div class="pure-g"> @@ -13,12 +13,12 @@ </button> </div> <div class="pure-u-1-2"> - <a class="pure-button" href="<%= URI.escape(referer) %>"> + <a class="pure-button" href="<%= URI.encode_www_form(referer) %>"> <%= translate(locale, "No") %> </a> </div> </div> - <input type="hidden" name="csrf_token" value="<%= URI.escape(csrf_token) %>"> + <input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(csrf_token) %>"> </form> </div> diff --git a/src/invidious/views/history.ecr b/src/invidious/views/history.ecr index e5154560..7d7ded2c 100644 --- a/src/invidious/views/history.ecr +++ b/src/invidious/views/history.ecr @@ -20,7 +20,7 @@ <script> var watched_data = { - csrf_token: '<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>', + csrf_token: '<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>', } </script> <script src="/js/watched_widget.js"></script> @@ -35,7 +35,7 @@ var watched_data = { <div class="thumbnail"> <img class="thumbnail" src="/vi/<%= item %>/mqdefault.jpg"/> <form onsubmit="return false" action="/watch_ajax?action_mark_unwatched=1&id=<%= item %>&referer=<%= env.get("current_page") %>" method="post"> - <input type="hidden" name="csrf_token" value="<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>"> + <input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>"> <p class="watched"> <a onclick="mark_unwatched(this)" data-id="<%= item %>" href="javascript:void(0)"> <button type="submit" style="all:unset"> diff --git a/src/invidious/views/login.ecr b/src/invidious/views/login.ecr index 614978bc..8518ca81 100644 --- a/src/invidious/views/login.ecr +++ b/src/invidious/views/login.ecr @@ -22,7 +22,7 @@ <hr> <% if account_type == "invidious" %> - <form class="pure-form pure-form-stacked" action="/login?referer=<%= URI.escape(referer) %>&type=invidious" method="post"> + <form class="pure-form pure-form-stacked" action="/login?referer=<%= URI.encode_www_form(referer) %>&type=invidious" method="post"> <fieldset> <% if email %> <input name="email" type="hidden" value="<%= email %>"> @@ -44,7 +44,7 @@ <% captcha = captcha.not_nil! %> <img style="width:100%" src='<%= captcha[:question] %>'/> <% captcha[:tokens].each_with_index do |token, i| %> - <input type="hidden" name="token[<%= i %>]" value="<%= URI.escape(token) %>"> + <input type="hidden" name="token[<%= i %>]" value="<%= URI.encode_www_form(token) %>"> <% end %> <input type="hidden" name="captcha_type" value="image"> <label for="answer"><%= translate(locale, "Time (h:mm:ss):") %></label> @@ -52,7 +52,7 @@ <% when "text" %> <% captcha = captcha.not_nil! %> <% captcha[:tokens].each_with_index do |token, i| %> - <input type="hidden" name="token[<%= i %>]" value="<%= URI.escape(token) %>"> + <input type="hidden" name="token[<%= i %>]" value="<%= URI.encode_www_form(token) %>"> <% end %> <input type="hidden" name="captcha_type" value="text"> <label for="answer"><%= captcha[:question] %></label> @@ -85,7 +85,7 @@ </fieldset> </form> <% elsif account_type == "google" %> - <form class="pure-form pure-form-stacked" action="/login?referer=<%= URI.escape(referer) %>&type=google" method="post"> + <form class="pure-form pure-form-stacked" action="/login?referer=<%= URI.encode_www_form(referer) %>&type=google" method="post"> <fieldset> <% if email %> <input name="email" type="hidden" value="<%= email %>"> diff --git a/src/invidious/views/playlists.ecr b/src/invidious/views/playlists.ecr index 400922ff..a32192b5 100644 --- a/src/invidious/views/playlists.ecr +++ b/src/invidious/views/playlists.ecr @@ -33,7 +33,7 @@ <div class="h-box"> <% ucid = channel.ucid %> <% author = channel.author %> - <% sub_count_text = channel.sub_count.format %> + <% sub_count_text = number_to_short_text(channel.sub_count) %> <%= rendered "components/subscribe_widget" %> </div> diff --git a/src/invidious/views/preferences.ecr b/src/invidious/views/preferences.ecr index 6ea01fba..56334dd9 100644 --- a/src/invidious/views/preferences.ecr +++ b/src/invidious/views/preferences.ecr @@ -9,7 +9,7 @@ function update_value(element) { </script> <div class="h-box"> - <form class="pure-form pure-form-aligned" action="/preferences?referer=<%= URI.escape(referer) %>" method="post"> + <form class="pure-form pure-form-aligned" action="/preferences?referer=<%= URI.encode_www_form(referer) %>" method="post"> <fieldset> <legend><%= translate(locale, "Player preferences") %></legend> @@ -242,15 +242,15 @@ function update_value(element) { <legend><%= translate(locale, "Data preferences") %></legend> <div class="pure-control-group"> - <a href="/clear_watch_history?referer=<%= URI.escape(referer) %>"><%= translate(locale, "Clear watch history") %></a> + <a href="/clear_watch_history?referer=<%= URI.encode_www_form(referer) %>"><%= translate(locale, "Clear watch history") %></a> </div> <div class="pure-control-group"> - <a href="/change_password?referer=<%= URI.escape(referer) %>"><%= translate(locale, "Change password") %></a> + <a href="/change_password?referer=<%= URI.encode_www_form(referer) %>"><%= translate(locale, "Change password") %></a> </div> <div class="pure-control-group"> - <a href="/data_control?referer=<%= URI.escape(referer) %>"><%= translate(locale, "Import/export data") %></a> + <a href="/data_control?referer=<%= URI.encode_www_form(referer) %>"><%= translate(locale, "Import/export data") %></a> </div> <div class="pure-control-group"> @@ -266,7 +266,7 @@ function update_value(element) { </div> <div class="pure-control-group"> - <a href="/delete_account?referer=<%= URI.escape(referer) %>"><%= translate(locale, "Delete account") %></a> + <a href="/delete_account?referer=<%= URI.encode_www_form(referer) %>"><%= translate(locale, "Delete account") %></a> </div> <% end %> diff --git a/src/invidious/views/privacy.ecr b/src/invidious/views/privacy.ecr index f273b250..643f880b 100644 --- a/src/invidious/views/privacy.ecr +++ b/src/invidious/views/privacy.ecr @@ -3,73 +3,52 @@ <% end %> <div class="h-box"> - <%= Markdown.to_html(<<-END_PRIVACY_POLICY - ## Privacy - - This document concerns what data you provide to this website, the purpose of the data, how the data is stored, and how the data can be removed. - - ### Data you directly provide - - Data that you provide to the website for the purpose of the site's operation (for example: an account name, account password, or channel subscription) will be stored in the website's database until the user decides to remove it. This data will not be intentionally shared with anyone or anything. - - Information stored about a registered user is limited to: - - - a list of session tokens for remaining logged in across devices - - the last time an account was updated (to provide accurate notifications) - - a list of video IDs identifying notifications from a user's subscriptions - - a list of channel UCIDs the user is subscribed to - - a user ID (for persistent storage of subscriptions and preferences) - - a json object containing user preferences - - a hashed password if applicable (not present on google accounts) - - a randomly generated token for providing an RSS feed of a user's subscriptions - - a list of video IDs identifying watched videos - - The above list reflects [this code](https://github.com/omarroth/invidious/blob/master/src/invidious/users.cr#L14-L51). - - Users can clear their watch history using the [clear watch history](/clear_watch_history) page. - - If a user is logged in with a Google account, no password will ever be stored. This website uses the session token provided by Google to identify a user, but does not store the information required to make requests on a user's behalf without their knowledge or consent. - - ### Data you passively provide - - When you request any resource from this website (for example: a page, a font, an image, or an API endpoint) information about the request may be logged. - - Information about a request is limited to: - - - the time the request was made - - the status code of the response - - the method of the request - - the requested URL - - how long it took to complete the request. - - No identifying information is logged, such as the visitor's cookie, user-agent, or IP address. Here are a couple lines to serve as an example: - - ``` - 2019-01-19 16:37:47 +00:00 200 GET /api/v1/comments/xrlETJYzH-c?format=html&hl=en-US 1345.88ms - 2019-01-19 16:37:53 +00:00 200 GET /vi/r5P-f5arPXE/maxres.jpg 1085.41ms - 2019-01-19 16:37:54 +00:00 200 GET /watch 7.04ms - ``` - - This website does not store the visitor's user-agent or IP address and does not use fingerprinting, advertisements, or tracking of any form. - - This website provides links to googlevideo.com to provide audio and video playback. googlevideo.com is owned by Google and is subject to their [privacy policy](https://policies.google.com/privacy). - - ### Data stored in your browser - - This website uses browser cookies to authenticate registered users. This data consists of: - - - An account token to keep you logged into the website between visits, which is sent when any page is loaded while you are logged in - - This website also provides an option to store site preferences, such as the theme or locale, without an account. Using this feature will store a cookie in the visitor's browser containing their preferences. This cookie is sent on every request and does not contain any identifying information. - - You can remove this data from your browser by logging out of this website, or by using your browser's cookie-related controls to delete the data. - - ### Removal of data - - To remove data stored in your browser, you can log out of the website, or you can use your browser's cookie-related controls to delete the data. - - To remove data that has been stored in the website's database, you can use the [delete my account](/delete_account) page. - END_PRIVACY_POLICY - ) - %> + <h2>Privacy</h2> + <p>This document concerns what data you provide to this website, the purpose of the data, how the data is stored, and how the data can be removed.</p> + + <h3>Data you directly provide</h3> + <p>Data that you provide to the website for the purpose of the site's operation (for example: an account name, account password, or channel subscription) will be stored in the website's database until the user decides to remove it. This data will not be intentionally shared with anyone or anything.</p> + <p>Information stored about a registered user is limited to:</p> + <ul> + <li>a list of session tokens for remaining logged in across devices</li> + <li>the last time an account was updated (to provide accurate notifications)</li> + <li>a list of video IDs identifying notifications from a user's subscriptions</li> + <li>a list of channel UCIDs the user is subscribed to</li> + <li>a user ID (for persistent storage of subscriptions and preferences)</li> + <li>a json object containing user preferences</li> + <li>a hashed password if applicable (not present on google accounts)</li> + <li>a randomly generated token for providing an RSS feed of a user's subscriptions</li> + <li>a list of video IDs identifying watched videos</li> + </ul> + <p>Users can clear their watch history using the <a href="/clear_watch_history">clear watch history</a> page.</p> + <p>If a user is logged in with a Google account, no password will ever be stored. This website uses the session token provided by Google to identify a user, but does not store the information required to make requests on a user's behalf without their knowledge or consent.</p> + + <h3>Data you passively provide</h3> + <p>When you request any resource from this website (for example: a page, a font, an image, or an API endpoint) information about the request may be logged.</p> + <p>Information about a request is limited to:</p> + <ul> + <li>the time the request was made</li> + <li>the status code of the response</li> + <li>the method of the request</li> + <li>the requested URL</li> + <li>how long it took to complete the request.</li> + </ul> + <p>No identifying information is logged, such as the visitor's cookie, user-agent, or IP address. Here are a couple lines to serve as an example:</p> + <pre><code>2019-01-19 16:37:47 +00:00 200 GET /api/v1/comments/xrlETJYzH-c?format=html&hl=en-US 1345.88ms +2019-01-19 16:37:53 +00:00 200 GET /vi/r5P-f5arPXE/maxres.jpg 1085.41ms +2019-01-19 16:37:54 +00:00 200 GET /watch 7.04ms</code></pre> + <p>This website does not store the visitor's user-agent or IP address and does not use fingerprinting, advertisements, or tracking of any form.</p> + <p>This website provides links to googlevideo.com to provide audio and video playback. googlevideo.com is owned by Google and is subject to their <a href="https://policies.google.com/privacy">privacy policy</a>.</p> + + <h3>Data stored in your browser</h3> + <p>This website uses browser cookies to authenticate registered users. This data consists of:</p> + <ul> + <li>An account token to keep you logged into the website between visits, which is sent when any page is loaded while you are logged in</li> + </ul> + <p>This website also provides an option to store site preferences, such as the theme or locale, without an account. Using this feature will store a cookie in the visitor's browser containing their preferences. This cookie is sent on every request and does not contain any identifying information.</p> + <p>You can remove this data from your browser by logging out of this website, or by using your browser's cookie-related controls to delete the data.</p> + + <h3>Removal of data</h3> + <p>To remove data stored in your browser, you can log out of the website, or you can use your browser's cookie-related controls to delete the data.</p> + <p>To remove data that has been stored in the website's database, you can use the <a href="/delete_account">delete my account</a> page.</p> </div> diff --git a/src/invidious/views/subscription_manager.ecr b/src/invidious/views/subscription_manager.ecr index aa6c5d81..43d14b37 100644 --- a/src/invidious/views/subscription_manager.ecr +++ b/src/invidious/views/subscription_manager.ecr @@ -19,7 +19,7 @@ </div> <div class="pure-u-1-3" style="text-align:right"> <h3> - <a href="/data_control?referer=<%= URI.escape(referer) %>"> + <a href="/data_control?referer=<%= URI.encode_www_form(referer) %>"> <%= translate(locale, "Import/export") %> </a> </h3> @@ -38,7 +38,7 @@ <div class="pure-u-1-5" style="text-align:right"> <h3 style="padding-right:0.5em"> <form onsubmit="return false" action="/subscription_ajax?action_remove_subscriptions=1&c=<%= channel.id %>&referer=<%= env.get("current_page") %>" method="post"> - <input type="hidden" name="csrf_token" value="<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>"> + <input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>"> <a onclick="remove_subscription(this)" data-ucid="<%= channel.id %>" href="#"> <input style="all:unset" type="submit" value="<%= translate(locale, "unsubscribe") %>"> </a> @@ -78,6 +78,6 @@ function remove_subscription(target) { } } - xhr.send('csrf_token=<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>'); + xhr.send('csrf_token=<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>'); } </script> diff --git a/src/invidious/views/subscriptions.ecr b/src/invidious/views/subscriptions.ecr index f98eec6f..ee31d241 100644 --- a/src/invidious/views/subscriptions.ecr +++ b/src/invidious/views/subscriptions.ecr @@ -47,7 +47,7 @@ <script> var watched_data = { - csrf_token: '<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>', + csrf_token: '<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>', } </script> <script src="/js/watched_widget.js"></script> diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr index 8d8cec88..cfefbc2e 100644 --- a/src/invidious/views/template.ecr +++ b/src/invidious/views/template.ecr @@ -68,7 +68,7 @@ </div> <div class="pure-u-1-4"> <form action="/signout?referer=<%= env.get?("current_page") %>" method="post"> - <input type="hidden" name="csrf_token" value="<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>"> + <input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>"> <a class="pure-menu-heading" href="#"> <input style="all:unset" type="submit" value="<%= translate(locale, "Log out") %>"> </a> diff --git a/src/invidious/views/token_manager.ecr b/src/invidious/views/token_manager.ecr index e1c0228f..b626d99c 100644 --- a/src/invidious/views/token_manager.ecr +++ b/src/invidious/views/token_manager.ecr @@ -11,7 +11,7 @@ <div class="pure-u-1-3"></div> <div class="pure-u-1-3" style="text-align:right"> <h3> - <a href="/preferences?referer=<%= URI.escape(referer) %>"><%= translate(locale, "Preferences") %></a> + <a href="/preferences?referer=<%= URI.encode_www_form(referer) %>"><%= translate(locale, "Preferences") %></a> </h3> </div> </div> @@ -30,7 +30,7 @@ <div class="pure-u-1-5" style="text-align:right"> <h3 style="padding-right:0.5em"> <form onsubmit="return false" action="/token_ajax?action_revoke_token=1&session=<%= token[:session] %>&referer=<%= env.get("current_page") %>" method="post"> - <input type="hidden" name="csrf_token" value="<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>"> + <input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>"> <a onclick="revoke_token(this)" data-session="<%= token[:session] %>" href="#"> <input style="all:unset" type="submit" value="<%= translate(locale, "revoke") %>"> </a> @@ -70,6 +70,6 @@ function revoke_token(target) { } } - xhr.send('csrf_token=<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>'); + xhr.send('csrf_token=<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>'); } </script> diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 58c4b1a3..6e37f7a6 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -106,22 +106,22 @@ var video_data = { <label for="download_widget"><%= translate(locale, "Download as: ") %></label> <select style="width:100%" name="download_widget" id="download_widget"> <% fmt_stream.each do |option| %> - <option value='{"id":"<%= video.id %>","itag":"<%= option["itag"] %>","title":"<%= URI.escape(video.title) %>-<%= video.id %>.<%= option["type"].split(";")[0].split("/")[1] %>"}'> + <option value='{"id":"<%= video.id %>","itag":"<%= option["itag"] %>","title":"<%= URI.encode_www_form(video.title) %>-<%= video.id %>.<%= option["type"].split(";")[0].split("/")[1] %>"}'> <%= itag_to_metadata?(option["itag"]).try &.["height"]? || "~240" %>p - <%= option["type"].split(";")[0] %> </option> <% end %> <% video_streams.each do |option| %> - <option value='{"id":"<%= video.id %>","itag":"<%= option["itag"] %>","title":"<%= URI.escape(video.title) %>-<%= video.id %>.<%= option["type"].split(";")[0].split("/")[1] %>"}'> + <option value='{"id":"<%= video.id %>","itag":"<%= option["itag"] %>","title":"<%= URI.encode_www_form(video.title) %>-<%= video.id %>.<%= option["type"].split(";")[0].split("/")[1] %>"}'> <%= option["quality_label"] %> - <%= option["type"].split(";")[0] %> @ <%= option["fps"] %>fps - video only </option> <% end %> <% audio_streams.each do |option| %> - <option value='{"id":"<%= video.id %>","itag":"<%= option["itag"] %>","title":"<%= URI.escape(video.title) %>-<%= video.id %>.<%= option["type"].split(";")[0].split("/")[1] %>"}'> + <option value='{"id":"<%= video.id %>","itag":"<%= option["itag"] %>","title":"<%= URI.encode_www_form(video.title) %>-<%= video.id %>.<%= option["type"].split(";")[0].split("/")[1] %>"}'> <%= option["type"].split(";")[0] %> @ <%= option["bitrate"] %>k - audio only </option> <% end %> <% captions.each do |caption| %> - <option value='{"id":"<%= video.id %>","label":"<%= caption.name.simpleText %>","title":"<%= URI.escape(video.title) %>-<%= video.id %>.<%= caption.languageCode %>.vtt"}'> + <option value='{"id":"<%= video.id %>","label":"<%= caption.name.simpleText %>","title":"<%= URI.encode_www_form(video.title) %>-<%= video.id %>.<%= caption.languageCode %>.vtt"}'> <%= translate(locale, "Subtitles - `x` (.vtt)", caption.name.simpleText) %> </option> <% end %> |
