summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml2
-rw-r--r--.gitmodules3
-rw-r--r--assets/css/default.css4
-rw-r--r--assets/css/player.css12
-rw-r--r--assets/js/_helpers.js249
-rw-r--r--assets/js/community.js86
-rw-r--r--assets/js/embed.js103
-rw-r--r--assets/js/handlers.js137
-rw-r--r--assets/js/notifications.js203
-rw-r--r--assets/js/player.js352
-rw-r--r--assets/js/playlist_widget.js52
-rw-r--r--assets/js/subscribe_widget.js92
-rw-r--r--assets/js/themes.js112
-rw-r--r--assets/js/watch.js475
-rw-r--r--assets/js/watched_widget.js39
-rw-r--r--docker-compose.yml2
-rw-r--r--docker/Dockerfile.arm642
-rw-r--r--locales/bn.json97
-rw-r--r--locales/cs.json5
-rw-r--r--locales/en-US.json1
-rw-r--r--locales/fi.json3
-rw-r--r--locales/fr.json1
-rw-r--r--locales/hr.json79
-rw-r--r--locales/id.json33
-rw-r--r--locales/it.json56
-rw-r--r--locales/ja.json7
-rw-r--r--locales/nb-NO.json13
-rw-r--r--locales/pt-BR.json3
-rw-r--r--locales/pt-PT.json46
-rw-r--r--locales/pt.json47
-rw-r--r--locales/ru.json137
-rw-r--r--locales/sl.json61
-rw-r--r--locales/tr.json3
-rw-r--r--locales/uk.json23
-rw-r--r--locales/zh-CN.json3
-rw-r--r--locales/zh-TW.json3
m---------mocks0
-rw-r--r--scripts/deploy-database.sh60
-rw-r--r--scripts/install-dependencies.sh174
-rw-r--r--spec/invidious/hashtag_spec.cr109
-rw-r--r--spec/invidious/search/query_spec.cr42
-rw-r--r--spec/parsers_helper.cr33
-rw-r--r--src/invidious.cr4
-rw-r--r--src/invidious/channels/about.cr24
-rw-r--r--src/invidious/channels/community.cr12
-rw-r--r--src/invidious/comments.cr18
-rw-r--r--src/invidious/exceptions.cr4
-rw-r--r--src/invidious/hashtag.cr44
-rw-r--r--src/invidious/playlists.cr2
-rw-r--r--src/invidious/routes/api/manifest.cr21
-rw-r--r--src/invidious/routes/api/v1/authenticated.cr2
-rw-r--r--src/invidious/routes/api/v1/channels.cr6
-rw-r--r--src/invidious/routes/api/v1/videos.cr8
-rw-r--r--src/invidious/routes/channels.cr9
-rw-r--r--src/invidious/routes/embed.cr6
-rw-r--r--src/invidious/routes/feeds.cr4
-rw-r--r--src/invidious/routes/playlists.cr14
-rw-r--r--src/invidious/routes/search.cr37
-rw-r--r--src/invidious/routes/video_playback.cr8
-rw-r--r--src/invidious/routes/watch.cr3
-rw-r--r--src/invidious/search/query.cr12
-rw-r--r--src/invidious/videos.cr83
-rw-r--r--src/invidious/views/components/item.ecr33
-rw-r--r--src/invidious/views/components/player.ecr15
-rw-r--r--src/invidious/views/embed.ecr1
-rw-r--r--src/invidious/views/feeds/history.ecr4
-rw-r--r--src/invidious/views/hashtag.ecr39
-rw-r--r--src/invidious/views/licenses.ecr14
-rw-r--r--src/invidious/views/search.ecr10
-rw-r--r--src/invidious/views/template.ecr1
-rw-r--r--src/invidious/views/user/subscription_manager.ecr4
-rw-r--r--src/invidious/views/user/token_manager.ecr4
-rw-r--r--src/invidious/views/watch.ecr42
-rw-r--r--src/invidious/yt_backend/extractors.cr62
-rw-r--r--src/invidious/yt_backend/extractors_utils.cr41
75 files changed, 2172 insertions, 1383 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6107e260..bc80c75c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -47,6 +47,8 @@ jobs:
steps:
- uses: actions/checkout@v3
+ with:
+ submodules: true
- name: Install Crystal
uses: crystal-lang/install-crystal@v1.6.0
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..3d19d888
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "mocks"]
+ path = mocks
+ url = ../mocks
diff --git a/assets/css/default.css b/assets/css/default.css
index c360e982..9ffff960 100644
--- a/assets/css/default.css
+++ b/assets/css/default.css
@@ -530,4 +530,8 @@ p,
/* Center the "invidious" logo on the search page */
#logo > h1 { text-align: center; }
+/* IE11 fixes */
:-ms-input-placeholder { color: #888; }
+
+/* Wider settings name to less word wrap */
+.pure-form-aligned .pure-control-group label { width: 19em; }
diff --git a/assets/css/player.css b/assets/css/player.css
index 304375b5..8a7cfdab 100644
--- a/assets/css/player.css
+++ b/assets/css/player.css
@@ -101,21 +101,25 @@ ul.vjs-menu-content::-webkit-scrollbar {
order: 2;
}
+.vjs-audio-button {
+ order: 3;
+}
+
.vjs-quality-selector,
.video-js .vjs-http-source-selector {
- order: 3;
+ order: 4;
}
.vjs-playback-rate {
- order: 4;
+ order: 5;
}
.vjs-share-control {
- order: 5;
+ order: 6;
}
.vjs-fullscreen-control {
- order: 6;
+ order: 7;
}
.vjs-playback-rate > .vjs-menu {
diff --git a/assets/js/_helpers.js b/assets/js/_helpers.js
new file mode 100644
index 00000000..7c50670e
--- /dev/null
+++ b/assets/js/_helpers.js
@@ -0,0 +1,249 @@
+'use strict';
+// Contains only auxiliary methods
+// May be included and executed unlimited number of times without any consequences
+
+// Polyfills for IE11
+Array.prototype.find = Array.prototype.find || function (condition) {
+ return this.filter(condition)[0];
+};
+Array.from = Array.from || function (source) {
+ return Array.prototype.slice.call(source);
+};
+NodeList.prototype.forEach = NodeList.prototype.forEach || function (callback) {
+ Array.from(this).forEach(callback);
+};
+String.prototype.includes = String.prototype.includes || function (searchString) {
+ return this.indexOf(searchString) >= 0;
+};
+String.prototype.startsWith = String.prototype.startsWith || function (prefix) {
+ return this.substr(0, prefix.length) === prefix;
+};
+Math.sign = Math.sign || function(x) {
+ x = +x;
+ if (!x) return x; // 0 and NaN
+ return x > 0 ? 1 : -1;
+};
+if (!window.hasOwnProperty('HTMLDetailsElement') && !window.hasOwnProperty('mockHTMLDetailsElement')) {
+ window.mockHTMLDetailsElement = true;
+ const style = 'details:not([open]) > :not(summary) {display: none}';
+ document.head.appendChild(document.createElement('style')).textContent = style;
+
+ addEventListener('click', function (e) {
+ if (e.target.nodeName !== 'SUMMARY') return;
+ const details = e.target.parentElement;
+ if (details.hasAttribute('open'))
+ details.removeAttribute('open');
+ else
+ details.setAttribute('open', '');
+ });
+}
+
+// Monstrous global variable for handy code
+// Includes: clamp, xhr, storage.{get,set,remove}
+window.helpers = window.helpers || {
+ /**
+ * https://en.wikipedia.org/wiki/Clamping_(graphics)
+ * @param {Number} num Source number
+ * @param {Number} min Low border
+ * @param {Number} max High border
+ * @returns {Number} Clamped value
+ */
+ clamp: function (num, min, max) {
+ if (max < min) {
+ var t = max; max = min; min = t; // swap max and min
+ }
+
+ if (max < num)
+ return max;
+ if (min > num)
+ return min;
+ return num;
+ },
+
+ /** @private */
+ _xhr: function (method, url, options, callbacks) {
+ const xhr = new XMLHttpRequest();
+ xhr.open(method, url);
+
+ // Default options
+ xhr.responseType = 'json';
+ xhr.timeout = 10000;
+ // Default options redefining
+ if (options.responseType)
+ xhr.responseType = options.responseType;
+ if (options.timeout)
+ xhr.timeout = options.timeout;
+
+ if (method === 'POST')
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+
+ // better than onreadystatechange because of 404 codes https://stackoverflow.com/a/36182963
+ xhr.onloadend = function () {
+ if (xhr.status === 200) {
+ if (callbacks.on200) {
+ // fix for IE11. It doesn't convert response to JSON
+ if (xhr.responseType === '' && typeof(xhr.response) === 'string')
+ callbacks.on200(JSON.parse(xhr.response));
+ else
+ callbacks.on200(xhr.response);
+ }
+ } else {
+ // handled by onerror
+ if (xhr.status === 0) return;
+
+ if (callbacks.onNon200)
+ callbacks.onNon200(xhr);
+ }
+ };
+
+ xhr.ontimeout = function () {
+ if (callbacks.onTimeout)
+ callbacks.onTimeout(xhr);
+ };
+
+ xhr.onerror = function () {
+ if (callbacks.onError)
+ callbacks.onError(xhr);
+ };
+
+ if (options.payload)
+ xhr.send(options.payload);
+ else
+ xhr.send();
+ },
+ /** @private */
+ _xhrRetry: function(method, url, options, callbacks) {
+ if (options.retries <= 0) {
+ console.warn('Failed to pull', options.entity_name);
+ if (callbacks.onTotalFail)
+ callbacks.onTotalFail();
+ return;
+ }
+ helpers._xhr(method, url, options, callbacks);
+ },
+ /**
+ * @callback callbackXhrOn200
+ * @param {Object} response - xhr.response
+ */
+ /**
+ * @callback callbackXhrError
+ * @param {XMLHttpRequest} xhr
+ */
+ /**
+ * @param {'GET'|'POST'} method - 'GET' or 'POST'
+ * @param {String} url - URL to send request to
+ * @param {Object} options - other XHR options
+ * @param {XMLHttpRequestBodyInit} [options.payload=null] - payload for POST-requests
+ * @param {'arraybuffer'|'blob'|'document'|'json'|'text'} [options.responseType=json]
+ * @param {Number} [options.timeout=10000]
+ * @param {Number} [options.retries=1]
+ * @param {String} [options.entity_name='unknown'] - string to log
+ * @param {Number} [options.retry_timeout=1000]
+ * @param {Object} callbacks - functions to execute on events fired
+ * @param {callbackXhrOn200} [callbacks.on200]
+ * @param {callbackXhrError} [callbacks.onNon200]
+ * @param {callbackXhrError} [callbacks.onTimeout]
+ * @param {callbackXhrError} [callbacks.onError]
+ * @param {callbackXhrError} [callbacks.onTotalFail] - if failed after all retries
+ */
+ xhr: function(method, url, options, callbacks) {
+ if (!options.retries || options.retries <= 1) {
+ helpers._xhr(method, url, options, callbacks);
+ return;
+ }
+
+ if (!options.entity_name) options.entity_name = 'unknown';
+ if (!options.retry_timeout) options.retry_timeout = 1000;
+ const retries_total = options.retries;
+ let currentTry = 1;
+
+ const retry = function () {
+ console.warn('Pulling ' + options.entity_name + ' failed... ' + (currentTry++) + '/' + retries_total);
+ setTimeout(function () {
+ options.retries--;
+ helpers._xhrRetry(method, url, options, callbacks);
+ }, options.retry_timeout);
+ };
+
+ // Pack retry() call into error handlers
+ callbacks._onError = callbacks.onError;
+ callbacks.onError = function (xhr) {
+ if (callbacks._onError)
+ callbacks._onError(xhr);
+ retry();
+ };
+ callbacks._onTimeout = callbacks.onTimeout;
+ callbacks.onTimeout = function (xhr) {
+ if (callbacks._onTimeout)
+ callbacks._onTimeout(xhr);
+ retry();
+ };
+
+ helpers._xhrRetry(method, url, options, callbacks);
+ },
+
+ /**
+ * @typedef {Object} invidiousStorage
+ * @property {(key:String) => Object} get
+ * @property {(key:String, value:Object)} set
+ * @property {(key:String)} remove
+ */
+
+ /**
+ * Universal storage, stores and returns JS objects. Uses inside localStorage or cookies
+ * @type {invidiousStorage}
+ */
+ storage: (function () {
+ // access to localStorage throws exception in Tor Browser, so try is needed
+ let localStorageIsUsable = false;
+ try{localStorageIsUsable = !!localStorage.setItem;}catch(e){}
+
+ if (localStorageIsUsable) {
+ return {
+ get: function (key) {
+ if (!localStorage[key]) return;
+ try {
+ return JSON.parse(decodeURIComponent(localStorage[key]));
+ } catch(e) {
+ // Erase non parsable value
+ helpers.storage.remove(key);
+ }
+ },
+ set: function (key, value) { localStorage[key] = encodeURIComponent(JSON.stringify(value)); },
+ remove: function (key) { localStorage.removeItem(key); }
+ };
+ }
+
+ // TODO: fire 'storage' event for cookies
+ console.info('Storage: localStorage is disabled or unaccessible. Cookies used as fallback');
+ return {
+ get: function (key) {
+ const cookiePrefix = key + '=';
+ function findCallback(cookie) {return cookie.startsWith(cookiePrefix);}
+ const matchedCookie = document.cookie.split('; ').find(findCallback);
+ if (matchedCookie) {
+ const cookieBody = matchedCookie.replace(cookiePrefix, '');
+ if (cookieBody.length === 0) return;
+ try {
+ return JSON.parse(decodeURIComponent(cookieBody));
+ } catch(e) {
+ // Erase non parsable value
+ helpers.storage.remove(key);
+ }
+ }
+ },
+ set: function (key, value) {
+ const cookie_data = encodeURIComponent(JSON.stringify(value));
+
+ // Set expiration in 2 year
+ const date = new Date();
+ date.setFullYear(date.getFullYear()+2);
+
+ document.cookie = key + '=' + cookie_data + '; expires=' + date.toGMTString();
+ },
+ remove: function (key) {
+ document.cookie = key + '=; Max-Age=0';
+ }
+ };
+ })()
+};
diff --git a/assets/js/community.js b/assets/js/community.js
index 44066a58..32fe4ebc 100644
--- a/assets/js/community.js
+++ b/assets/js/community.js
@@ -1,13 +1,6 @@
'use strict';
var community_data = JSON.parse(document.getElementById('community_data').textContent);
-String.prototype.supplant = function (o) {
- return this.replace(/{([^{}]*)}/g, function (a, b) {
- var r = o[b];
- return typeof r === 'string' || typeof r === 'number' ? r : a;
- });
-};
-
function hide_youtube_replies(event) {
var target = event.target;
@@ -38,13 +31,6 @@ function show_youtube_replies(event) {
target.setAttribute('data-sub-text', sub_text);
}
-function number_with_separator(val) {
- while (/(\d+)(\d{3})/.test(val.toString())) {
- val = val.toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2');
- }
- return val;
-}
-
function get_youtube_replies(target, load_more) {
var continuation = target.getAttribute('data-continuation');
@@ -58,47 +44,39 @@ function get_youtube_replies(target, load_more) {
'&hl=' + community_data.preferences.locale +
'&thin_mode=' + community_data.preferences.thin_mode +
'&continuation=' + continuation;
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('GET', url, true);
-
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status === 200) {
- if (load_more) {
- body = body.parentNode.parentNode;
- body.removeChild(body.lastElementChild);
- body.innerHTML += xhr.response.contentHtml;
- } else {
- body.removeChild(body.lastElementChild);
-
- var p = document.createElement('p');
- var a = document.createElement('a');
- p.appendChild(a);
-
- a.href = 'javascript:void(0)';
- a.onclick = hide_youtube_replies;
- a.setAttribute('data-sub-text', community_data.hide_replies_text);
- a.setAttribute('data-inner-text', community_data.show_replies_text);
- a.innerText = community_data.hide_replies_text;
-
- var div = document.createElement('div');
- div.innerHTML = xhr.response.contentHtml;
-
- body.appendChild(p);
- body.appendChild(div);
- }
+
+ helpers.xhr('GET', url, {}, {
+ on200: function (response) {
+ if (load_more) {
+ body = body.parentNode.parentNode;
+ body.removeChild(body.lastElementChild);
+ body.innerHTML += response.contentHtml;
} else {
- body.innerHTML = fallback;
- }
- }
- };
+ body.removeChild(body.lastElementChild);
+
+ var p = document.createElement('p');
+ var a = document.createElement('a');
+ p.appendChild(a);
+
+ a.href = 'javascript:void(0)';
+ a.onclick = hide_youtube_replies;
+ a.setAttribute('data-sub-text', community_data.hide_replies_text);
+ a.setAttribute('data-inner-text', community_data.show_replies_text);
+ a.textContent = community_data.hide_replies_text;
- xhr.ontimeout = function () {
- console.warn('Pulling comments failed.');
- body.innerHTML = fallback;
- };
+ var div = document.createElement('div');
+ div.innerHTML = response.contentHtml;
- xhr.send();
+ body.appendChild(p);
+ body.appendChild(div);
+ }
+ },
+ onNon200: function (xhr) {
+ body.innerHTML = fallback;
+ },
+ onTimeout: function (xhr) {
+ console.warn('Pulling comments failed');
+ body.innerHTML = fallback;
+ }
+ });
}
diff --git a/assets/js/embed.js b/assets/js/embed.js
index 7e9ac605..b11b5e5a 100644
--- a/assets/js/embed.js
+++ b/assets/js/embed.js
@@ -1,14 +1,7 @@
'use strict';
var video_data = JSON.parse(document.getElementById('video_data').textContent);
-function get_playlist(plid, retries) {
- if (retries === undefined) retries = 5;
-
- if (retries <= 0) {
- console.warn('Failed to pull playlist');
- return;
- }
-
+function get_playlist(plid) {
var plid_url;
if (plid.startsWith('RD')) {
plid_url = '/api/v1/mixes/' + plid +
@@ -21,85 +14,49 @@ function get_playlist(plid, retries) {
'&format=html&hl=' + video_data.preferences.locale;
}
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('GET', plid_url, true);
-
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status === 200) {
- if (xhr.response.nextVideo) {
- player.on('ended', function () {
- var url = new URL('https://example.com/embed/' + xhr.response.nextVideo);
-
- url.searchParams.set('list', plid);
- if (!plid.startsWith('RD')) {
- url.searchParams.set('index', xhr.response.index);
- }
-
- if (video_data.params.autoplay || video_data.params.continue_autoplay) {
- url.searchParams.set('autoplay', '1');
- }
-
- if (video_data.params.listen !== video_data.preferences.listen) {
- url.searchParams.set('listen', video_data.params.listen);
- }
-
- if (video_data.params.speed !== video_data.preferences.speed) {
- url.searchParams.set('speed', video_data.params.speed);
- }
-
- if (video_data.params.local !== video_data.preferences.local) {
- url.searchParams.set('local', video_data.params.local);
- }
-
- location.assign(url.pathname + url.search);
- });
- }
- }
+ helpers.xhr('GET', plid_url, {retries: 5, entity_name: 'playlist'}, {
+ on200: function (response) {
+ if (!response.nextVideo)
+ return;
+
+ player.on('ended', function () {
+ var url = new URL('https://example.com/embed/' + response.nextVideo);
+
+ url.searchParams.set('list', plid);
+ if (!plid.startsWith('RD'))
+ url.searchParams.set('index', response.index);
+ if (video_data.params.autoplay || video_data.params.continue_autoplay)
+ url.searchParams.set('autoplay', '1');
+ if (video_data.params.listen !== video_data.preferences.listen)
+ url.searchParams.set('listen', video_data.params.listen);
+ if (video_data.params.speed !== video_data.preferences.speed)
+ url.searchParams.set('speed', video_data.params.speed);
+ if (video_data.params.local !== video_data.preferences.local)
+ url.searchParams.set('local', video_data.params.local);
+
+ location.assign(url.pathname + url.search);
+ });
}
- };
-
- xhr.onerror = function () {
- console.warn('Pulling playlist failed... ' + retries + '/5');
- setTimeout(function () { get_playlist(plid, retries - 1); }, 1000);
- };
-
- xhr.ontimeout = function () {
- console.warn('Pulling playlist failed... ' + retries + '/5');
- get_playlist(plid, retries - 1);
- };
-
- xhr.send();
+ });
}
-window.addEventListener('load', function (e) {
+addEventListener('load', function (e) {
if (video_data.plid) {
get_playlist(video_data.plid);
} else if (video_data.video_series) {
player.on('ended', function () {
var url = new URL('https://example.com/embed/' + video_data.video_series.shift());
- if (video_data.params.autoplay || video_data.params.continue_autoplay) {
+ if (video_data.params.autoplay || video_data.params.continue_autoplay)
url.searchParams.set('autoplay', '1');
- }
-
- if (video_data.params.listen !== video_data.preferences.listen) {
+ if (video_data.params.listen !== video_data.preferences.listen)
url.searchParams.set('listen', video_data.params.listen);
- }
-
- if (video_data.params.speed !== video_data.preferences.speed) {
+ if (video_data.params.speed !== video_data.preferences.speed)
url.searchParams.set('speed', video_data.params.speed);
- }
-
- if (video_data.params.local !== video_data.preferences.local) {
+ if (video_data.params.local !== video_data.preferences.local)
url.searchParams.set('local', video_data.params.local);
- }
-
- if (video_data.video_series.length !== 0) {
+ if (video_data.video_series.length !== 0)
url.searchParams.set('playlist', video_data.video_series.join(','));
- }
location.assign(url.pathname + url.search);
});
diff --git a/assets/js/handlers.js b/assets/js/handlers.js
index f6617b60..29810e72 100644
--- a/assets/js/handlers.js
+++ b/assets/js/handlers.js
@@ -1,8 +1,6 @@
'use strict';
(function () {
- var n2a = function (n) { return Array.prototype.slice.call(n); };
-
var video_player = document.getElementById('player_html5_api');
if (video_player) {
video_player.onmouseenter = function () { video_player['data-title'] = video_player['title']; video_player['title'] = ''; };
@@ -11,8 +9,8 @@
}
// For dynamically inserted elements
- document.addEventListener('click', function (e) {
- if (!e || !e.target) { return; }
+ addEventListener('click', function (e) {
+ if (!e || !e.target) return;
var t = e.target;
var handler_name = t.getAttribute('data-onclick');
@@ -29,6 +27,7 @@
get_youtube_replies(t, load_more, load_replies);
break;
case 'toggle_parent':
+ e.preventDefault();
toggle_parent(t);
break;
default:
@@ -36,118 +35,98 @@
}
});
- n2a(document.querySelectorAll('[data-mouse="switch_classes"]')).forEach(function (e) {
- var classes = e.getAttribute('data-switch-classes').split(',');
- var ec = classes[0];
- var lc = classes[1];
- var onoff = function (on, off) {
- var cs = e.getAttribute('class');
- cs = cs.split(off).join(on);
- e.setAttribute('class', cs);
- };
- e.onmouseenter = function () { onoff(ec, lc); };
- e.onmouseleave = function () { onoff(lc, ec); };
+ document.querySelectorAll('[data-mouse="switch_classes"]').forEach(function (el) {
+ var classes = el.getAttribute('data-switch-classes').split(',');
+ var classOnEnter = classes[0];
+ var classOnLeave = classes[1];
+ function toggle_classes(toAdd, toRemove) {
+ el.classList.add(toAdd);
+ el.classList.remove(toRemove);
+ }
+ el.onmouseenter = function () { toggle_classes(classOnEnter, classOnLeave); };
+ el.onmouseleave = function () { toggle_classes(classOnLeave, classOnEnter); };
});
- n2a(document.querySelectorAll('[data-onsubmit="return_false"]')).forEach(function (e) {
- e.onsubmit = function () { return false; };
+ document.querySelectorAll('[data-onsubmit="return_false"]').forEach(function (el) {
+ el.onsubmit = function () { return false; };
});
- n2a(document.querySelectorAll('[data-onclick="mark_watched"]')).forEach(function (e) {
- e.onclick = function () { mark_watched(e); };
+ document.querySelectorAll('[data-onclick="mark_watched"]').forEach(function (el) {
+ el.onclick = function () { mark_watched(el); };
});
- n2a(document.querySelectorAll('[data-onclick="mark_unwatched"]')).forEach(function (e) {
- e.onclick = function () { mark_unwatched(e); };
+ document.querySelectorAll('[data-onclick="mark_unwatched"]').forEach(function (el) {
+ el.onclick = function () { mark_unwatched(el); };
});
- n2a(document.querySelectorAll('[data-onclick="add_playlist_video"]')).forEach(function (e) {
- e.onclick = function () { add_playlist_video(e); };
+ document.querySelectorAll('[data-onclick="add_playlist_video"]').forEach(function (el) {
+ el.onclick = function () { add_playlist_video(el); };
});
- n2a(document.querySelectorAll('[data-onclick="add_playlist_item"]')).forEach(function (e) {
- e.onclick = function () { add_playlist_item(e); };
+ document.querySelectorAll('[data-onclick="add_playlist_item"]').forEach(function (el) {
+ el.onclick = function () { add_playlist_item(el); };
});
- n2a(document.querySelectorAll('[data-onclick="remove_playlist_item"]')).forEach(function (e) {
- e.onclick = function () { remove_playlist_item(e); };
+ document.querySelectorAll('[data-onclick="remove_playlist_item"]').forEach(function (el) {
+ el.onclick = function () { remove_playlist_item(el); };
});
- n2a(document.querySelectorAll('[data-onclick="revoke_token"]')).forEach(function (e) {
- e.onclick = function () { revoke_token(e); };
+ document.querySelectorAll('[data-onclick="revoke_token"]').forEach(function (el) {
+ el.onclick = function () { revoke_token(el); };
});
- n2a(document.querySelectorAll('[data-onclick="remove_subscription"]')).forEach(function (e) {
- e.onclick = function () { remove_subscription(e); };
+ document.querySelectorAll('[data-onclick="remove_subscription"]').forEach(function (el) {
+ el.onclick = function () { remove_subscription(el); };
});
- n2a(document.querySelectorAll('[data-onclick="notification_requestPermission"]')).forEach(function (e) {
- e.onclick = function () { Notification.requestPermission(); };
+ document.querySelectorAll('[data-onclick="notification_requestPermission"]').forEach(function (el) {
+ el.onclick = function () { Notification.requestPermission(); };
});
- n2a(document.querySelectorAll('[data-onrange="update_volume_value"]')).forEach(function (e) {
- var cb = function () { update_volume_value(e); };
- e.oninput = cb;
- e.onchange = cb;
+ document.querySelectorAll('[data-onrange="update_volume_value"]').forEach(function (el) {
+ function update_volume_value() {
+ document.getElementById('volume-value').textContent = el.value;
+ }
+ el.oninput = update_volume_value;
+ el.onchange = update_volume_value;
});
- function update_volume_value(element) {
- document.getElementById('volume-value').innerText = element.value;
- }
function revoke_token(target) {
var row = target.parentNode.parentNode.parentNode.parentNode.parentNode;
row.style.display = 'none';
var count = document.getElementById('count');
- count.innerText = count.innerText - 1;
+ count.textContent--;
- var referer = window.encodeURIComponent(document.location.href);
var url = '/token_ajax?action_revoke_token=1&redirect=false' +
- '&referer=' + referer +
+ '&referer=' + encodeURIComponent(location.href) +
'&session=' + target.getAttribute('data-session');
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('POST', url, true);
- xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status !== 200) {
- count.innerText = parseInt(count.innerText) + 1;
- row.style.display = '';
- }
- }
- };
- var csrf_token = target.parentNode.querySelector('input[name="csrf_token"]').value;
- xhr.send('csrf_token=' + csrf_token);
+ var payload = 'csrf_token=' + target.parentNode.querySelector('input[name="csrf_token"]').value;
+
+ helpers.xhr('POST', url, {payload: payload}, {
+ onNon200: function (xhr) {
+ count.textContent++;
+ row.style.display = '';
+ }
+ });
}
function remove_subscription(target) {
var row = target.parentNode.parentNode.parentNode.parentNode.parentNode;
row.style.display = 'none';
var count = document.getElementById('count');
- count.innerText = count.innerText - 1;
+ count.textContent--;
- var referer = window.encodeURIComponent(document.location.href);
var url = '/subscription_ajax?action_remove_subscriptions=1&redirect=false' +
- '&referer=' + referer +
+ '&referer=' + encodeURIComponent(location.href) +
'&c=' + target.getAttribute('data-ucid');
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('POST', url, true);
- xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status !== 200) {
- count.innerText = parseInt(count.innerText) + 1;
- row.style.display = '';
- }
- }
- };
- var csrf_token = target.parentNode.querySelector('input[name="csrf_token"]').value;
- xhr.send('csrf_token=' + csrf_token);
+ var payload = 'csrf_token=' + target.parentNode.querySelector('input[name="csrf_token"]').value;
+
+ helpers.xhr('POST', url, {payload: payload}, {
+ onNon200: function (xhr) {
+ count.textContent++;
+ row.style.display = '';
+ }
+ });
}
// Handle keypresses
- window.addEventListener('keydown', function (event) {
+ addEventListener('keydown', function (event) {
// Ignore modifier keys
if (event.ctrlKey || event.metaKey) return;
diff --git a/assets/js/notifications.js b/assets/js/notifications.js
index ec5f6dd3..058553d9 100644
--- a/assets/js/notifications.js
+++ b/assets/js/notifications.js
@@ -1,43 +1,26 @@
'use strict';
var notification_data = JSON.parse(document.getElementById('notification_data').textContent);
-var notifications, delivered;
-
-function get_subscriptions(callback, retries) {
- if (retries === undefined) retries = 5;
-
- if (retries <= 0) {
- return;
- }
-
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('GET', '/api/v1/auth/subscriptions?fields=authorId', true);
-
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status === 200) {
- var subscriptions = xhr.response;
- callback(subscriptions);
- }
- }
- };
-
- xhr.onerror = function () {
- console.warn('Pulling subscriptions failed... ' + retries + '/5');
- setTimeout(function () { get_subscriptions(callback, retries - 1); }, 1000);
- };
+/** Boolean meaning 'some tab have stream' */
+const STORAGE_KEY_STREAM = 'stream';
+/** Number of notifications. May be increased or reset */
+const STORAGE_KEY_NOTIF_COUNT = 'notification_count';
- xhr.ontimeout = function () {
- console.warn('Pulling subscriptions failed... ' + retries + '/5');
- get_subscriptions(callback, retries - 1);
- };
-
- xhr.send();
+var notifications, delivered;
+var notifications_mock = { close: function () { } };
+
+function get_subscriptions() {
+ helpers.xhr('GET', '/api/v1/auth/subscriptions?fields=authorId', {
+ retries: 5,
+ entity_name: 'subscriptions'
+ }, {
+ on200: create_notification_stream
+ });
}
function create_notification_stream(subscriptions) {
+ // sse.js can't be replaced to EventSource in place as it lack support of payload and headers
+ // see https://developer.mozilla.org/en-US/docs/Web/API/EventSource/EventSource
notifications = new SSE(
'/api/v1/auth/notifications?fields=videoId,title,author,authorId,publishedText,published,authorThumbnails,liveNow', {
withCredentials: true,
@@ -49,96 +32,100 @@ function create_notification_stream(subscriptions) {
var start_time = Math.round(new Date() / 1000);
notifications.onmessage = function (event) {
- if (!event.id) {
- return;
- }
+ if (!event.id) return;
var notification = JSON.parse(event.data);
console.info('Got notification:', notification);
- if (start_time < notification.published && !delivered.includes(notification.videoId)) {
- if (Notification.permission === 'granted') {
- var system_notification =
- new Notification((notification.liveNow ? notification_data.live_now_text : notification_data.upload_text).replace('`x`', notification.author), {
- body: notification.title,
- icon: '/ggpht' + new URL(notification.authorThumbnails[2].url).pathname,
- img: '/ggpht' + new URL(notification.authorThumbnails[4].url).pathname,
- tag: notification.videoId
- });
-
- system_notification.onclick = function (event) {
- window.open('/watch?v=' + event.currentTarget.tag, '_blank');
- };
- }
-
- delivered.push(notification.videoId);
- localStorage.setItem('notification_count', parseInt(localStorage.getItem('notification_count') || '0') + 1);
- var notification_ticker = document.getElementById('notification_ticker');
-
- if (parseInt(localStorage.getItem('notification_count')) > 0) {
- notification_ticker.innerHTML =
- '<span id="notification_count">' + localStorage.getItem('notification_count') + '</span> <i class="icon ion-ios-notifications"></i>';
- } else {
- notification_ticker.innerHTML =
- '<i class="icon ion-ios-notifications-outline"></i>';
- }
+ // Ignore not actual and delivered notifications
+ if (start_time > notification.published || delivered.includes(notification.videoId)) return;
+
+ delivered.push(notification.videoId);
+
+ let notification_count = helpers.storage.get(STORAGE_KEY_NOTIF_COUNT) || 0;
+ notification_count++;
+ helpers.storage.set(STORAGE_KEY_NOTIF_COUNT, notification_count);
+
+ update_ticker_count();
+
+ // permission for notifications handled on settings page. JS handler is in handlers.js
+ if (window.Notification && Notification.permission === 'granted') {
+ var notification_text = notification.liveNow ? notification_data.live_now_text : notification_data.upload_text;
+ notification_text = notification_text.replace('`x`', notification.author);
+
+ var system_notification = new Notification(notification_text, {
+ body: notification.title,
+ icon: '/ggpht' + new URL(notification.authorThumbnails[2].url).pathname,
+ img: '/ggpht' + new URL(notification.authorThumbnails[4].url).pathname
+ });
+
+ system_notification.onclick = function (e) {
+ open('/watch?v=' + notification.videoId, '_blank');
+ };
}
};
- notifications.addEventListener('error', handle_notification_error);
- notifications.stream();
-}
+ notifications.addEventListener('error', function (e) {
+ console.warn('Something went wrong with notifications, trying to reconnect...');
+ notifications = notifications_mock;
+ setTimeout(get_subscriptions, 1000);
+ });
-function handle_notification_error(event) {
- console.warn('Something went wrong with notifications, trying to reconnect...');
- notifications = { close: function () { } };
- setTimeout(function () { get_subscriptions(create_notification_stream); }, 1000);
+ notifications.stream();
}
-window.addEventListener('load', function (e) {
- localStorage.setItem('notification_count', document.getElementById('notification_count') ? document.getElementById('notification_count').innerText : '0');
+function update_ticker_count() {
+ var notification_ticker = document.getElementById('notification_ticker');
- if (localStorage.getItem('stream')) {
- localStorage.removeItem('stream');
+ const notification_count = helpers.storage.get(STORAGE_KEY_STREAM);
+ if (notification_count > 0) {
+ notification_ticker.innerHTML =
+ '<span id="notification_count">' + notification_count + '</span> <i class="icon ion-ios-notifications"></i>';
} else {
- setTimeout(function () {
- if (!localStorage.getItem('stream')) {
- notifications = { close: function () { } };
- localStorage.setItem('stream', true);
- get_subscriptions(create_notification_stream);
- }
- }, Math.random() * 1000 + 50);
+ notification_ticker.innerHTML =
+ '<i class="icon ion-ios-notifications-outline"></i>';
}
+}
- window.addEventListener('storage', function (e) {
- if (e.key === 'stream' && !e.newValue) {
- if (notifications) {
- localStorage.setItem('stream', true);
- } else {
- setTimeout(function () {
- if (!localStorage.getItem('stream')) {
- notifications = { close: function () { } };
- localStorage.setItem('stream', true);
- get_subscriptions(create_notification_stream);
- }
- }, Math.random() * 1000 + 50);
- }
- } else if (e.key === 'notification_count') {
- var notification_ticker = document.getElementById('notification_ticker');
-
- if (parseInt(e.newValue) > 0) {
- notification_ticker.innerHTML =
- '<span id="notification_count">' + e.newValue + '</span> <i class="icon ion-ios-notifications"></i>';
- } else {
- notification_ticker.innerHTML =
- '<i class="icon ion-ios-notifications-outline"></i>';
- }
+function start_stream_if_needed() {
+ // random wait for other tabs set 'stream' flag
+ setTimeout(function () {
+ if (!helpers.storage.get(STORAGE_KEY_STREAM)) {
+ // if no one set 'stream', set it by yourself and start stream
+ helpers.storage.set(STORAGE_KEY_STREAM, true);
+ notifications = notifications_mock;
+ get_subscriptions();
}
- });
-});
+ }, Math.random() * 1000 + 50); // [0.050 .. 1.050) second
+}
+
+
+addEventListener('storage', function (e) {
+ if (e.key === STORAGE_KEY_NOTIF_COUNT)
+ update_ticker_count();
-window.addEventListener('unload', function (e) {
- if (notifications) {
- localStorage.removeItem('stream');
+ // if 'stream' key was removed
+ if (e.key === STORAGE_KEY_STREAM && !helpers.storage.get(STORAGE_KEY_STREAM)) {
+ if (notifications) {
+ // restore it if we have active stream
+ helpers.storage.set(STORAGE_KEY_STREAM, true);
+ } else {
+ start_stream_if_needed();
+ }
}
});
+
+addEventListener('load', function () {
+ var notification_count_el = document.getElementById('notification_count');
+ var notification_count = notification_count_el ? parseInt(notification_count_el.textContent) : 0;
+ helpers.storage.set(STORAGE_KEY_NOTIF_COUNT, notification_count);
+
+ if (helpers.storage.get(STORAGE_KEY_STREAM))
+ helpers.storage.remove(STORAGE_KEY_STREAM);
+ start_stream_if_needed();
+});
+
+addEventListener('unload', function () {
+ // let chance to other tabs to be a streamer via firing 'storage' event
+ if (notifications) helpers.storage.remove(STORAGE_KEY_STREAM);
+});
diff --git a/assets/js/player.js b/assets/js/player.js
index 6ddb1158..287b7ea1 100644
--- a/assets/js/player.js
+++ b/assets/js/player.js
@@ -17,6 +17,7 @@ var options = {
'remainingTimeDisplay',
'Spacer',
'captionsButton',
+ 'audioTrackButton',
'qualitySelector',
'playbackRateMenuButton',
'fullscreenToggle'
@@ -42,45 +43,53 @@ embed_url = location.origin + '/embed/' + video_data.id + embed_url.search;
var save_player_pos_key = 'save_player_pos';
videojs.Vhs.xhr.beforeRequest = function(options) {
- if (options.uri.indexOf('videoplayback') === -1 && options.uri.indexOf('local=true') === -1) {
- options.uri = options.uri + '?local=true';
+ // set local if requested not videoplayback
+ if (!options.uri.includes('videoplayback')) {
+ if (!options.uri.includes('local=true'))
+ options.uri += '?local=true';
}
return options;
};
var player = videojs('player', options);
-player.on('error', () => {
- if (video_data.params.quality !== 'dash') {
- if (!player.currentSrc().includes("local=true") && !video_data.local_disabled) {
- var currentSources = player.currentSources();
- for (var i = 0; i < currentSources.length; i++) {
- currentSources[i]["src"] += "&local=true"
- }
- player.src(currentSources)
- }
- else if (player.error().code === 2 || player.error().code === 4) {
- setTimeout(function (event) {
- console.log('An error occurred in the player, reloading...');
-
- var currentTime = player.currentTime();
- var playbackRate = player.playbackRate();
- var paused = player.paused();
-
- player.load();
-
- if (currentTime > 0.5) currentTime -= 0.5;
-
- player.currentTime(currentTime);
- player.playbackRate(playbackRate);
-
- if (!paused) player.play();
- }, 10000);
- }
+player.on('error', function () {
+ if (video_data.params.quality === 'dash') return;
+
+ var localNotDisabled = (
+ !player.currentSrc().includes('local=true') && !video_data.local_disabled
+ );
+ var reloadMakesSense = (
+ player.error().code === MediaError.MEDIA_ERR_NETWORK ||
+ player.error().code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED
+ );
+
+ if (localNotDisabled) {
+ // add local=true to all current sources
+ player.src(player.currentSources().map(function (source) {
+ source.src += '&local=true';
+ }));
+ } else if (reloadMakesSense) {
+ setTimeout(function () {
+ console.warn('An error occurred in the player, reloading...');
+
+ // After load() all parameters are reset. Save them
+ var currentTime = player.currentTime();
+ var playbackRate = player.playbackRate();
+ var paused = player.paused();
+
+ player.load();
+
+ if (currentTime > 0.5) currentTime -= 0.5;
+
+ player.currentTime(currentTime);
+ player.playbackRate(playbackRate);
+ if (!paused) player.play();
+ }, 5000);
}
});
-if (video_data.params.quality == 'dash') {
+if (video_data.params.quality === 'dash') {
player.reloadSourceOnError({
errorInterval: 10
});
@@ -89,7 +98,7 @@ if (video_data.params.quality == 'dash') {
/**
* Function for add time argument to url
* @param {String} url
- * @returns urlWithTimeArg
+ * @returns {URL} urlWithTimeArg
*/
function addCurrentTimeToURL(url) {
var urlUsed = new URL(url);
@@ -112,18 +121,12 @@ var shareOptions = {
description: player_data.description,
image: player_data.thumbnail,
get embedCode() {
- return '<iframe id="ivplayer" width="640" height="360" src="' +
- addCurrentTimeToURL(embed_url) + '" style="border:none;"></iframe>';
+ // Single quotes inside here required. HTML inserted as is into value attribute of input
+ return "<iframe id='ivplayer' width='640' height='360' src='" +
+ addCurrentTimeToURL(embed_url) + "' style='border:none;'></iframe>";
}
};
-const storage = (function () {
- try { if (localStorage.length !== -1) return localStorage; }
- catch (e) { console.info('No storage available: ' + e); }
-
- return undefined;
-})();
-
if (location.pathname.startsWith('/embed/')) {
var overlay_content = '<h1><a rel="noopener" target="_blank" href="' + location.origin + '/watch?v=' + video_data.id + '">' + player_data.title + '</a></h1>';
player.overlay({
@@ -143,11 +146,12 @@ function isMobile() {
}
if (isMobile()) {
- player.mobileUi();
+ player.mobileUi({ touchControls: { seekSeconds: 5 * player.playbackRate() } });
var buttons = ['playToggle', 'volumePanel', 'captionsButton'];
- if (video_data.params.quality !== 'dash') buttons.push('qualitySelector');
+ if (!video_data.params.listen && video_data.params.quality === 'dash') buttons.push('audioTrackButton');
+ if (video_data.params.listen || video_data.params.quality !== 'dash') buttons.push('qualitySelector');
// Create new control bar object for operation buttons
const ControlBar = videojs.getComponent('controlBar');
@@ -162,7 +166,7 @@ if (isMobile()) {
buttons.forEach(function (child) {primary_control_bar.removeChild(child);});
var operations_bar_element = operations_bar.el();
- operations_bar_element.className += ' mobile-operations-bar';
+ operations_bar_element.classList.add('mobile-operations-bar');
player.addChild(operations_bar);
// Playback menu doesn't work when it's initialized outside of the primary control bar
@@ -174,9 +178,9 @@ if (isMobile()) {
var share_element = document.getElementsByClassName('vjs-share-control')[0];
operations_bar_element.append(share_element);
- if (video_data.params.quality === 'dash') {
- var http_source_selector = document.getElementsByClassName('vjs-http-source-selector vjs-menu-button')[0];
- operations_bar_element.append(http_source_selector);
+ if (!video_data.params.listen && video_data.params.quality === 'dash') {
+ var http_source_selector = document.getElementsByClassName('vjs-http-source-selector vjs-menu-button')[0];
+ operations_bar_element.append(http_source_selector);
}
});
}
@@ -220,14 +224,14 @@ player.playbackRate(video_data.params.speed);
* Method for getting the contents of a cookie
*
* @param {String} name Name of cookie
- * @returns cookieValue
+ * @returns {String|null} cookieValue
*/
function getCookieValue(name) {
- var value = document.cookie.split(';').filter(function (item) {return item.includes(name + '=');});
-
- return (value.length >= 1)
- ? value[0].substring((name + '=').length, value[0].length)
- : null;
+ var cookiePrefix = name + '=';
+ var matchedCookie = document.cookie.split(';').find(function (item) {return item.includes(cookiePrefix);});
+ if (matchedCookie)
+ return matchedCookie.replace(cookiePrefix, '');
+ return null;
}
/**
@@ -257,11 +261,11 @@ function updateCookie(newVolume, newSpeed) {
date.setTime(date.getTime() + 63115200);
var ipRegex = /^((\d+\.){3}\d+|[A-Fa-f0-9]*:[A-Fa-f0-9:]*:[A-Fa-f0-9:]+)$/;
- var domainUsed = window.location.hostname;
+ var domainUsed = location.hostname;
// Fix for a bug in FF where the leading dot in the FQDN is not ignored
if (domainUsed.charAt(0) !== '.' && !ipRegex.test(domainUsed) && domainUsed !== 'localhost')
- domainUsed = '.' + window.location.hostname;
+ domainUsed = '.' + location.hostname;
document.cookie = 'PREFS=' + cookieData + '; SameSite=Strict; path=/; domain=' +
domainUsed + '; expires=' + date.toGMTString() + ';';
@@ -272,6 +276,9 @@ function updateCookie(newVolume, newSpeed) {
player.on('ratechange', function () {
updateCookie(null, player.playbackRate());
+ if (isMobile()) {
+ player.mobileUi({ touchControls: { seekSeconds: 5 * player.playbackRate() } });
+ }
});
player.on('volumechange', function () {
@@ -280,7 +287,7 @@ player.on('volumechange', function () {
player.on('waiting', function () {
if (player.playbackRate() > 1 && player.liveTracker.isLive() && player.liveTracker.atLiveEdge()) {
- console.info('Player has caught up to source, resetting playbackRate.');
+ console.info('Player has caught up to source, resetting playbackRate');
player.playbackRate(1);
}
});
@@ -292,12 +299,12 @@ if (video_data.premiere_timestamp && Math.round(new Date() / 1000) < video_data.
if (video_data.params.save_player_pos) {
const url = new URL(location);
const hasTimeParam = url.searchParams.has('t');
- const remeberedTime = get_video_time();
+ const rememberedTime = get_video_time();
let lastUpdated = 0;
- if(!hasTimeParam) set_seconds_after_start(remeberedTime);
+ if(!hasTimeParam) set_seconds_after_start(rememberedTime);
- const updateTime = function () {
+ player.on('timeupdate', function () {
const raw = player.currentTime();
const time = Math.floor(raw);
@@ -305,9 +312,7 @@ if (video_data.params.save_player_pos) {
save_video_time(time);
lastUpdated = time;
}
- };
-
- player.on('timeupdate', updateTime);
+ });
}
else remove_all_video_times();
@@ -347,53 +352,31 @@ if (!video_data.params.listen && video_data.params.quality === 'dash') {
targetQualityLevel = 0;
break;
default:
- const targetHeight = Number.parseInt(video_data.params.quality_dash, 10);
+ const targetHeight = parseInt(video_data.params.quality_dash);
for (let i = 0; i < qualityLevels.length; i++) {
- if (qualityLevels[i].height <= targetHeight) {
+ if (qualityLevels[i].height <= targetHeight)
targetQualityLevel = i;
- } else {
+ else
break;
- }
}
}
- for (let i = 0; i < qualityLevels.length; i++) {
- qualityLevels[i].enabled = (i === targetQualityLevel);
- }
+ qualityLevels.forEach(function (level, index) {
+ level.enabled = (index === targetQualityLevel);
+ });
});
});
}
}
player.vttThumbnails({
- src: location.origin + '/api/v1/storyboards/' + video_data.id + '?height=90',
+ src: '/api/v1/storyboards/' + video_data.id + '?height=90',
showTimestamp: true
});
// Enable annotations
if (!video_data.params.listen && video_data.params.annotations) {
- window.addEventListener('load', function (e) {
- var video_container = document.getElementById('player');
- let xhr = new XMLHttpRequest();
- xhr.responseType = 'text';
- xhr.timeout = 60000;
- xhr.open('GET', '/api/v1/annotations/' + video_data.id, true);
-
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status === 200) {
- videojs.registerPlugin('youtubeAnnotationsPlugin', youtubeAnnotationsPlugin);
- if (!player.paused()) {
- player.youtubeAnnotationsPlugin({ annotationXml: xhr.response, videoContainer: video_container });
- } else {
- player.one('play', function (event) {
- player.youtubeAnnotationsPlugin({ annotationXml: xhr.response, videoContainer: video_container });
- });
- }
- }
- }
- };
-
- window.addEventListener('__ar_annotation_click', function (e) {
+ addEventListener('load', function (e) {
+ addEventListener('__ar_annotation_click', function (e) {
const url = e.detail.url,
target = e.detail.target,
seconds = e.detail.seconds;
@@ -406,41 +389,48 @@ if (!video_data.params.listen && video_data.params.annotations) {
path = path.pathname + path.search;
if (target === 'current') {
- window.location.href = path;
+ location.href = path;
} else if (target === 'new') {
- window.open(path, '_blank');
+ open(path, '_blank');
+ }
+ });
+
+ helpers.xhr('GET', '/api/v1/annotations/' + video_data.id, {
+ responseType: 'text',
+ timeout: 60000
+ }, {
+ on200: function (response) {
+ var video_container = document.getElementById('player');
+ videojs.registerPlugin('youtubeAnnotationsPlugin', youtubeAnnotationsPlugin);
+ if (player.paused()) {
+ player.one('play', function (event) {
+ player.youtubeAnnotationsPlugin({ annotationXml: response, videoContainer: video_container });
+ });
+ } else {
+ player.youtubeAnnotationsPlugin({ annotationXml: response, videoContainer: video_container });
+ }
}
});
- xhr.send();
});
}
-function increase_volume(delta) {
+function change_volume(delta) {
const curVolume = player.volume();
let newVolume = curVolume + delta;
- if (newVolume > 1) {
- newVolume = 1;
- } else if (newVolume < 0) {
- newVolume = 0;
- }
+ newVolume = helpers.clamp(newVolume, 0, 1);
player.volume(newVolume);
}
function toggle_muted() {
- const isMuted = player.muted();
- player.muted(!isMuted);
+ player.muted(!player.muted());
}
function skip_seconds(delta) {
const duration = player.duration();
const curTime = player.currentTime();
let newTime = curTime + delta;
- if (newTime > duration) {
- newTime = duration;
- } else if (newTime < 0) {
- newTime = 0;
- }
+ newTime = helpers.clamp(newTime, 0, duration);
player.currentTime(newTime);
}
@@ -450,57 +440,21 @@ function set_seconds_after_start(delta) {
}
function save_video_time(seconds) {
- const videoId = video_data.id;
const all_video_times = get_all_video_times();
-
- all_video_times[videoId] = seconds;
-
- set_all_video_times(all_video_times);
+ all_video_times[video_data.id] = seconds;
+ helpers.storage.set(save_player_pos_key, all_video_times);
}
function get_video_time() {
- try {
- const videoId = video_data.id;
- const all_video_times = get_all_video_times();
- const timestamp = all_video_times[videoId];
-
- return timestamp || 0;
- }
- catch (e) {
- return 0;
- }
-}
-
-function set_all_video_times(times) {
- if (storage) {
- if (times) {
- try {
- storage.setItem(save_player_pos_key, JSON.stringify(times));
- } catch (e) {
- console.warn('set_all_video_times: ' + e);
- }
- } else {
- storage.removeItem(save_player_pos_key);
- }
- }
+ return get_all_video_times()[video_data.id] || 0;
}
function get_all_video_times() {
- if (storage) {
- const raw = storage.getItem(save_player_pos_key);
- if (raw !== null) {
- try {
- return JSON.parse(raw);
- } catch (e) {
- console.warn('get_all_video_times: ' + e);
- }
- }
- }
- return {};
+ return helpers.storage.get(save_player_pos_key) || {};
}
function remove_all_video_times() {
- set_all_video_times(null);
+ helpers.storage.remove(save_player_pos_key);
}
function set_time_percent(percent) {
@@ -516,21 +470,23 @@ function toggle_play() { player.paused() ? play() : pause(); }
const toggle_captions = (function () {
let toggledTrack = null;
- const onChange = function (e) {
- toggledTrack = null;
- };
- const bindChange = function (onOrOff) {
- player.textTracks()[onOrOff]('change', onChange);
- };
+
+ function bindChange(onOrOff) {
+ player.textTracks()[onOrOff]('change', function (e) {
+ toggledTrack = null;
+ });
+ }
+
// Wrapper function to ignore our own emitted events and only listen
// to events emitted by Video.js on click on the captions menu items.
- const setMode = function (track, mode) {
+ function setMode(track, mode) {
bindChange('off');
track.mode = mode;
- window.setTimeout(function () {
+ setTimeout(function () {
bindChange('on');
}, 0);
- };
+ }
+
bindChange('on');
return function () {
if (toggledTrack !== null) {
@@ -578,15 +534,11 @@ function increase_playback_rate(steps) {
const maxIndex = options.playbackRates.length - 1;
const curIndex = options.playbackRates.indexOf(player.playbackRate());
let newIndex = curIndex + steps;
- if (newIndex > maxIndex) {
- newIndex = maxIndex;
- } else if (newIndex < 0) {
- newIndex = 0;
- }
+ newIndex = helpers.clamp(newIndex, 0, maxIndex);
player.playbackRate(options.playbackRates[newIndex]);
}
-window.addEventListener('keydown', function (e) {
+addEventListener('keydown', function (e) {
if (e.target.tagName.toLowerCase() === 'input') {
// Ignore input when focus is on certain elements, e.g. form fields.
return;
@@ -619,10 +571,10 @@ window.addEventListener('keydown', function (e) {
case 'MediaStop': action = stop; break;
case 'ArrowUp':
- if (isPlayerFocused) action = increase_volume.bind(this, 0.1);
+ if (isPlayerFocused) action = change_volume.bind(this, 0.1);
break;
case 'ArrowDown':
- if (isPlayerFocused) action = increase_volume.bind(this, -0.1);
+ if (isPlayerFocused) action = change_volume.bind(this, -0.1);
break;
case 'm':
@@ -673,12 +625,11 @@ window.addEventListener('keydown', function (e) {
// TODO: Add support to play back previous video.
break;
- case '.':
- // TODO: Add support for next-frame-stepping.
- break;
- case ',':
- // TODO: Add support for previous-frame-stepping.
- break;
+ // TODO: More precise step. Now FPS is taken equal to 29.97
+ // Common FPS: https://forum.videohelp.com/threads/81868#post323588
+ // Possible solution is new HTMLVideoElement.requestVideoFrameCallback() https://wicg.github.io/video-rvfc/
+ case ',': action = function () { pause(); skip_seconds(-1/29.97); }; break;
+ case '.': action = function () { pause(); skip_seconds( 1/29.97); }; break;
case '>': action = increase_playback_rate.bind(this, 1); break;
case '<': action = increase_playback_rate.bind(this, -1); break;
@@ -697,10 +648,6 @@ window.addEventListener('keydown', function (e) {
// Add support for controlling the player volume by scrolling over it. Adapted from
// https://github.com/ctd1500/videojs-hotkeys/blob/bb4a158b2e214ccab87c2e7b95f42bc45c6bfd87/videojs.hotkeys.js#L292-L328
(function () {
- const volumeStep = 0.05;
- const enableVolumeScroll = true;
- const enableHoverScroll = true;
- const doc = document;
const pEl = document.getElementById('player');
var volumeHover = false;
@@ -710,44 +657,33 @@ window.addEventListener('keydown', function (e) {
volumeSelector.onmouseout = function () { volumeHover = false; };
}
- var mouseScroll = function mouseScroll(event) {
- var activeEl = doc.activeElement;
- if (enableHoverScroll) {
- // If we leave this undefined then it can match non-existent elements below
- activeEl = 0;
- }
-
+ function mouseScroll(event) {
// When controls are disabled, hotkeys will be disabled as well
- if (player.controls()) {
- if (volumeHover) {
- if (enableVolumeScroll) {
- event = window.event || event;
- var delta = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail)));
- event.preventDefault();
-
- if (delta === 1) {
- increase_volume(volumeStep);
- } else if (delta === -1) {
- increase_volume(-volumeStep);
- }
- }
- }
- }
- };
+ if (!player.controls() || !volumeHover) return;
+
+ event.preventDefault();
+ var wheelMove = event.wheelDelta || -event.detail;
+ var volumeSign = Math.sign(wheelMove);
+
+ change_volume(volumeSign * 0.05); // decrease/increase by 5%
+ }
player.on('mousewheel', mouseScroll);
player.on('DOMMouseScroll', mouseScroll);
}());
// Since videojs-share can sometimes be blocked, we defer it until last
-if (player.share) {
- player.share(shareOptions);
-}
+if (player.share) player.share(shareOptions);
// show the preferred caption by default
if (player_data.preferred_caption_found) {
player.ready(function () {
- player.textTracks()[1].mode = 'showing';
+ if (!video_data.params.listen && video_data.params.quality === 'dash') {
+ // play.textTracks()[0] on DASH mode is showing some debug messages
+ player.textTracks()[1].mode = 'showing';
+ } else {
+ player.textTracks()[0].mode = 'showing';
+ }
});
}
@@ -763,7 +699,7 @@ if (navigator.vendor === 'Apple Computer, Inc.' && video_data.params.listen) {
}
// Watch on Invidious link
-if (window.location.pathname.startsWith('/embed/')) {
+if (location.pathname.startsWith('/embed/')) {
const Button = videojs.getComponent('Button');
let watch_on_invidious_button = new Button(player);
@@ -778,3 +714,11 @@ if (window.location.pathname.startsWith('/embed/')) {
var cb = player.getChild('ControlBar');
cb.addChild(watch_on_invidious_button);
}
+
+addEventListener('DOMContentLoaded', function () {
+ // Save time during redirection on another instance
+ const changeInstanceLink = document.querySelector('#watch-on-another-invidious-instance > a');
+ if (changeInstanceLink) changeInstanceLink.addEventListener('click', function () {
+ changeInstanceLink.href = addCurrentTimeToURL(changeInstanceLink.href);
+ });
+});
diff --git a/assets/js/playlist_widget.js b/assets/js/playlist_widget.js
index c2565874..c92592ac 100644
--- a/assets/js/playlist_widget.js
+++ b/assets/js/playlist_widget.js
@@ -1,5 +1,6 @@
'use strict';
var playlist_data = JSON.parse(document.getElementById('playlist_data').textContent);
+var payload = 'csrf_token=' + playlist_data.csrf_token;
function add_playlist_video(target) {
var select = target.parentNode.children[0].children[1];
@@ -8,21 +9,12 @@ function add_playlist_video(target) {
var url = '/playlist_ajax?action_add_video=1&redirect=false' +
'&video_id=' + target.getAttribute('data-id') +
'&playlist_id=' + option.getAttribute('data-plid');
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('POST', url, true);
- xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status === 200) {
- option.innerText = '✓' + option.innerText;
- }
+ helpers.xhr('POST', url, {payload: payload}, {
+ on200: function (response) {
+ option.textContent = '✓' + option.textContent;
}
- };
-
- xhr.send('csrf_token=' + playlist_data.csrf_token);
+ });
}
function add_playlist_item(target) {
@@ -32,21 +24,12 @@ function add_playlist_item(target) {
var url = '/playlist_ajax?action_add_video=1&redirect=false' +
'&video_id=' + target.getAttribute('data-id') +
'&playlist_id=' + target.getAttribute('data-plid');
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('POST', url, true);
- xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status !== 200) {
- tile.style.display = '';
- }
+ helpers.xhr('POST', url, {payload: payload}, {
+ onNon200: function (xhr) {
+ tile.style.display = '';
}
- };
-
- xhr.send('csrf_token=' + playlist_data.csrf_token);
+ });
}
function remove_playlist_item(target) {
@@ -56,19 +39,10 @@ function remove_playlist_item(target) {
var url = '/playlist_ajax?action_remove_video=1&redirect=false' +
'&set_video_id=' + target.getAttribute('data-index') +
'&playlist_id=' + target.getAttribute('data-plid');
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('POST', url, true);
- xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status !== 200) {
- tile.style.display = '';
- }
+ helpers.xhr('POST', url, {payload: payload}, {
+ onNon200: function (xhr) {
+ tile.style.display = '';
}
- };
-
- xhr.send('csrf_token=' + playlist_data.csrf_token);
+ });
}
diff --git a/assets/js/subscribe_widget.js b/assets/js/subscribe_widget.js
index 45ff5706..7665a00b 100644
--- a/assets/js/subscribe_widget.js
+++ b/assets/js/subscribe_widget.js
@@ -1,8 +1,9 @@
'use strict';
var subscribe_data = JSON.parse(document.getElementById('subscribe_data').textContent);
+var payload = 'csrf_token=' + subscribe_data.csrf_token;
var subscribe_button = document.getElementById('subscribe');
-subscribe_button.parentNode['action'] = 'javascript:void(0)';
+subscribe_button.parentNode.action = 'javascript:void(0)';
if (subscribe_button.getAttribute('data-type') === 'subscribe') {
subscribe_button.onclick = subscribe;
@@ -10,87 +11,34 @@ if (subscribe_button.getAttribute('data-type') === 'subscribe') {
subscribe_button.onclick = unsubscribe;
}
-function subscribe(retries) {
- if (retries === undefined) retries = 5;
-
- if (retries <= 0) {
- console.warn('Failed to subscribe.');
- return;
- }
-
- var url = '/subscription_ajax?action_create_subscription_to_channel=1&redirect=false' +
- '&c=' + subscribe_data.ucid;
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('POST', url, true);
- xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-
+function subscribe() {
var fallback = subscribe_button.innerHTML;
subscribe_button.onclick = unsubscribe;
subscribe_button.innerHTML = '<b>' + subscribe_data.unsubscribe_text + ' | ' + subscribe_data.sub_count_text + '</b>';
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status !== 200) {
- subscribe_button.onclick = subscribe;
- subscribe_button.innerHTML = fallback;
- }
- }
- };
-
- xhr.onerror = function () {
- console.warn('Subscribing failed... ' + retries + '/5');
- setTimeout(function () { subscribe(retries - 1); }, 1000);
- };
-
- xhr.ontimeout = function () {
- console.warn('Subscribing failed... ' + retries + '/5');
- subscribe(retries - 1);
- };
+ var url = '/subscription_ajax?action_create_subscription_to_channel=1&redirect=false' +
+ '&c=' + subscribe_data.ucid;
- xhr.send('csrf_token=' + subscribe_data.csrf_token);
+ helpers.xhr('POST', url, {payload: payload, retries: 5, entity_name: 'subscribe request'}, {
+ onNon200: function (xhr) {
+ subscribe_button.onclick = subscribe;
+ subscribe_button.innerHTML = fallback;
+ }
+ });
}
-function unsubscribe(retries) {
- if (retries === undefined)
- retries = 5;
-
- if (retries <= 0) {
- console.warn('Failed to subscribe');
- return;
- }
-
- var url = '/subscription_ajax?action_remove_subscriptions=1&redirect=false' +
- '&c=' + subscribe_data.ucid;
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('POST', url, true);
- xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-
+function unsubscribe() {
var fallback = subscribe_button.innerHTML;
subscribe_button.onclick = subscribe;
subscribe_button.innerHTML = '<b>' + subscribe_data.subscribe_text + ' | ' + subscribe_data.sub_count_text + '</b>';
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status !== 200) {
- subscribe_button.onclick = unsubscribe;
- subscribe_button.innerHTML = fallback;
- }
- }
- };
-
- xhr.onerror = function () {
- console.warn('Unsubscribing failed... ' + retries + '/5');
- setTimeout(function () { unsubscribe(retries - 1); }, 1000);
- };
-
- xhr.ontimeout = function () {
- console.warn('Unsubscribing failed... ' + retries + '/5');
- unsubscribe(retries - 1);
- };
+ var url = '/subscription_ajax?action_remove_subscriptions=1&redirect=false' +
+ '&c=' + subscribe_data.ucid;
- xhr.send('csrf_token=' + subscribe_data.csrf_token);
+ helpers.xhr('POST', url, {payload: payload, retries: 5, entity_name: 'unsubscribe request'}, {
+ onNon200: function (xhr) {
+ subscribe_button.onclick = unsubscribe;
+ subscribe_button.innerHTML = fallback;
+ }
+ });
}
diff --git a/assets/js/themes.js b/assets/js/themes.js
index 3f503b38..76767d5f 100644
--- a/assets/js/themes.js
+++ b/assets/js/themes.js
@@ -1,90 +1,44 @@
'use strict';
var toggle_theme = document.getElementById('toggle_theme');
-toggle_theme.href = 'javascript:void(0);';
+toggle_theme.href = 'javascript:void(0)';
-toggle_theme.addEventListener('click', function () {
- var dark_mode = document.body.classList.contains('light-theme');
-
- var url = '/toggle_theme?redirect=false';
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('GET', url, true);
-
- set_mode(dark_mode);
- try {
- window.localStorage.setItem('dark_mode', dark_mode ? 'dark' : 'light');
- } catch (e) {}
+const STORAGE_KEY_THEME = 'dark_mode';
+const THEME_DARK = 'dark';
+const THEME_LIGHT = 'light';
- xhr.send();
-});
-
-window.addEventListener('storage', function (e) {
- if (e.key === 'dark_mode') {
- update_mode(e.newValue);
- }
-});
-
-window.addEventListener('DOMContentLoaded', function () {
- const dark_mode = document.getElementById('dark_mode_pref').textContent;
- try {
- // Update localStorage if dark mode preference changed on preferences page
- window.localStorage.setItem('dark_mode', dark_mode);
- } catch (e) {}
- update_mode(dark_mode);
+// TODO: theme state controlled by system
+toggle_theme.addEventListener('click', function () {
+ const isDarkTheme = helpers.storage.get(STORAGE_KEY_THEME) === THEME_DARK;
+ const newTheme = isDarkTheme ? THEME_LIGHT : THEME_DARK;
+ setTheme(newTheme);
+ helpers.storage.set(STORAGE_KEY_THEME, newTheme);
+ helpers.xhr('GET', '/toggle_theme?redirect=false', {}, {});
});
-
-var darkScheme = window.matchMedia('(prefers-color-scheme: dark)');
-var lightScheme = window.matchMedia('(prefers-color-scheme: light)');
-
-darkScheme.addListener(scheme_switch);
-lightScheme.addListener(scheme_switch);
-
-function scheme_switch (e) {
- // ignore this method if we have a preference set
- try {
- if (localStorage.getItem('dark_mode')) {
- return;
- }
- } catch (exception) {}
- if (e.matches) {
- if (e.media.includes('dark')) {
- set_mode(true);
- } else if (e.media.includes('light')) {
- set_mode(false);
- }
- }
-}
-
-function set_mode (bool) {
- if (bool) {
- // dark
- toggle_theme.children[0].setAttribute('class', 'icon ion-ios-sunny');
- document.body.classList.remove('no-theme');
- document.body.classList.remove('light-theme');
- document.body.classList.add('dark-theme');
+/** @param {THEME_DARK|THEME_LIGHT} theme */
+function setTheme(theme) {
+ // By default body element has .no-theme class that uses OS theme via CSS @media rules
+ // It rewrites using hard className below
+ if (theme === THEME_DARK) {
+ toggle_theme.children[0].className = 'icon ion-ios-sunny';
+ document.body.className = 'dark-theme';
} else {
- // light
- toggle_theme.children[0].setAttribute('class', 'icon ion-ios-moon');
- document.body.classList.remove('no-theme');
- document.body.classList.remove('dark-theme');
- document.body.classList.add('light-theme');
+ toggle_theme.children[0].className = 'icon ion-ios-moon';
+ document.body.className = 'light-theme';
}
}
-function update_mode (mode) {
- if (mode === 'true' /* for backwards compatibility */ || mode === 'dark') {
- // If preference for dark mode indicated
- set_mode(true);
- }
- else if (mode === 'false' /* for backwards compatibility */ || mode === 'light') {
- // If preference for light mode indicated
- set_mode(false);
- }
- else if (document.getElementById('dark_mode_pref').textContent === '' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
- // If no preference indicated here and no preference indicated on the preferences page (backend), but the browser tells us that the operating system has a dark theme
- set_mode(true);
+// Handles theme change event caused by other tab
+addEventListener('storage', function (e) {
+ if (e.key === STORAGE_KEY_THEME)
+ setTheme(helpers.storage.get(STORAGE_KEY_THEME));
+});
+
+// Set theme from preferences on page load
+addEventListener('DOMContentLoaded', function () {
+ const prefTheme = document.getElementById('dark_mode_pref').textContent;
+ if (prefTheme) {
+ setTheme(prefTheme);
+ helpers.storage.set(STORAGE_KEY_THEME, prefTheme);
}
- // else do nothing, falling back to the mode defined by the `dark_mode` preference on the preferences page (backend)
-}
+});
diff --git a/assets/js/watch.js b/assets/js/watch.js
index 29d58be5..cff84e4d 100644
--- a/assets/js/watch.js
+++ b/assets/js/watch.js
@@ -1,5 +1,7 @@
'use strict';
var video_data = JSON.parse(document.getElementById('video_data').textContent);
+var spinnerHTML = '<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
+var spinnerHTMLwithHR = spinnerHTML + '<hr>';
String.prototype.supplant = function (o) {
return this.replace(/{([^{}]*)}/g, function (a, b) {
@@ -10,24 +12,24 @@ String.prototype.supplant = function (o) {
function toggle_parent(target) {
var body = target.parentNode.parentNode.children[1];
- if (body.style.display === null || body.style.display === '') {
- target.textContent = '[ + ]';
- body.style.display = 'none';
- } else {
+ if (body.style.display === 'none') {
target.textContent = '[ − ]';
body.style.display = '';
+ } else {
+ target.textContent = '[ + ]';
+ body.style.display = 'none';
}
}
function toggle_comments(event) {
var target = event.target;
var body = target.parentNode.parentNode.parentNode.children[1];
- if (body.style.display === null || body.style.display === '') {
- target.textContent = '[ + ]';
- body.style.display = 'none';
- } else {
+ if (body.style.display === 'none') {
target.textContent = '[ − ]';
body.style.display = '';
+ } else {
+ target.textContent = '[ + ]';
+ body.style.display = 'none';
}
}
@@ -79,56 +81,31 @@ if (continue_button) {
function next_video() {
var url = new URL('https://example.com/watch?v=' + video_data.next_video);
- if (video_data.params.autoplay || video_data.params.continue_autoplay) {
+ if (video_data.params.autoplay || video_data.params.continue_autoplay)
url.searchParams.set('autoplay', '1');
- }
-
- if (video_data.params.listen !== video_data.preferences.listen) {
+ if (video_data.params.listen !== video_data.preferences.listen)
url.searchParams.set('listen', video_data.params.listen);
- }
-
- if (video_data.params.speed !== video_data.preferences.speed) {
+ if (video_data.params.speed !== video_data.preferences.speed)
url.searchParams.set('speed', video_data.params.speed);
- }
-
- if (video_data.params.local !== video_data.preferences.local) {
+ if (video_data.params.local !== video_data.preferences.local)
url.searchParams.set('local', video_data.params.local);
- }
-
url.searchParams.set('continue', '1');
+
location.assign(url.pathname + url.search);
}
function continue_autoplay(event) {
if (event.target.checked) {
- player.on('ended', function () {
- next_video();
- });
+ player.on('ended', next_video);
} else {
player.off('ended');
}
}
-function number_with_separator(val) {
- while (/(\d+)(\d{3})/.test(val.toString())) {
- val = val.toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2');
- }
- return val;
-}
-
-function get_playlist(plid, retries) {
- if (retries === undefined) retries = 5;
+function get_playlist(plid) {
var playlist = document.getElementById('playlist');
- if (retries <= 0) {
- console.warn('Failed to pull playlist');
- playlist.innerHTML = '';
- return;
- }
-
- playlist.innerHTML = ' \
- <h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3> \
- <hr>';
+ playlist.innerHTML = spinnerHTMLwithHR;
var plid_url;
if (plid.startsWith('RD')) {
@@ -142,225 +119,148 @@ function get_playlist(plid, retries) {
'&format=html&hl=' + video_data.preferences.locale;
}
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('GET', plid_url, true);
-
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status === 200) {
- playlist.innerHTML = xhr.response.playlistHtml;
- var nextVideo = document.getElementById(xhr.response.nextVideo);
- nextVideo.parentNode.parentNode.scrollTop = nextVideo.offsetTop;
-
- if (xhr.response.nextVideo) {
- player.on('ended', function () {
- var url = new URL('https://example.com/watch?v=' + xhr.response.nextVideo);
-
- url.searchParams.set('list', plid);
- if (!plid.startsWith('RD')) {
- url.searchParams.set('index', xhr.response.index);
- }
-
- if (video_data.params.autoplay || video_data.params.continue_autoplay) {
- url.searchParams.set('autoplay', '1');
- }
-
- if (video_data.params.listen !== video_data.preferences.listen) {
- url.searchParams.set('listen', video_data.params.listen);
- }
-
- if (video_data.params.speed !== video_data.preferences.speed) {
- url.searchParams.set('speed', video_data.params.speed);
- }
-
- if (video_data.params.local !== video_data.preferences.local) {
- url.searchParams.set('local', video_data.params.local);
- }
-
- location.assign(url.pathname + url.search);
- });
- }
- } else {
- playlist.innerHTML = '';
- document.getElementById('continue').style.display = '';
- }
+ helpers.xhr('GET', plid_url, {retries: 5, entity_name: 'playlist'}, {
+ on200: function (response) {
+ playlist.innerHTML = response.playlistHtml;
+
+ if (!response.nextVideo) return;
+
+ var nextVideo = document.getElementById(response.nextVideo);
+ nextVideo.parentNode.parentNode.scrollTop = nextVideo.offsetTop;
+
+ player.on('ended', function () {
+ var url = new URL('https://example.com/watch?v=' + response.nextVideo);
+
+ url.searchParams.set('list', plid);
+ if (!plid.startsWith('RD'))
+ url.searchParams.set('index', response.index);
+ if (video_data.params.autoplay || video_data.params.continue_autoplay)
+ url.searchParams.set('autoplay', '1');
+ if (video_data.params.listen !== video_data.preferences.listen)
+ url.searchParams.set('listen', video_data.params.listen);
+ if (video_data.params.speed !== video_data.preferences.speed)
+ url.searchParams.set('speed', video_data.params.speed);
+ if (video_data.params.local !== video_data.preferences.local)
+ url.searchParams.set('local', video_data.params.local);
+
+ location.assign(url.pathname + url.search);
+ });
+ },
+ onNon200: function (xhr) {
+ playlist.innerHTML = '';
+ document.getElementById('continue').style.display = '';
+ },
+ onError: function (xhr) {
+ playlist.innerHTML = spinnerHTMLwithHR;
+ },
+ onTimeout: function (xhr) {
+ playlist.innerHTML = spinnerHTMLwithHR;
}
- };
-
- xhr.onerror = function () {
- playlist = document.getElementById('playlist');
- playlist.innerHTML =
- '<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3><hr>';
-
- console.warn('Pulling playlist timed out... ' + retries + '/5');
- setTimeout(function () { get_playlist(plid, retries - 1); }, 1000);
- };
-
- xhr.ontimeout = function () {
- playlist = document.getElementById('playlist');
- playlist.innerHTML =
- '<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3><hr>';
-
- console.warn('Pulling playlist timed out... ' + retries + '/5');
- get_playlist(plid, retries - 1);
- };
-
- xhr.send();
+ });
}
-function get_reddit_comments(retries) {
- if (retries === undefined) retries = 5;
+function get_reddit_comments() {
var comments = document.getElementById('comments');
- if (retries <= 0) {
- console.warn('Failed to pull comments');
- comments.innerHTML = '';
- return;
- }
-
var fallback = comments.innerHTML;
- comments.innerHTML =
- '<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
+ comments.innerHTML = spinnerHTML;
var url = '/api/v1/comments/' + video_data.id +
'?source=reddit&format=html' +
'&hl=' + video_data.preferences.locale;
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('GET', url, true);
-
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status === 200) {
- comments.innerHTML = ' \
- <div> \
- <h3> \
- <a href="javascript:void(0)">[ − ]</a> \
- {title} \
- </h3> \
- <p> \
- <b> \
- <a href="javascript:void(0)" data-comments="youtube"> \
- {youtubeCommentsText} \
- </a> \
- </b> \
- </p> \
+
+ var onNon200 = function (xhr) { comments.innerHTML = fallback; };
+ if (video_data.params.comments[1] === 'youtube')
+ onNon200 = function (xhr) {};
+
+ helpers.xhr('GET', url, {retries: 5, entity_name: ''}, {
+ on200: function (response) {
+ comments.innerHTML = ' \
+ <div> \
+ <h3> \
+ <a href="javascript:void(0)">[ − ]</a> \
+ {title} \
+ </h3> \
+ <p> \
<b> \
- <a rel="noopener" target="_blank" href="https://reddit.com{permalink}">{redditPermalinkText}</a> \
+ <a href="javascript:void(0)" data-comments="youtube"> \
+ {youtubeCommentsText} \
+ </a> \
</b> \
- </div> \
- <div>{contentHtml}</div> \
- <hr>'.supplant({
- title: xhr.response.title,
- youtubeCommentsText: video_data.youtube_comments_text,
- redditPermalinkText: video_data.reddit_permalink_text,
- permalink: xhr.response.permalink,
- contentHtml: xhr.response.contentHtml
- });
-
- comments.children[0].children[0].children[0].onclick = toggle_comments;
- comments.children[0].children[1].children[0].onclick = swap_comments;
- } else {
- if (video_data.params.comments[1] === 'youtube') {
- console.warn('Pulling comments failed... ' + retries + '/5');
- setTimeout(function () { get_youtube_comments(retries - 1); }, 1000);
- } else {
- comments.innerHTML = fallback;
- }
- }
- }
- };
-
- xhr.onerror = function () {
- console.warn('Pulling comments failed... ' + retries + '/5');
- setTimeout(function () { get_reddit_comments(retries - 1); }, 1000);
- };
-
- xhr.ontimeout = function () {
- console.warn('Pulling comments failed... ' + retries + '/5');
- get_reddit_comments(retries - 1);
- };
-
- xhr.send();
+ </p> \
+ <b> \
+ <a rel="noopener" target="_blank" href="https://reddit.com{permalink}">{redditPermalinkText}</a> \
+ </b> \
+ </div> \
+ <div>{contentHtml}</div> \
+ <hr>'.supplant({
+ title: response.title,
+ youtubeCommentsText: video_data.youtube_comments_text,
+ redditPermalinkText: video_data.reddit_permalink_text,
+ permalink: response.permalink,
+ contentHtml: response.contentHtml
+ });
+
+ comments.children[0].children[0].children[0].onclick = toggle_comments;
+ comments.children[0].children[1].children[0].onclick = swap_comments;
+ },
+ onNon200: onNon200, // declared above
+ });
}
-function get_youtube_comments(retries) {
- if (retries === undefined) retries = 5;
+function get_youtube_comments() {
var comments = document.getElementById('comments');
- if (retries <= 0) {
- console.warn('Failed to pull comments');
- comments.innerHTML = '';
- return;
- }
-
var fallback = comments.innerHTML;
- comments.innerHTML =
- '<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
+ comments.innerHTML = spinnerHTML;
var url = '/api/v1/comments/' + video_data.id +
'?format=html' +
'&hl=' + video_data.preferences.locale +
'&thin_mode=' + video_data.preferences.thin_mode;
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('GET', url, true);
-
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status === 200) {
- comments.innerHTML = ' \
- <div> \
- <h3> \
- <a href="javascript:void(0)">[ − ]</a> \
- {commentsText} \
- </h3> \
- <b> \
- <a href="javascript:void(0)" data-comments="reddit"> \
- {redditComments} \
- </a> \
- </b> \
- </div> \
- <div>{contentHtml}</div> \
- <hr>'.supplant({
- contentHtml: xhr.response.contentHtml,
- redditComments: video_data.reddit_comments_text,
- commentsText: video_data.comments_text.supplant(
- { commentCount: number_with_separator(xhr.response.commentCount) }
- )
- });
-
- comments.children[0].children[0].children[0].onclick = toggle_comments;
- comments.children[0].children[1].children[0].onclick = swap_comments;
- } else {
- if (video_data.params.comments[1] === 'youtube') {
- setTimeout(function () { get_youtube_comments(retries - 1); }, 1000);
- } else {
- comments.innerHTML = '';
- }
- }
+
+ var onNon200 = function (xhr) { comments.innerHTML = fallback; };
+ if (video_data.params.comments[1] === 'youtube')
+ onNon200 = function (xhr) {};
+
+ helpers.xhr('GET', url, {retries: 5, entity_name: 'comments'}, {
+ on200: function (response) {
+ comments.innerHTML = ' \
+ <div> \
+ <h3> \
+ <a href="javascript:void(0)">[ − ]</a> \
+ {commentsText} \
+ </h3> \
+ <b> \
+ <a href="javascript:void(0)" data-comments="reddit"> \
+ {redditComments} \
+ </a> \
+ </b> \
+ </div> \
+ <div>{contentHtml}</div> \
+ <hr>'.supplant({
+ contentHtml: response.contentHtml,
+ redditComments: video_data.reddit_comments_text,
+ commentsText: video_data.comments_text.supplant({
+ // toLocaleString correctly splits number with local thousands separator. e.g.:
+ // '1,234,567.89' for user with English locale
+ // '1 234 567,89' for user with Russian locale
+ // '1.234.567,89' for user with Portuguese locale
+ commentCount: response.commentCount.toLocaleString()
+ })
+ });
+
+ comments.children[0].children[0].children[0].onclick = toggle_comments;
+ comments.children[0].children[1].children[0].onclick = swap_comments;
+ },
+ onNon200: onNon200, // declared above
+ onError: function (xhr) {
+ comments.innerHTML = spinnerHTML;
+ },
+ onTimeout: function (xhr) {
+ comments.innerHTML = spinnerHTML;
}
- };
-
- xhr.onerror = function () {
- comments.innerHTML =
- '<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
- console.warn('Pulling comments failed... ' + retries + '/5');
- setTimeout(function () { get_youtube_comments(retries - 1); }, 1000);
- };
-
- xhr.ontimeout = function () {
- comments.innerHTML =
- '<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
- console.warn('Pulling comments failed... ' + retries + '/5');
- get_youtube_comments(retries - 1);
- };
-
- xhr.send();
+ });
}
function get_youtube_replies(target, load_more, load_replies) {
@@ -368,91 +268,72 @@ function get_youtube_replies(target, load_more, load_replies) {
var body = target.parentNode.parentNode;
var fallback = body.innerHTML;
- body.innerHTML =
- '<h3 style="text-align:center"><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>';
+ body.innerHTML = spinnerHTML;
var url = '/api/v1/comments/' + video_data.id +
'?format=html' +
'&hl=' + video_data.preferences.locale +
'&thin_mode=' + video_data.preferences.thin_mode +
'&continuation=' + continuation;
- if (load_replies) {
- url += '&action=action_get_comment_replies';
- }
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('GET', url, true);
-
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status === 200) {
- if (load_more) {
- body = body.parentNode.parentNode;
- body.removeChild(body.lastElementChild);
- body.innerHTML += xhr.response.contentHtml;
- } else {
- body.removeChild(body.lastElementChild);
-
- var p = document.createElement('p');
- var a = document.createElement('a');
- p.appendChild(a);
-
- a.href = 'javascript:void(0)';
- a.onclick = hide_youtube_replies;
- a.setAttribute('data-sub-text', video_data.hide_replies_text);
- a.setAttribute('data-inner-text', video_data.show_replies_text);
- a.innerText = video_data.hide_replies_text;
-
- var div = document.createElement('div');
- div.innerHTML = xhr.response.contentHtml;
-
- body.appendChild(p);
- body.appendChild(div);
- }
+ if (load_replies) url += '&action=action_get_comment_replies';
+
+ helpers.xhr('GET', url, {}, {
+ on200: function (response) {
+ if (load_more) {
+ body = body.parentNode.parentNode;
+ body.removeChild(body.lastElementChild);
+ body.innerHTML += response.contentHtml;
} else {
- body.innerHTML = fallback;
- }
- }
- };
+ body.removeChild(body.lastElementChild);
+
+ var p = document.createElement('p');
+ var a = document.createElement('a');
+ p.appendChild(a);
+
+ a.href = 'javascript:void(0)';
+ a.onclick = hide_youtube_replies;
+ a.setAttribute('data-sub-text', video_data.hide_replies_text);
+ a.setAttribute('data-inner-text', video_data.show_replies_text);
+ a.textContent = video_data.hide_replies_text;
- xhr.ontimeout = function () {
- console.warn('Pulling comments failed.');
- body.innerHTML = fallback;
- };
+ var div = document.createElement('div');
+ div.innerHTML = response.contentHtml;
- xhr.send();
+ body.appendChild(p);
+ body.appendChild(div);
+ }
+ },
+ onNon200: function (xhr) {
+ body.innerHTML = fallback;
+ },
+ onTimeout: function (xhr) {
+ console.warn('Pulling comments failed');
+ body.innerHTML = fallback;
+ }
+ });
}
if (video_data.play_next) {
player.on('ended', function () {
var url = new URL('https://example.com/watch?v=' + video_data.next_video);
- if (video_data.params.autoplay || video_data.params.continue_autoplay) {
+ if (video_data.params.autoplay || video_data.params.continue_autoplay)
url.searchParams.set('autoplay', '1');
- }
-
- if (video_data.params.listen !== video_data.preferences.listen) {
+ if (video_data.params.listen !== video_data.preferences.listen)
url.searchParams.set('listen', video_data.params.listen);
- }
-
- if (video_data.params.speed !== video_data.preferences.speed) {
+ if (video_data.params.speed !== video_data.preferences.speed)
url.searchParams.set('speed', video_data.params.speed);
- }
-
- if (video_data.params.local !== video_data.preferences.local) {
+ if (video_data.params.local !== video_data.preferences.local)
url.searchParams.set('local', video_data.params.local);
- }
-
url.searchParams.set('continue', '1');
+
location.assign(url.pathname + url.search);
});
}
-window.addEventListener('load', function (e) {
- if (video_data.plid) {
+addEventListener('load', function (e) {
+ if (video_data.plid)
get_playlist(video_data.plid);
- }
if (video_data.params.comments[0] === 'youtube') {
get_youtube_comments();
diff --git a/assets/js/watched_widget.js b/assets/js/watched_widget.js
index 87989a79..f1ac9cb4 100644
--- a/assets/js/watched_widget.js
+++ b/assets/js/watched_widget.js
@@ -1,5 +1,6 @@
'use strict';
var watched_data = JSON.parse(document.getElementById('watched_data').textContent);
+var payload = 'csrf_token=' + watched_data.csrf_token;
function mark_watched(target) {
var tile = target.parentNode.parentNode.parentNode.parentNode.parentNode;
@@ -7,45 +8,27 @@ function mark_watched(target) {
var url = '/watch_ajax?action_mark_watched=1&redirect=false' +
'&id=' + target.getAttribute('data-id');
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('POST', url, true);
- xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status !== 200) {
- tile.style.display = '';
- }
+ helpers.xhr('POST', url, {payload: payload}, {
+ onNon200: function (xhr) {
+ tile.style.display = '';
}
- };
-
- xhr.send('csrf_token=' + watched_data.csrf_token);
+ });
}
function mark_unwatched(target) {
var tile = target.parentNode.parentNode.parentNode.parentNode.parentNode;
tile.style.display = 'none';
var count = document.getElementById('count');
- count.innerText = count.innerText - 1;
+ count.textContent--;
var url = '/watch_ajax?action_mark_unwatched=1&redirect=false' +
'&id=' + target.getAttribute('data-id');
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'json';
- xhr.timeout = 10000;
- xhr.open('POST', url, true);
- xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- if (xhr.status !== 200) {
- count.innerText = count.innerText - 1 + 2;
- tile.style.display = '';
- }
+ helpers.xhr('POST', url, {payload: payload}, {
+ onNon200: function (xhr) {
+ count.textContent++;
+ tile.style.display = '';
}
- };
-
- xhr.send('csrf_token=' + watched_data.csrf_token);
+ });
}
diff --git a/docker-compose.yml b/docker-compose.yml
index fa14a8e8..eb83b020 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -2,7 +2,7 @@
# Using it will build an image from the locally cloned repository.
#
# If you want to use Invidious in production, see the docker-compose.yml file provided
-# in the installation documentation: https://docs.invidious.io/Installation.md
+# in the installation documentation: https://docs.invidious.io/installation/
version: "3"
services:
diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64
index 75cab819..a703e870 100644
--- a/docker/Dockerfile.arm64
+++ b/docker/Dockerfile.arm64
@@ -1,5 +1,5 @@
FROM alpine:edge AS builder
-RUN apk add --no-cache 'crystal=1.4.1-r0' shards sqlite-static yaml-static yaml-dev libxml2-dev zlib-static openssl-libs-static openssl-dev musl-dev
+RUN apk add --no-cache 'crystal=1.4.1-r1' shards sqlite-static yaml-static yaml-dev libxml2-dev zlib-static openssl-libs-static openssl-dev musl-dev
ARG release
diff --git a/locales/bn.json b/locales/bn.json
new file mode 100644
index 00000000..3d1cb5da
--- /dev/null
+++ b/locales/bn.json
@@ -0,0 +1,97 @@
+{
+ "Subscribe": "সাবস্ক্রাইব",
+ "View channel on YouTube": "ইউটিউবে চ্যানেল দেখুন",
+ "View playlist on YouTube": "ইউটিউবে প্লেলিস্ট দেখুন",
+ "newest": "সর্ব-নতুন",
+ "oldest": "পুরানতম",
+ "popular": "জনপ্রিয়",
+ "last": "শেষটা",
+ "Next page": "পরের পৃষ্ঠা",
+ "Previous page": "আগের পৃষ্ঠা",
+ "Clear watch history?": "দেখার ইতিহাস সাফ করবেন?",
+ "New password": "নতুন পাসওয়ার্ড",
+ "New passwords must match": "নতুন পাসওয়ার্ড অবশ্যই মিলতে হবে",
+ "Cannot change password for Google accounts": "গুগল অ্যাকাউন্টগুলোর জন্য পাসওয়ার্ড পরিবর্তন করা যায় না",
+ "Authorize token?": "টোকেন অনুমোদন করবেন?",
+ "Authorize token for `x`?": "`x` -এর জন্য টোকেন অনুমোদন?",
+ "Yes": "হ্যাঁ",
+ "No": "না",
+ "Import and Export Data": "তথ্য আমদানি ও রপ্তানি",
+ "Import": "আমদানি",
+ "Import Invidious data": "ইনভিডিয়াস তথ্য আমদানি",
+ "Import YouTube subscriptions": "ইউটিউব সাবস্ক্রিপশন আনুন",
+ "Import FreeTube subscriptions (.db)": "ফ্রিটিউব সাবস্ক্রিপশন (.db) আনুন",
+ "Import NewPipe subscriptions (.json)": "নতুন পাইপ সাবস্ক্রিপশন আনুন (.json)",
+ "Import NewPipe data (.zip)": "নিউপাইপ তথ্য আনুন (.zip)",
+ "Export": "তথ্য বের করুন",
+ "Export subscriptions as OPML": "সাবস্ক্রিপশন OPML হিসাবে আনুন",
+ "Export subscriptions as OPML (for NewPipe & FreeTube)": "OPML-এ সাবস্ক্রিপশন বের করুন(নিউ পাইপ এবং ফ্রিউটিউব এর জন্য)",
+ "Export data as JSON": "JSON হিসাবে তথ্য বের করুন",
+ "Delete account?": "অ্যাকাউন্ট মুছে ফেলবেন?",
+ "History": "ইতিহাস",
+ "An alternative front-end to YouTube": "ইউটিউবের একটি বিকল্পস্বরূপ সম্মুখ-প্রান্ত",
+ "JavaScript license information": "জাভাস্ক্রিপ্ট লাইসেন্সের তথ্য",
+ "source": "সূত্র",
+ "Log in": "লগ ইন",
+ "Log in/register": "লগ ইন/রেজিস্টার",
+ "Log in with Google": "গুগল দিয়ে লগ ইন করুন",
+ "User ID": "ইউজার আইডি",
+ "Password": "পাসওয়ার্ড",
+ "Time (h:mm:ss):": "সময় (ঘণ্টা:মিনিট:সেকেন্ড):",
+ "Text CAPTCHA": "টেক্সট ক্যাপচা",
+ "Image CAPTCHA": "চিত্র ক্যাপচা",
+ "Sign In": "সাইন ইন",
+ "Register": "নিবন্ধন",
+ "E-mail": "ই-মেইল",
+ "Google verification code": "গুগল যাচাইকরণ কোড",
+ "Preferences": "পছন্দসমূহ",
+ "preferences_category_player": "প্লেয়ারের পছন্দসমূহ",
+ "preferences_video_loop_label": "সর্বদা লুপ: ",
+ "preferences_autoplay_label": "স্বয়ংক্রিয় চালু: ",
+ "preferences_continue_label": "ডিফল্টভাবে পরবর্তী চালাও: ",
+ "preferences_continue_autoplay_label": "পরবর্তী ভিডিও স্বয়ংক্রিয়ভাবে চালাও: ",
+ "preferences_listen_label": "সহজাতভাবে শোনো: ",
+ "preferences_local_label": "ভিডিও প্রক্সি করো: ",
+ "preferences_speed_label": "সহজাত গতি: ",
+ "preferences_quality_label": "পছন্দের ভিডিও মান: ",
+ "preferences_volume_label": "প্লেয়ার শব্দের মাত্রা: ",
+ "LIVE": "লাইভ",
+ "Shared `x` ago": "`x` আগে শেয়ার করা হয়েছে",
+ "Unsubscribe": "আনসাবস্ক্রাইব",
+ "generic_views_count": "{{count}}জন দেখেছে",
+ "generic_views_count_plural": "{{count}}জন দেখেছে",
+ "generic_videos_count": "{{count}}টি ভিডিও",
+ "generic_videos_count_plural": "{{count}}টি ভিডিও",
+ "generic_subscribers_count": "{{count}}জন অনুসরণকারী",
+ "generic_subscribers_count_plural": "{{count}}জন অনুসরণকারী",
+ "preferences_watch_history_label": "দেখার ইতিহাস চালু করো: ",
+ "preferences_quality_option_dash": "ড্যাশ (সময়োপযোগী মান)",
+ "preferences_quality_dash_option_auto": "স্বয়ংক্রিয়",
+ "preferences_quality_dash_option_best": "সেরা",
+ "preferences_quality_dash_option_worst": "মন্দতম",
+ "preferences_quality_dash_option_4320p": "৪৩২০পি",
+ "preferences_quality_dash_option_2160p": "২১৬০পি",
+ "preferences_quality_dash_option_1440p": "১৪৪০পি",
+ "preferences_quality_dash_option_480p": "৪৮০পি",
+ "preferences_quality_dash_option_360p": "৩৬০পি",
+ "preferences_quality_dash_option_240p": "২৪০পি",
+ "preferences_quality_dash_option_144p": "১৪৪পি",
+ "preferences_comments_label": "সহজাত মন্তব্য: ",
+ "youtube": "ইউটিউব",
+ "Fallback captions: ": "বিকল্প উপাখ্যান: ",
+ "preferences_related_videos_label": "সম্পর্কিত ভিডিও দেখাও: ",
+ "preferences_annotations_label": "সহজাতভাবে টীকা দেখাও ",
+ "preferences_quality_option_hd720": "উচ্চ৭২০",
+ "preferences_quality_dash_label": "পছন্দের ড্যাশ ভিডিও মান: ",
+ "preferences_captions_label": "সহজাত উপাখ্যান: ",
+ "generic_playlists_count": "{{count}}টি চালুতালিকা",
+ "generic_playlists_count_plural": "{{count}}টি চালুতালিকা",
+ "reddit": "রেডিট",
+ "invidious": "ইনভিডিয়াস",
+ "generic_subscriptions_count": "{{count}}টি অনুসরণ",
+ "generic_subscriptions_count_plural": "{{count}}টি অনুসরণ",
+ "preferences_quality_option_medium": "মধ্যম",
+ "preferences_quality_option_small": "ছোট",
+ "preferences_quality_dash_option_1080p": "১০৮০পি",
+ "preferences_quality_dash_option_720p": "৭২০পি"
+}
diff --git a/locales/cs.json b/locales/cs.json
index d590b5b8..97f108d7 100644
--- a/locales/cs.json
+++ b/locales/cs.json
@@ -88,7 +88,7 @@
"Only show latest unwatched video from channel: ": "Zobrazit jen nejnovější nezhlédnuté video z daného kanálu: ",
"preferences_unseen_only_label": "Zobrazit jen již nezhlédnuté: ",
"preferences_notifications_only_label": "Zobrazit pouze upozornění (pokud nějaká jsou): ",
- "Enable web notifications": "Povolit webové upozornění",
+ "Enable web notifications": "Povolit webová upozornění",
"`x` uploaded a video": "`x` nahrál(a) video",
"`x` is live": "`x` je živě",
"preferences_category_data": "Nastavení dat",
@@ -486,5 +486,6 @@
"search_filters_features_option_purchased": "Zakoupeno",
"search_filters_sort_label": "Řadit dle",
"search_filters_sort_option_relevance": "Relevantnost",
- "search_filters_apply_button": "Použít vybrané filtry"
+ "search_filters_apply_button": "Použít vybrané filtry",
+ "Popular enabled: ": "Populární povoleno: "
}
diff --git a/locales/en-US.json b/locales/en-US.json
index 7518c3a1..9701a621 100644
--- a/locales/en-US.json
+++ b/locales/en-US.json
@@ -136,6 +136,7 @@
"preferences_default_home_label": "Default homepage: ",
"preferences_feed_menu_label": "Feed menu: ",
"preferences_show_nick_label": "Show nickname on top: ",
+ "Popular enabled: ": "Popular enabled: ",
"Top enabled: ": "Top enabled: ",
"CAPTCHA enabled: ": "CAPTCHA enabled: ",
"Login enabled: ": "Login enabled: ",
diff --git a/locales/fi.json b/locales/fi.json
index 2aa64ea7..cbb18825 100644
--- a/locales/fi.json
+++ b/locales/fi.json
@@ -470,5 +470,6 @@
"search_filters_duration_option_medium": "Keskipituinen (4 - 20 minuuttia)",
"search_message_use_another_instance": " Voit myös <a href=\"`x`\">hakea toisella instanssilla</a>.",
"search_filters_date_option_none": "Milloin tahansa",
- "search_filters_type_option_all": "Mikä tahansa tyyppi"
+ "search_filters_type_option_all": "Mikä tahansa tyyppi",
+ "Popular enabled: ": "Suosittu käytössä: "
}
diff --git a/locales/fr.json b/locales/fr.json
index 6fee70f9..928a4400 100644
--- a/locales/fr.json
+++ b/locales/fr.json
@@ -116,6 +116,7 @@
"preferences_default_home_label": "Page d'accueil par défaut : ",
"preferences_feed_menu_label": "Préferences des abonnements : ",
"preferences_show_nick_label": "Afficher le nom d'utilisateur en haut à droite : ",
+ "Popular enabled: ": "Page \"populaire\" activée: ",
"Top enabled: ": "Top activé : ",
"CAPTCHA enabled: ": "CAPTCHA activé : ",
"Login enabled: ": "Autoriser l'ouverture de sessions utilisateur : ",
diff --git a/locales/hr.json b/locales/hr.json
index 94633aac..54eef7f9 100644
--- a/locales/hr.json
+++ b/locales/hr.json
@@ -107,7 +107,7 @@
"preferences_feed_menu_label": "Izbornik za feedove: ",
"preferences_show_nick_label": "Prikaži nadimak na vrhu: ",
"Top enabled: ": "Najbolji aktivirani: ",
- "CAPTCHA enabled: ": "Aktivirani CAPTCHA: ",
+ "CAPTCHA enabled: ": "CAPTCHA aktiviran: ",
"Login enabled: ": "Prijava aktivirana: ",
"Registration enabled: ": "Registracija aktivirana: ",
"Report statistics: ": "Izvještaj o statistici: ",
@@ -137,8 +137,8 @@
"Title": "Naslov",
"Playlist privacy": "Privatnost zbirke",
"Editing playlist `x`": "Uređivanje zbirke `x`",
- "Show more": "Pokaži više",
- "Show less": "Pokaži manje",
+ "Show more": "Prikaži više",
+ "Show less": "Prikaži manje",
"Watch on YouTube": "Gledaj na YouTubeu",
"Switch Invidious Instance": "Promijeni Invidious instancu",
"Hide annotations": "Sakrij napomene",
@@ -318,7 +318,7 @@
"Movies": "Filmovi",
"Download": "Preuzmi",
"Download as: ": "Preuzmi kao: ",
- "%A %B %-d, %Y": "%A, %-d. %B %Y",
+ "%A %B %-d, %Y": "%A, %-d. %B %Y.",
"(edited)": "(uređeno)",
"YouTube comment permalink": "Stalna poveznica YouTube komentara",
"permalink": "stalna poveznica",
@@ -328,40 +328,40 @@
"Videos": "Videa",
"Playlists": "Zbirke",
"Community": "Zajednica",
- "search_filters_sort_option_relevance": "značaj",
- "search_filters_sort_option_rating": "ocjena",
- "search_filters_sort_option_date": "datum",
- "search_filters_sort_option_views": "prikazi",
- "search_filters_type_label": "vrsta_sadržaja",
- "search_filters_duration_label": "trajanje",
- "search_filters_features_label": "funkcije",
- "search_filters_sort_label": "redoslijed",
- "search_filters_date_option_hour": "sat",
- "search_filters_date_option_today": "danas",
- "search_filters_date_option_week": "tjedan",
- "search_filters_date_option_month": "mjesec",
- "search_filters_date_option_year": "godina",
- "search_filters_type_option_video": "video",
- "search_filters_type_option_channel": "kanal",
+ "search_filters_sort_option_relevance": "Značaj",
+ "search_filters_sort_option_rating": "Ocjena",
+ "search_filters_sort_option_date": "Datum prijenosa",
+ "search_filters_sort_option_views": "Broj gledanja",
+ "search_filters_type_label": "Vrsta",
+ "search_filters_duration_label": "Trajanje",
+ "search_filters_features_label": "Funkcije",
+ "search_filters_sort_label": "Redoslijed",
+ "search_filters_date_option_hour": "Zadnjih sat vremena",
+ "search_filters_date_option_today": "Danas",
+ "search_filters_date_option_week": "Ovaj tjedan",
+ "search_filters_date_option_month": "Ovaj mjesec",
+ "search_filters_date_option_year": "Ova godina",
+ "search_filters_type_option_video": "Video",
+ "search_filters_type_option_channel": "Kanal",
"search_filters_type_option_playlist": "Zbirka",
- "search_filters_type_option_movie": "film",
- "search_filters_type_option_show": "emisija",
- "search_filters_features_option_hd": "hd",
- "search_filters_features_option_subtitles": "titlovi",
- "search_filters_features_option_c_commons": "creative_commons",
- "search_filters_features_option_three_d": "3d",
- "search_filters_features_option_live": "uživo",
+ "search_filters_type_option_movie": "Film",
+ "search_filters_type_option_show": "Emisija",
+ "search_filters_features_option_hd": "HD",
+ "search_filters_features_option_subtitles": "Titlovi/CC",
+ "search_filters_features_option_c_commons": "Creative Commons",
+ "search_filters_features_option_three_d": "3D",
+ "search_filters_features_option_live": "Uživo",
"search_filters_features_option_four_k": "4k",
- "search_filters_features_option_location": "lokacija",
- "search_filters_features_option_hdr": "hdr",
+ "search_filters_features_option_location": "Lokacija",
+ "search_filters_features_option_hdr": "HDR",
"Current version: ": "Trenutačna verzija: ",
"next_steps_error_message": "Nakon toga bi trebali pokušati sljedeće: ",
"next_steps_error_message_refresh": "Aktualiziraj stranicu",
"next_steps_error_message_go_to_youtube": "Idi na YouTube",
"footer_donate_page": "Doniraj",
"adminprefs_modified_source_code_url_label": "URL do repozitorija izmijenjenog izvornog koda",
- "search_filters_duration_option_short": "Kratki (< 4 minute)",
- "search_filters_duration_option_long": "Dugi (> 20 minute)",
+ "search_filters_duration_option_short": "Kratko (< 4 minute)",
+ "search_filters_duration_option_long": "Dugo (> 20 minute)",
"footer_source_code": "Izvorni kod",
"footer_modfied_source_code": "Izmijenjeni izvorni kod",
"footer_documentation": "Dokumentacija",
@@ -384,8 +384,8 @@
"search_filters_features_option_three_sixty": "360 °",
"none": "bez",
"videoinfo_youTube_embed_link": "Ugradi",
- "user_created_playlists": "`x` stvorene zbirke",
- "user_saved_playlists": "`x` spremljene zbirke",
+ "user_created_playlists": "`x` je stvorio/la zbirke",
+ "user_saved_playlists": "`x` je spremio/la zbirke",
"Video unavailable": "Video nedostupan",
"preferences_save_player_pos_label": "Spremi mjesto reprodukcije: ",
"videoinfo_watch_on_youTube": "Gledaj na YouTubeu",
@@ -432,7 +432,7 @@
"generic_subscriptions_count_2": "{{count}} pretplata",
"generic_playlists_count_0": "{{count}} zbirka",
"generic_playlists_count_1": "{{count}} zbirke",
- "generic_playlists_count_2": "{{count}} zbirka",
+ "generic_playlists_count_2": "{{count}} zbiraka",
"generic_videos_count_0": "{{count}} video",
"generic_videos_count_1": "{{count}} videa",
"generic_videos_count_2": "{{count}} videa",
@@ -476,5 +476,16 @@
"Portuguese (auto-generated)": "Portugalski (automatski generiran)",
"Spanish (auto-generated)": "Španjolski (automatski generiran)",
"preferences_watch_history_label": "Aktiviraj povijest gledanja: ",
- "search_filters_title": "Filtar"
+ "search_filters_title": "Filtri",
+ "search_filters_date_option_none": "Bilo koji datum",
+ "search_filters_date_label": "Datum prijenosa",
+ "search_message_no_results": "Nema rezultata.",
+ "search_message_use_another_instance": " Također možeš <a href=\"`x`\">tražiti na jednoj drugoj instanci</a>.",
+ "search_message_change_filters_or_query": "Pokušaj proširiti upit za pretragu i/ili promijeni filtre.",
+ "search_filters_features_option_vr180": "VR180",
+ "search_filters_duration_option_none": "Bilo koje duljine",
+ "search_filters_duration_option_medium": "Srednje (4 – 20 minuta)",
+ "search_filters_apply_button": "Primijeni odabrane filtre",
+ "search_filters_type_option_all": "Bilo koja vrsta",
+ "Popular enabled: ": "Popularni aktivirani: "
}
diff --git a/locales/id.json b/locales/id.json
index 71b7bdb1..d150cece 100644
--- a/locales/id.json
+++ b/locales/id.json
@@ -346,7 +346,7 @@
"Community": "Komunitas",
"search_filters_sort_option_relevance": "Relevansi",
"search_filters_sort_option_rating": "Penilaian",
- "search_filters_sort_option_date": "Tanggal unggah",
+ "search_filters_sort_option_date": "Tanggal Unggah",
"search_filters_sort_option_views": "Jumlah ditonton",
"search_filters_type_label": "Tipe",
"search_filters_duration_label": "Durasi",
@@ -418,5 +418,34 @@
"English (United States)": "Inggris (US)",
"preferences_watch_history_label": "Aktifkan riwayat tontonan: ",
"English (United Kingdom)": "Inggris (UK)",
- "search_filters_title": "Saring"
+ "search_filters_title": "Saring",
+ "search_message_no_results": "Tidak ada hasil yang ditemukan.",
+ "search_message_change_filters_or_query": "Coba perbanyak kueri pencarian dan/atau ubah filter Anda.",
+ "search_message_use_another_instance": " Anda juga bisa <a href=\"`x`\">mencari di peladen lain</a>.",
+ "Indonesian (auto-generated)": "Indonesia (dibuat secara otomatis)",
+ "Japanese (auto-generated)": "Jepang (dibuat secara otomatis)",
+ "Korean (auto-generated)": "Korea (dibuat secara otomatis)",
+ "Portuguese (Brazil)": "Portugis (Brasil)",
+ "Russian (auto-generated)": "Rusia (dibuat secara otomatis)",
+ "Spanish (Mexico)": "Spanyol (Meksiko)",
+ "Spanish (Spain)": "Spanyol (Spanyol)",
+ "Vietnamese (auto-generated)": "Vietnam (dibuat secara otomatis)",
+ "search_filters_features_option_vr180": "VR180",
+ "Spanish (auto-generated)": "Spanyol (dibuat secara otomatis)",
+ "Chinese": "Bahasa Cina",
+ "Chinese (Taiwan)": "Bahasa Cina (Taiwan)",
+ "Chinese (Hong Kong)": "Bahasa Cina (Hong Kong)",
+ "Chinese (China)": "Bahasa Cina (China)",
+ "French (auto-generated)": "Perancis (dibuat secara otomatis)",
+ "German (auto-generated)": "Jerman (dibuat secara otomatis)",
+ "Italian (auto-generated)": "Italia (dibuat secara otomatis)",
+ "Portuguese (auto-generated)": "Portugis (dibuat secara otomatis)",
+ "Turkish (auto-generated)": "Turki (dibuat secara otomatis)",
+ "search_filters_date_label": "Tanggal unggah",
+ "search_filters_type_option_all": "Segala jenis",
+ "search_filters_apply_button": "Terapkan saringan yang dipilih",
+ "Dutch (auto-generated)": "Belanda (dihasilkan secara otomatis)",
+ "search_filters_date_option_none": "Tanggal berapa pun",
+ "search_filters_duration_option_none": "Durasi berapa pun",
+ "search_filters_duration_option_medium": "Sedang (4 - 20 menit)"
}
diff --git a/locales/it.json b/locales/it.json
index 7ba5ff2d..ac83ac58 100644
--- a/locales/it.json
+++ b/locales/it.json
@@ -28,7 +28,7 @@
"Import and Export Data": "Importazione ed esportazione dati",
"Import": "Importa",
"Import Invidious data": "Importa dati Invidious in formato JSON",
- "Import YouTube subscriptions": "Importa le iscrizioni da YouTube",
+ "Import YouTube subscriptions": "Importa le iscrizioni da YouTube/OPML",
"Import FreeTube subscriptions (.db)": "Importa le iscrizioni da FreeTube (.db)",
"Import NewPipe subscriptions (.json)": "Importa le iscrizioni da NewPipe (.json)",
"Import NewPipe data (.zip)": "Importa i dati di NewPipe (.zip)",
@@ -340,7 +340,7 @@
"%A %B %-d, %Y": "%A %-d %B %Y",
"(edited)": "(modificato)",
"YouTube comment permalink": "Link permanente al commento di YouTube",
- "permalink": "permalink",
+ "permalink": "perma-collegamento",
"`x` marked it with a ❤": "`x` l'ha contrassegnato con un ❤",
"Audio mode": "Modalità audio",
"Video mode": "Modalità video",
@@ -385,7 +385,7 @@
"preferences_quality_dash_option_144p": "144p",
"Released under the AGPLv3 on Github.": "Rilasciato su GitHub con licenza AGPLv3.",
"preferences_quality_option_medium": "Media",
- "preferences_quality_option_small": "Piccola",
+ "preferences_quality_option_small": "Limitata",
"preferences_quality_dash_option_best": "Migliore",
"preferences_quality_dash_option_worst": "Peggiore",
"invidious": "Invidious",
@@ -393,7 +393,7 @@
"preferences_quality_option_hd720": "HD720",
"preferences_quality_dash_option_auto": "Automatica",
"videoinfo_watch_on_youTube": "Guarda su YouTube",
- "preferences_extend_desc_label": "Espandi automaticamente la descrizione del video: ",
+ "preferences_extend_desc_label": "Estendi automaticamente la descrizione del video: ",
"preferences_vr_mode_label": "Video interattivi a 360 gradi: ",
"Show less": "Mostra di meno",
"Switch Invidious Instance": "Cambia istanza Invidious",
@@ -425,5 +425,51 @@
"search_filters_type_option_show": "Serie",
"search_filters_duration_option_short": "Corto (< 4 minuti)",
"search_filters_duration_option_long": "Lungo (> 20 minuti)",
- "search_filters_features_option_purchased": "Acquistato"
+ "search_filters_features_option_purchased": "Acquistato",
+ "comments_view_x_replies": "Vedi {{count}} risposta",
+ "comments_view_x_replies_plural": "Vedi {{count}} risposte",
+ "comments_points_count": "{{count}} punto",
+ "comments_points_count_plural": "{{count}} punti",
+ "Portuguese (auto-generated)": "Portoghese (auto-generato)",
+ "crash_page_you_found_a_bug": "Sembra che tu abbia trovato un bug in Invidious!",
+ "crash_page_switch_instance": "provato a <a href=\"`x`\">usare un'altra istanza</a>",
+ "crash_page_before_reporting": "Prima di segnalare un bug, assicurati di aver:",
+ "crash_page_read_the_faq": "letto le <a href=\"`x`\">domande più frequenti (FAQ)</a>",
+ "crash_page_search_issue": "cercato tra <a href=\"`x`\"> i problemi esistenti su GitHub</a>",
+ "crash_page_report_issue": "Se niente di tutto ciò ha aiutato, per favore <a href=\"`x`\">apri un nuovo problema su GitHub</a> (preferibilmente in inglese) e includi il seguente testo nel tuo messaggio (NON tradurre il testo):",
+ "Popular enabled: ": "Popolare attivato: ",
+ "English (United Kingdom)": "Inglese (Regno Unito)",
+ "Portuguese (Brazil)": "Portoghese (Brasile)",
+ "preferences_watch_history_label": "Attiva cronologia di riproduzione: ",
+ "French (auto-generated)": "Francese (auto-generato)",
+ "search_message_use_another_instance": " Puoi anche <a href=\"`x`\">cercare in un'altra istanza</a>.",
+ "search_message_no_results": "Nessun risultato trovato.",
+ "search_message_change_filters_or_query": "Prova ad ampliare la ricerca e/o modificare i filtri.",
+ "English (United States)": "Inglese (Stati Uniti)",
+ "Cantonese (Hong Kong)": "Cantonese (Hong Kong)",
+ "Chinese": "Cinese",
+ "Chinese (China)": "Cinese (Cina)",
+ "Chinese (Hong Kong)": "Cinese (Hong Kong)",
+ "Chinese (Taiwan)": "Cinese (Taiwan)",
+ "Dutch (auto-generated)": "Olandese (auto-generato)",
+ "German (auto-generated)": "Tedesco (auto-generato)",
+ "Indonesian (auto-generated)": "Indonesiano (auto-generato)",
+ "Interlingue": "Interlingua",
+ "Italian (auto-generated)": "Italiano (auto-generato)",
+ "Japanese (auto-generated)": "Giapponese (auto-generato)",
+ "Korean (auto-generated)": "Coreano (auto-generato)",
+ "Russian (auto-generated)": "Russo (auto-generato)",
+ "Spanish (auto-generated)": "Spagnolo (auto-generato)",
+ "Spanish (Mexico)": "Spagnolo (Messico)",
+ "Spanish (Spain)": "Spagnolo (Spagna)",
+ "Turkish (auto-generated)": "Turco (auto-generato)",
+ "Vietnamese (auto-generated)": "Vietnamita (auto-generato)",
+ "search_filters_date_label": "Data caricamento",
+ "search_filters_date_option_none": "Qualunque data",
+ "search_filters_type_option_all": "Qualunque tipo",
+ "search_filters_duration_option_none": "Qualunque durata",
+ "search_filters_duration_option_medium": "Media (4 - 20 minuti)",
+ "search_filters_features_option_vr180": "VR180",
+ "search_filters_apply_button": "Applica filtri selezionati",
+ "crash_page_refresh": "provato a <a href=\"`x`\">ricaricare la pagina</a>"
}
diff --git a/locales/ja.json b/locales/ja.json
index 20d3c20e..7918fe95 100644
--- a/locales/ja.json
+++ b/locales/ja.json
@@ -433,5 +433,10 @@
"Spanish (Spain)": "スペイン語 (スペイン)",
"Vietnamese (auto-generated)": "ベトナム語 (自動生成)",
"search_filters_title": "フィルタ",
- "search_filters_features_option_three_sixty": "360°"
+ "search_filters_features_option_three_sixty": "360°",
+ "search_message_change_filters_or_query": "別のキーワードを試してみるか、検索フィルタを削除してください",
+ "search_message_no_results": "一致する検索結果はありませんでした",
+ "English (United States)": "英語 (アメリカ)",
+ "search_filters_date_label": "アップロード日",
+ "search_filters_features_option_vr180": "VR180"
}
diff --git a/locales/nb-NO.json b/locales/nb-NO.json
index 8d80c10c..77c688d5 100644
--- a/locales/nb-NO.json
+++ b/locales/nb-NO.json
@@ -460,5 +460,16 @@
"Russian (auto-generated)": "Russisk (laget automatisk)",
"Dutch (auto-generated)": "Nederlandsk (laget automatisk)",
"Turkish (auto-generated)": "Tyrkisk (laget automatisk)",
- "search_filters_title": "Filtrer"
+ "search_filters_title": "Filtrer",
+ "Popular enabled: ": "Populære påskrudd: ",
+ "search_message_change_filters_or_query": "Prøv ett mindre snevert søk og/eller endre filterne.",
+ "search_filters_duration_option_medium": "Middels (4–20 minutter)",
+ "search_message_no_results": "Resultatløst.",
+ "search_filters_type_option_all": "Alle typer",
+ "search_filters_duration_option_none": "Uvilkårlig varighet",
+ "search_message_use_another_instance": " Du kan også <a href=\"`x`\">søke på en annen instans</a>.",
+ "search_filters_date_label": "Opplastningsdato",
+ "search_filters_apply_button": "Bruk valgte filtre",
+ "search_filters_date_option_none": "Siden begynnelsen",
+ "search_filters_features_option_vr180": "VR180"
}
diff --git a/locales/pt-BR.json b/locales/pt-BR.json
index df149564..9576d646 100644
--- a/locales/pt-BR.json
+++ b/locales/pt-BR.json
@@ -470,5 +470,6 @@
"Spanish (Spain)": "Espanhol (Espanha)",
"Turkish (auto-generated)": "Turco (gerado automaticamente)",
"search_filters_duration_option_medium": "Médio (4 - 20 minutos)",
- "search_filters_features_option_vr180": "VR180"
+ "search_filters_features_option_vr180": "VR180",
+ "Popular enabled: ": "Popular habilitado: "
}
diff --git a/locales/pt-PT.json b/locales/pt-PT.json
index a57a2939..b00ebc72 100644
--- a/locales/pt-PT.json
+++ b/locales/pt-PT.json
@@ -21,15 +21,15 @@
"No": "Não",
"Import and Export Data": "Importar e exportar dados",
"Import": "Importar",
- "Import Invidious data": "Importar dados do Invidious",
- "Import YouTube subscriptions": "Importar subscrições do YouTube",
+ "Import Invidious data": "Importar dados JSON do Invidious",
+ "Import YouTube subscriptions": "Importar subscrições OPML ou do YouTube",
"Import FreeTube subscriptions (.db)": "Importar subscrições do FreeTube (.db)",
"Import NewPipe subscriptions (.json)": "Importar subscrições do NewPipe (.json)",
"Import NewPipe data (.zip)": "Importar dados do NewPipe (.zip)",
"Export": "Exportar",
"Export subscriptions as OPML": "Exportar subscrições como OPML",
"Export subscriptions as OPML (for NewPipe & FreeTube)": "Exportar subscrições como OPML (para NewPipe e FreeTube)",
- "Export data as JSON": "Exportar dados como JSON",
+ "Export data as JSON": "Exportar dados do Invidious como JSON",
"Delete account?": "Eliminar conta?",
"History": "Histórico",
"An alternative front-end to YouTube": "Uma interface alternativa ao YouTube",
@@ -60,13 +60,13 @@
"preferences_volume_label": "Volume da reprodução: ",
"preferences_comments_label": "Preferência dos comentários: ",
"youtube": "YouTube",
- "reddit": "reddit",
+ "reddit": "Reddit",
"preferences_captions_label": "Legendas predefinidas: ",
"Fallback captions: ": "Legendas alternativas: ",
"preferences_related_videos_label": "Mostrar vídeos relacionados: ",
"preferences_annotations_label": "Mostrar anotações sempre: ",
"preferences_extend_desc_label": "Estender automaticamente a descrição do vídeo: ",
- "preferences_vr_mode_label": "Vídeos interativos de 360 graus: ",
+ "preferences_vr_mode_label": "Vídeos interativos de 360 graus (necessita de WebGL): ",
"preferences_category_visual": "Preferências visuais",
"preferences_player_style_label": "Estilo do reprodutor: ",
"Dark mode: ": "Modo escuro: ",
@@ -374,5 +374,39 @@
"next_steps_error_message": "Pode tentar as seguintes opções: ",
"next_steps_error_message_refresh": "Atualizar",
"next_steps_error_message_go_to_youtube": "Ir ao YouTube",
- "search_filters_title": "Filtro"
+ "search_filters_title": "Filtro",
+ "generic_videos_count": "{{count}} vídeo",
+ "generic_videos_count_plural": "{{count}} vídeos",
+ "generic_playlists_count": "{{count}} lista de reprodução",
+ "generic_playlists_count_plural": "{{count}} listas de reprodução",
+ "generic_subscriptions_count": "{{count}} subscrição",
+ "generic_subscriptions_count_plural": "{{count}} subscrições",
+ "generic_views_count": "{{count}} visualização",
+ "generic_views_count_plural": "{{count}} visualizações",
+ "generic_subscribers_count": "{{count}} subscritor",
+ "generic_subscribers_count_plural": "{{count}} subscritores",
+ "preferences_quality_dash_option_4320p": "4320p",
+ "preferences_quality_dash_label": "Qualidade de vídeo DASH preferencial ",
+ "preferences_quality_dash_option_2160p": "2160p",
+ "subscriptions_unseen_notifs_count": "{{count}} notificação por ver",
+ "subscriptions_unseen_notifs_count_plural": "{{count}} notificações por ver",
+ "Popular enabled: ": "Página \"Popular\" ativada: ",
+ "search_message_no_results": "Nenhum resultado encontrado.",
+ "preferences_quality_dash_option_auto": "Automática",
+ "preferences_region_label": "País para o conteúdo: ",
+ "preferences_quality_dash_option_1440p": "1440p",
+ "preferences_quality_dash_option_720p": "720p",
+ "preferences_watch_history_label": "Ativar histórico de visualizações ",
+ "preferences_quality_dash_option_best": "Melhor",
+ "preferences_quality_dash_option_worst": "Pior",
+ "preferences_quality_dash_option_144p": "144p",
+ "invidious": "Invidious",
+ "preferences_quality_option_hd720": "HD720",
+ "preferences_quality_option_dash": "DASH (qualidade adaptativa)",
+ "preferences_quality_option_medium": "Média",
+ "preferences_quality_option_small": "Pequena",
+ "preferences_quality_dash_option_1080p": "1080p",
+ "preferences_quality_dash_option_480p": "480p",
+ "preferences_quality_dash_option_360p": "360p",
+ "preferences_quality_dash_option_240p": "240p"
}
diff --git a/locales/pt.json b/locales/pt.json
index df237649..654cfdeb 100644
--- a/locales/pt.json
+++ b/locales/pt.json
@@ -11,7 +11,7 @@
"preferences_show_nick_label": "Mostrar nome de utilizador em cima: ",
"preferences_automatic_instance_redirect_label": "Redirecionamento de instância automática (solução de último recurso para redirect.invidious.io): ",
"preferences_category_misc": "Preferências diversas",
- "preferences_vr_mode_label": "Vídeos interativos de 360 graus: ",
+ "preferences_vr_mode_label": "Vídeos interativos de 360 graus (necessita de WebGL): ",
"preferences_extend_desc_label": "Estender automaticamente a descrição do vídeo: ",
"next_steps_error_message_go_to_youtube": "Ir ao YouTube",
"next_steps_error_message": "Pode tentar as seguintes opções: ",
@@ -246,15 +246,15 @@
"JavaScript license information": "Informação de licença do JavaScript",
"An alternative front-end to YouTube": "Uma interface alternativa ao YouTube",
"History": "Histórico",
- "Export data as JSON": "Exportar dados como JSON",
+ "Export data as JSON": "Exportar dados Invidious como JSON",
"Export subscriptions as OPML (for NewPipe & FreeTube)": "Exportar subscrições como OPML (para NewPipe e FreeTube)",
"Export subscriptions as OPML": "Exportar subscrições como OPML",
"Export": "Exportar",
"Import NewPipe data (.zip)": "Importar dados do NewPipe (.zip)",
"Import NewPipe subscriptions (.json)": "Importar subscrições do NewPipe (.json)",
"Import FreeTube subscriptions (.db)": "Importar subscrições do FreeTube (.db)",
- "Import YouTube subscriptions": "Importar subscrições do YouTube",
- "Import Invidious data": "Importar dados do Invidious",
+ "Import YouTube subscriptions": "Importar subscrições do YouTube/OPML",
+ "Import Invidious data": "Importar dados JSON do Invidious",
"Import": "Importar",
"No": "Não",
"Yes": "Sim",
@@ -432,9 +432,44 @@
"crash_page_before_reporting": "Antes de reportar um erro, verifique se:",
"crash_page_refresh": "tentou <a href=\"`x`\">recarregar a página</a>",
"crash_page_switch_instance": "tentou <a href=\"`x`\">usar outra instância</a>",
- "crash_page_read_the_faq": "leu as <a href=\"`x`\">Perguntas frequentes (FAQ)</a>",
+ "crash_page_read_the_faq": "leia as <a href=\"`x`\">Perguntas frequentes (FAQ)</a>",
"crash_page_search_issue": "procurou se <a href=\"`x`\">o erro já foi reportado no GitHub</a>",
"crash_page_report_issue": "Se nenhuma opção acima ajudou, por favor <a href=\"`x`\">abra um novo problema no Github</a> (preferencialmente em inglês) e inclua o seguinte texto tal qual (NÃO o traduza):",
"user_created_playlists": "`x` listas de reprodução criadas",
- "search_filters_title": "Filtro"
+ "search_filters_title": "Filtro",
+ "Chinese (Taiwan)": "Chinês (Taiwan)",
+ "search_message_no_results": "Nenhum resultado encontrado.",
+ "search_message_change_filters_or_query": "Tente alargar os termos genéricos da pesquisa e/ou alterar os filtros.",
+ "search_message_use_another_instance": " Também pode <a href=\"`x`\">pesquisar noutra instância</a>.",
+ "English (United Kingdom)": "Inglês (Reino Unido)",
+ "English (United States)": "Inglês (Estados Unidos)",
+ "Cantonese (Hong Kong)": "Cantonês (Hong Kong)",
+ "Chinese": "Chinês",
+ "Chinese (Hong Kong)": "Chinês (Hong Kong)",
+ "Dutch (auto-generated)": "Holandês (gerado automaticamente)",
+ "French (auto-generated)": "Francês (gerado automaticamente)",
+ "German (auto-generated)": "Alemão (gerado automaticamente)",
+ "Indonesian (auto-generated)": "Indonésio (gerado automaticamente)",
+ "Interlingue": "Interlíngua",
+ "Italian (auto-generated)": "Italiano (gerado automaticamente)",
+ "Japanese (auto-generated)": "Japonês (gerado automaticamente)",
+ "Korean (auto-generated)": "Coreano (gerado automaticamente)",
+ "Portuguese (auto-generated)": "Português (gerado automaticamente)",
+ "Portuguese (Brazil)": "Português (Brasil)",
+ "Turkish (auto-generated)": "Turco (gerado automaticamente)",
+ "Vietnamese (auto-generated)": "Vietnamita (gerado automaticamente)",
+ "search_filters_duration_option_medium": "Médio (4 - 20 minutos)",
+ "search_filters_features_option_vr180": "VR180",
+ "search_filters_apply_button": "Aplicar filtros selecionados",
+ "Spanish (auto-generated)": "Espanhol (gerado automaticamente)",
+ "Spanish (Mexico)": "Espanhol (México)",
+ "preferences_watch_history_label": "Ativar histórico de reprodução: ",
+ "Chinese (China)": "Chinês (China)",
+ "Russian (auto-generated)": "Russo (gerado automaticamente)",
+ "Spanish (Spain)": "Espanhol (Espanha)",
+ "search_filters_date_label": "Data de publicação",
+ "search_filters_date_option_none": "Qualquer data",
+ "search_filters_type_option_all": "Qualquer tipo",
+ "search_filters_duration_option_none": "Qualquer duração",
+ "Popular enabled: ": "Página \"popular\" ativada: "
}
diff --git a/locales/ru.json b/locales/ru.json
index 0199f61f..4680e350 100644
--- a/locales/ru.json
+++ b/locales/ru.json
@@ -41,8 +41,8 @@
"User ID": "ID пользователя",
"Password": "Пароль",
"Time (h:mm:ss):": "Время (ч:мм:сс):",
- "Text CAPTCHA": "Текст капчи",
- "Image CAPTCHA": "Изображение капчи",
+ "Text CAPTCHA": "Текстовая капча (англ.)",
+ "Image CAPTCHA": "Капча-картинка",
"Sign In": "Войти",
"Register": "Зарегистрироваться",
"E-mail": "Электронная почта",
@@ -51,7 +51,7 @@
"preferences_category_player": "Настройки проигрывателя",
"preferences_video_loop_label": "Всегда повторять: ",
"preferences_autoplay_label": "Автовоспроизведение: ",
- "preferences_continue_label": "Всегда включать следующее видео? ",
+ "preferences_continue_label": "Переходить к следующему видео? ",
"preferences_continue_autoplay_label": "Автопроигрывание следующего видео: ",
"preferences_listen_label": "Режим «только аудио» по умолчанию: ",
"preferences_local_label": "Проигрывать видео через прокси? ",
@@ -71,15 +71,15 @@
"preferences_player_style_label": "Стиль проигрывателя: ",
"Dark mode: ": "Тёмное оформление: ",
"preferences_dark_mode_label": "Тема: ",
- "dark": "темная",
+ "dark": "тёмная",
"light": "светлая",
"preferences_thin_mode_label": "Облегчённое оформление: ",
"preferences_category_misc": "Прочие настройки",
- "preferences_automatic_instance_redirect_label": "Автоматическое перенаправление на зеркало сайта (переход на redirect.invidious.io): ",
+ "preferences_automatic_instance_redirect_label": "Автоматическая смена зеркала (переход на redirect.invidious.io): ",
"preferences_category_subscription": "Настройки подписок",
- "preferences_annotations_subscribed_label": "Всегда показывать аннотации в видео каналов, на которые вы подписаны? ",
- "Redirect homepage to feed: ": "Отображать видео с каналов, на которые вы подписаны, как главную страницу: ",
- "preferences_max_results_label": "Число видео, на которые вы подписаны, в ленте: ",
+ "preferences_annotations_subscribed_label": "Всегда показывать аннотации на каналах из ваших подписок? ",
+ "Redirect homepage to feed: ": "Показывать подписки на главной странице: ",
+ "preferences_max_results_label": "Число видео в ленте: ",
"preferences_sort_label": "Сортировать видео: ",
"published": "по дате публикации",
"published - reverse": "по дате публикации в обратном порядке",
@@ -96,10 +96,10 @@
"`x` is live": "`x` в прямом эфире",
"preferences_category_data": "Настройки данных",
"Clear watch history": "Очистить историю просмотров",
- "Import/export data": "Импорт/Экспорт данных",
+ "Import/export data": "Импорт и экспорт данных",
"Change password": "Изменить пароль",
- "Manage subscriptions": "Управлять подписками",
- "Manage tokens": "Управлять токенами",
+ "Manage subscriptions": "Управление подписками",
+ "Manage tokens": "Управление токенами",
"Watch history": "История просмотров",
"Delete account": "Удалить аккаунт",
"preferences_category_admin": "Администраторские настройки",
@@ -112,8 +112,8 @@
"Registration enabled: ": "Включить регистрацию? ",
"Report statistics: ": "Сообщать статистику? ",
"Save preferences": "Сохранить настройки",
- "Subscription manager": "Менеджер подписок",
- "Token manager": "Менеджер токенов",
+ "Subscription manager": "Управление подписками",
+ "Token manager": "Управление токенами",
"Token": "Токен",
"Import/export": "Импорт и экспорт",
"unsubscribe": "отписаться",
@@ -122,9 +122,9 @@
"search": "поиск",
"Log out": "Выйти",
"Released under the AGPLv3 on Github.": "Выпущено под лицензией AGPLv3 на GitHub.",
- "Source available here.": "Исходный код доступен здесь.",
- "View JavaScript license information.": "Посмотреть информацию по лицензии JavaScript.",
- "View privacy policy.": "Посмотреть политику конфиденциальности.",
+ "Source available here.": "Исходный код.",
+ "View JavaScript license information.": "Информация о лицензиях JavaScript.",
+ "View privacy policy.": "Политика конфиденциальности.",
"Trending": "В тренде",
"Public": "Публичный",
"Unlisted": "Нет в списке",
@@ -135,42 +135,42 @@
"Delete playlist": "Удалить плейлист",
"Create playlist": "Создать плейлист",
"Title": "Заголовок",
- "Playlist privacy": "Конфиденциальность плейлиста",
+ "Playlist privacy": "Видимость плейлиста",
"Editing playlist `x`": "Редактирование плейлиста `x`",
- "Show more": "Показать больше",
- "Show less": "Показать меньше",
+ "Show more": "Развернуть",
+ "Show less": "Свернуть",
"Watch on YouTube": "Смотреть на YouTube",
- "Switch Invidious Instance": "Сменить экземпляр Invidious",
+ "Switch Invidious Instance": "Сменить зеркало Invidious",
"Hide annotations": "Скрыть аннотации",
"Show annotations": "Показать аннотации",
"Genre: ": "Жанр: ",
"License: ": "Лицензия: ",
"Family friendly? ": "Семейный просмотр: ",
- "Wilson score: ": "Рейтинг Уилсона: ",
+ "Wilson score: ": "Оценка Уилсона: ",
"Engagement: ": "Вовлечённость: ",
"Whitelisted regions: ": "Доступно в регионах: ",
"Blacklisted regions: ": "Недоступно в регионах: ",
"Shared `x`": "Опубликовано `x`",
"Premieres in `x`": "Премьера через `x`",
"Premieres `x`": "Премьера `x`",
- "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Похоже, у вас отключён JavaScript. Чтобы увидить комментарии, нажмите сюда, но учтите: они могут загружаться немного медленнее.",
- "View YouTube comments": "Смотреть комментарии с YouTube",
+ "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Похоже, у вас отключён JavaScript. Нажмите сюда, чтобы увидеть комментарии. Но учтите: они могут загружаться немного медленнее.",
+ "View YouTube comments": "Показать комментарии с YouTube",
"View more comments on Reddit": "Посмотреть больше комментариев на Reddit",
"View `x` comments": {
- "([^.,0-9]|^)1([^.,0-9]|$)": "Показать `x` комментариев",
- "": "Показать `x` комментариев"
+ "([^.,0-9]|^)1([^.,0-9]|$)": "Показано `x` комментариев",
+ "": "Показано `x` комментариев"
},
"View Reddit comments": "Смотреть комментарии с Reddit",
"Hide replies": "Скрыть ответы",
"Show replies": "Показать ответы",
"Incorrect password": "Неправильный пароль",
"Quota exceeded, try again in a few hours": "Лимит превышен, попробуйте снова через несколько часов",
- "Unable to log in, make sure two-factor authentication (Authenticator or SMS) is turned on.": "Войти не удаётся. Проверьте, не включена ли двухфакторная аутентификация (по коду или смс).",
+ "Unable to log in, make sure two-factor authentication (Authenticator or SMS) is turned on.": "Не удалось войти. Проверьте, не включена ли двухфакторная аутентификация (по коду или смс).",
"Invalid TFA code": "Неправильный код двухфакторной аутентификации",
- "Login failed. This may be because two-factor authentication is not turned on for your account.": "Не удаётся войти. Это может быть из-за того, что в вашем аккаунте не включена двухфакторная аутентификация.",
+ "Login failed. This may be because two-factor authentication is not turned on for your account.": "Не удалось войти. Это может быть из-за того, что в вашем аккаунте не включена двухфакторная аутентификация.",
"Wrong answer": "Неправильный ответ",
"Erroneous CAPTCHA": "Неправильная капча",
- "CAPTCHA is a required field": "Необходимо пройти капчу",
+ "CAPTCHA is a required field": "Необходимо решить капчу",
"User ID is a required field": "Необходимо ввести ID пользователя",
"Password is a required field": "Необходимо ввести пароль",
"Wrong username or password": "Неправильный логин или пароль",
@@ -185,8 +185,8 @@
"Could not get channel info.": "Не удаётся получить информацию об этом канале.",
"Could not fetch comments": "Не удаётся загрузить комментарии",
"`x` ago": "`x` назад",
- "Load more": "Загрузить больше",
- "Could not create mix.": "Не удаётся создать микс.",
+ "Load more": "Загрузить ещё",
+ "Could not create mix.": "Не удалось создать микс.",
"Empty playlist": "Плейлист пуст",
"Not a playlist.": "Некорректный плейлист.",
"Playlist does not exist.": "Плейлист не существует.",
@@ -219,7 +219,7 @@
"Croatian": "Хорватский",
"Czech": "Чешский",
"Danish": "Датский",
- "Dutch": "Нидерландский",
+ "Dutch": "Голландский",
"Esperanto": "Эсперанто",
"Estonian": "Эстонский",
"Filipino": "Филиппинский",
@@ -229,8 +229,8 @@
"Georgian": "Грузинский",
"German": "Немецкий",
"Greek": "Греческий",
- "Gujarati": "Гуджаратский",
- "Haitian Creole": "Гаит. креольский",
+ "Gujarati": "Гуджарати",
+ "Haitian Creole": "Гаитянский креольский",
"Hausa": "Хауса",
"Hawaiian": "Гавайский",
"Hebrew": "Иврит",
@@ -251,7 +251,7 @@
"Kurdish": "Курдский",
"Kyrgyz": "Киргизский",
"Lao": "Лаосский",
- "Latin": "Латинский",
+ "Latin": "Латынь",
"Latvian": "Латышский",
"Lithuanian": "Литовский",
"Luxembourgish": "Люксембургский",
@@ -262,9 +262,9 @@
"Maltese": "Мальтийский",
"Maori": "Маори",
"Marathi": "Маратхи",
- "Mongolian": "Монгольская",
+ "Mongolian": "Монгольский",
"Nepali": "Непальский",
- "Norwegian Bokmål": "Норвежский",
+ "Norwegian Bokmål": "Норвежский букмол",
"Nyanja": "Ньянджа",
"Pashto": "Пушту",
"Persian": "Персидский",
@@ -299,7 +299,7 @@
"Vietnamese": "Вьетнамский",
"Welsh": "Валлийский",
"Western Frisian": "Западнофризский",
- "Xhosa": "Коса",
+ "Xhosa": "Коса (кхоса)",
"Yiddish": "Идиш",
"Yoruba": "Йоруба",
"Zulu": "Зулусский",
@@ -311,7 +311,7 @@
"Rating: ": "Рейтинг: ",
"preferences_locale_label": "Язык: ",
"View as playlist": "Смотреть как плейлист",
- "Default": "По-умолчанию",
+ "Default": "По умолчанию",
"Music": "Музыка",
"Gaming": "Игры",
"News": "Новости",
@@ -328,14 +328,14 @@
"Videos": "Видео",
"Playlists": "Плейлисты",
"Community": "Сообщество",
- "search_filters_sort_option_relevance": "Актуальность",
- "search_filters_sort_option_rating": "Рейтинг",
- "search_filters_sort_option_date": "Дата загрузки",
- "search_filters_sort_option_views": "Просмотры",
+ "search_filters_sort_option_relevance": "по актуальности",
+ "search_filters_sort_option_rating": "по рейтингу",
+ "search_filters_sort_option_date": "по дате загрузки",
+ "search_filters_sort_option_views": "по просмотрам",
"search_filters_type_label": "Тип",
"search_filters_duration_label": "Длительность",
- "search_filters_features_label": "Функции",
- "search_filters_sort_label": "Сортировать по",
+ "search_filters_features_label": "Дополнительно",
+ "search_filters_sort_label": "Сортировать",
"search_filters_date_option_hour": "Последний час",
"search_filters_date_option_today": "Сегодня",
"search_filters_date_option_week": "Эта неделя",
@@ -345,7 +345,7 @@
"search_filters_type_option_channel": "Канал",
"search_filters_type_option_playlist": "Плейлист",
"search_filters_type_option_movie": "Фильм",
- "search_filters_type_option_show": "Показать",
+ "search_filters_type_option_show": "Сериал",
"search_filters_features_option_hd": "HD",
"search_filters_features_option_subtitles": "Субтитры",
"search_filters_features_option_c_commons": "Creative Commons",
@@ -368,28 +368,28 @@
"English (United States)": "Английский (США)",
"Cantonese (Hong Kong)": "Кантонский (Гонконг)",
"Chinese (Taiwan)": "Китайский (Тайвань)",
- "Dutch (auto-generated)": "Голландский (автоматический)",
- "German (auto-generated)": "Немецкий (автоматический)",
- "Indonesian (auto-generated)": "Индонезийский (автоматический)",
- "Italian (auto-generated)": "Итальянский (автоматический)",
+ "Dutch (auto-generated)": "Голландский (созданы автоматически)",
+ "German (auto-generated)": "Немецкий (созданы автоматически)",
+ "Indonesian (auto-generated)": "Индонезийский (созданы автоматически)",
+ "Italian (auto-generated)": "Итальянский (созданы автоматически)",
"Interlingue": "Окциденталь",
- "Russian (auto-generated)": "Русский (автоматический)",
- "Spanish (auto-generated)": "Испанский (автоматический)",
+ "Russian (auto-generated)": "Русский (созданы автоматически)",
+ "Spanish (auto-generated)": "Испанский (созданы автоматически)",
"Spanish (Spain)": "Испанский (Испания)",
- "Turkish (auto-generated)": "Турецкий (автоматический)",
- "Vietnamese (auto-generated)": "Вьетнамский (автоматический)",
+ "Turkish (auto-generated)": "Турецкий (созданы автоматически)",
+ "Vietnamese (auto-generated)": "Вьетнамский (созданы автоматически)",
"footer_documentation": "Документация",
"adminprefs_modified_source_code_url_label": "Ссылка на нашу ветку репозитория",
"none": "ничего",
"videoinfo_watch_on_youTube": "Смотреть на YouTube",
- "videoinfo_youTube_embed_link": "Встраиваемый элемент",
- "videoinfo_invidious_embed_link": "Встраиваемая ссылка",
+ "videoinfo_youTube_embed_link": "Версия для встраивания",
+ "videoinfo_invidious_embed_link": "Ссылка для встраивания",
"download_subtitles": "Субтитры - `x` (.vtt)",
"user_created_playlists": "`x` созданных плейлистов",
- "crash_page_you_found_a_bug": "Похоже вы нашли баг в Invidious!",
+ "crash_page_you_found_a_bug": "Похоже, вы нашли ошибку в Invidious!",
"crash_page_before_reporting": "Прежде чем сообщать об ошибке, убедитесь, что вы:",
"crash_page_refresh": "пробовали <a href=\"`x`\"> перезагрузить страницу</a>",
- "crash_page_report_issue": "Если ни один вариант не помог, пожалуйста <a href=\"`x`\">откройте новую проблему на GitHub</a> (желательно на английском) и приложите следующий текст к вашему сообщению (НЕ переводите его):",
+ "crash_page_report_issue": "Если ни один вариант не помог, пожалуйста <a href=\"`x`\">откройте новую проблему на GitHub</a> (на английском, пжлста) и приложите следующий текст к вашему сообщению (НЕ переводите его):",
"generic_videos_count_0": "{{count}} видео",
"generic_videos_count_1": "{{count}} видео",
"generic_videos_count_2": "{{count}} видео",
@@ -417,8 +417,8 @@
"generic_views_count_0": "{{count}} просмотр",
"generic_views_count_1": "{{count}} просмотра",
"generic_views_count_2": "{{count}} просмотров",
- "French (auto-generated)": "Французский (автоматический)",
- "Portuguese (auto-generated)": "Португальский (автоматический)",
+ "French (auto-generated)": "Французский (созданы автоматически)",
+ "Portuguese (auto-generated)": "Португальский (созданы автоматически)",
"generic_count_days_0": "{{count}} день",
"generic_count_days_1": "{{count}} дня",
"generic_count_days_2": "{{count}} дней",
@@ -438,12 +438,12 @@
"search_filters_features_option_purchased": "Приобретено",
"videoinfo_started_streaming_x_ago": "Трансляция началась `x` назад",
"crash_page_switch_instance": "пробовали <a href=\"`x`\">использовать другое зеркало</a>",
- "crash_page_read_the_faq": "прочли <a href=\"`x`\">Частые Вопросы (ЧаВо)</a>",
+ "crash_page_read_the_faq": "прочли ответы на <a href=\"`x`\">Частые Вопросы (ЧаВо)</a>",
"Chinese": "Китайский",
"Chinese (Hong Kong)": "Китайский (Гонконг)",
- "Japanese (auto-generated)": "Японский (автоматический)",
+ "Japanese (auto-generated)": "Японский (созданы автоматически)",
"Chinese (China)": "Китайский (Китай)",
- "Korean (auto-generated)": "Корейский (автоматический)",
+ "Korean (auto-generated)": "Корейский (созданы автоматически)",
"generic_count_months_0": "{{count}} месяц",
"generic_count_months_1": "{{count}} месяца",
"generic_count_months_2": "{{count}} месяцев",
@@ -455,7 +455,7 @@
"footer_original_source_code": "Оригинальный исходный код",
"footer_modfied_source_code": "Изменённый исходный код",
"user_saved_playlists": "`x` сохранённых плейлистов",
- "crash_page_search_issue": "искали <a href=\"`x`\">похожую проблему на GitHub</a>",
+ "crash_page_search_issue": "поискали <a href=\"`x`\">похожую проблему на GitHub</a>",
"comments_points_count_0": "{{count}} плюс",
"comments_points_count_1": "{{count}} плюса",
"comments_points_count_2": "{{count}} плюсов",
@@ -464,7 +464,7 @@
"preferences_quality_option_dash": "DASH (автоматическое качество)",
"preferences_quality_option_hd720": "HD720",
"preferences_quality_option_medium": "Среднее",
- "preferences_quality_dash_label": "Предпочтительное автоматическое качество видео: ",
+ "preferences_quality_dash_label": "Предпочтительное качество для DASH: ",
"preferences_quality_dash_option_worst": "Очень низкое",
"preferences_quality_dash_option_4320p": "4320p",
"preferences_quality_dash_option_2160p": "2160p",
@@ -475,16 +475,17 @@
"Video unavailable": "Видео недоступно",
"preferences_save_player_pos_label": "Запоминать позицию: ",
"preferences_region_label": "Страна: ",
- "preferences_watch_history_label": "Включить историю просмотров ",
+ "preferences_watch_history_label": "Включить историю просмотров: ",
"search_filters_title": "Фильтр",
"search_filters_duration_option_none": "Любой длины",
"search_filters_type_option_all": "Любого типа",
- "search_filters_date_option_none": "Любой даты",
+ "search_filters_date_option_none": "Любая дата",
"search_filters_date_label": "Дата загрузки",
"search_message_no_results": "Ничего не найдено.",
"search_message_use_another_instance": " Дополнительно вы можете <a href=\"`x`\">поискать на других зеркалах</a>.",
"search_filters_features_option_vr180": "VR180",
- "search_message_change_filters_or_query": "Попробуйте расширить поисковый запрос и изменить фильтры.",
+ "search_message_change_filters_or_query": "Попробуйте расширить поисковый запрос или изменить фильтры.",
"search_filters_duration_option_medium": "Средние (4 - 20 минут)",
- "search_filters_apply_button": "Применить фильтры"
+ "search_filters_apply_button": "Применить фильтры",
+ "Popular enabled: ": "Популярное включено: "
}
diff --git a/locales/sl.json b/locales/sl.json
index 791a01c5..288f8da5 100644
--- a/locales/sl.json
+++ b/locales/sl.json
@@ -80,7 +80,7 @@
"preferences_category_admin": "Skrbniške nastavitve",
"preferences_default_home_label": "Privzeta domača stran: ",
"preferences_feed_menu_label": "Meni vira: ",
- "Top enabled: ": "Vrh je omogočen: ",
+ "Top enabled: ": "Vrh omogočen: ",
"CAPTCHA enabled: ": "CAPTCHA omogočeni: ",
"Login enabled: ": "Prijava je omogočena: ",
"Registration enabled: ": "Registracija je omogočena: ",
@@ -112,7 +112,7 @@
"Wilson score: ": "Wilsonov rezultat: ",
"Engagement: ": "Sodelovanje: ",
"Blacklisted regions: ": "Regije na seznamu nedovoljenih: ",
- "Shared `x`": "V skupni rabi `x`",
+ "Shared `x`": "V skupni rabi od: `x`",
"Premieres `x`": "Premiere `x`",
"View YouTube comments": "Oglej si YouTube komentarje",
"View more comments on Reddit": "Prikaži več komentarjev na Reddit",
@@ -201,22 +201,22 @@
"Yiddish": "jidiš",
"Yoruba": "joruba",
"Xhosa": "xhosa",
- "generic_count_years_0": "{{count}} leto",
+ "generic_count_years_0": "{{count}} letom",
"generic_count_years_1": "{{count}} leti",
- "generic_count_years_2": "{{count}} leta",
- "generic_count_years_3": "{{count}} let",
- "generic_count_days_0": "{{count}} dan",
- "generic_count_days_1": "{{count}} dneva",
- "generic_count_days_2": "{{count}} dni",
- "generic_count_days_3": "{{count}} dni",
- "generic_count_hours_0": "{{count}} ura",
- "generic_count_hours_1": "{{count}} uri",
- "generic_count_hours_2": "{{count}} ure",
- "generic_count_hours_3": "{{count}} ur",
- "generic_count_minutes_0": "{{count}} minuta",
- "generic_count_minutes_1": "{{count}} minuti",
- "generic_count_minutes_2": "{{count}} minute",
- "generic_count_minutes_3": "{{count}} minut",
+ "generic_count_years_2": "{{count}} leti",
+ "generic_count_years_3": "{{count}} leti",
+ "generic_count_days_0": "{{count}} dnevom",
+ "generic_count_days_1": "{{count}} dnevi",
+ "generic_count_days_2": "{{count}} dnevi",
+ "generic_count_days_3": "{{count}} dnevi",
+ "generic_count_hours_0": "{{count}} uro",
+ "generic_count_hours_1": "{{count}} urami",
+ "generic_count_hours_2": "{{count}} urami",
+ "generic_count_hours_3": "{{count}} urami",
+ "generic_count_minutes_0": "{{count}} minuto",
+ "generic_count_minutes_1": "{{count}} minutami",
+ "generic_count_minutes_2": "{{count}} minutami",
+ "generic_count_minutes_3": "{{count}} minutami",
"Search": "Iskanje",
"Top": "Vrh",
"About": "O aplikaciji",
@@ -423,23 +423,23 @@
"Spanish (Spain)": "španščina (Španija)",
"Tajik": "tadžiščina",
"Tamil": "tamilščina",
- "generic_count_weeks_0": "{{count}} teden",
- "generic_count_weeks_1": "{{count}} tedna",
- "generic_count_weeks_2": "{{count}} tedne",
- "generic_count_weeks_3": "{{count}} tednov",
+ "generic_count_weeks_0": "{{count}} tednom",
+ "generic_count_weeks_1": "{{count}} tedni",
+ "generic_count_weeks_2": "{{count}} tedni",
+ "generic_count_weeks_3": "{{count}} tedni",
"Swahili": "svahilščina",
"Swedish": "švedščina",
"Vietnamese (auto-generated)": "vietnamščina (samodejno ustvarjeno)",
- "generic_count_months_0": "{{count}} mesec",
- "generic_count_months_1": "{{count}} meseca",
- "generic_count_months_2": "{{count}} mesece",
- "generic_count_months_3": "{{count}} mesecev",
+ "generic_count_months_0": "{{count}} mesecem",
+ "generic_count_months_1": "{{count}} meseci",
+ "generic_count_months_2": "{{count}} meseci",
+ "generic_count_months_3": "{{count}} meseci",
"Uzbek": "uzbeščina",
"Zulu": "zulujščina",
- "generic_count_seconds_0": "{{count}} sekunda",
- "generic_count_seconds_1": "{{count}} sekundi",
- "generic_count_seconds_2": "{{count}} sekunde",
- "generic_count_seconds_3": "{{count}} sekund",
+ "generic_count_seconds_0": "{{count}} sekundo",
+ "generic_count_seconds_1": "{{count}} sekundami",
+ "generic_count_seconds_2": "{{count}} sekundami",
+ "generic_count_seconds_3": "{{count}} sekundami",
"Popular": "Priljubljeni",
"Music": "Glasba",
"Movies": "Filmi",
@@ -502,5 +502,6 @@
"crash_page_refresh": "poskušal/a <a href=\"`x`\">osvežiti stran</a>",
"crash_page_before_reporting": "Preden prijaviš napako, se prepričaj, da si:",
"crash_page_search_issue": "preiskal/a <a href=\"`x`\">obstoječe težave na GitHubu</a>",
- "crash_page_report_issue": "Če nič od navedenega ni pomagalo, prosim <a href=\"`x`\">odpri novo težavo v GitHubu</a> (po možnosti v angleščini) in v svoje sporočilo vključi naslednje besedilo (tega besedila NE prevajaj):"
+ "crash_page_report_issue": "Če nič od navedenega ni pomagalo, prosim <a href=\"`x`\">odpri novo težavo v GitHubu</a> (po možnosti v angleščini) in v svoje sporočilo vključi naslednje besedilo (tega besedila NE prevajaj):",
+ "Popular enabled: ": "Priljubljeni omogočeni: "
}
diff --git a/locales/tr.json b/locales/tr.json
index b1991c35..bd499746 100644
--- a/locales/tr.json
+++ b/locales/tr.json
@@ -470,5 +470,6 @@
"search_filters_duration_option_medium": "Orta (4 - 20 dakika)",
"search_filters_features_option_vr180": "VR180",
"search_filters_title": "Filtreler",
- "search_message_change_filters_or_query": "Arama sorgunuzu genişletmeyi ve/veya filtreleri değiştirmeyi deneyin."
+ "search_message_change_filters_or_query": "Arama sorgunuzu genişletmeyi ve/veya filtreleri değiştirmeyi deneyin.",
+ "Popular enabled: ": "Popüler etkin: "
}
diff --git a/locales/uk.json b/locales/uk.json
index dd03d559..0cc14579 100644
--- a/locales/uk.json
+++ b/locales/uk.json
@@ -1,6 +1,6 @@
{
- "LIVE": "ПРЯМИЙ ЕФІР",
- "Shared `x` ago": "Розміщено `x` назад",
+ "LIVE": "НАЖИВО",
+ "Shared `x` ago": "Розміщено `x` тому",
"Unsubscribe": "Відписатися",
"Subscribe": "Підписатися",
"View channel on YouTube": "Подивитися канал на YouTube",
@@ -30,7 +30,7 @@
"Export subscriptions as OPML": "Експортувати підписки у форматі OPML",
"Export subscriptions as OPML (for NewPipe & FreeTube)": "Експортувати підписки у форматі OPML (для NewPipe та FreeTube)",
"Export data as JSON": "Експортувати дані Invidious у форматі JSON",
- "Delete account?": "Видалити обліківку?",
+ "Delete account?": "Видалити обліковий запис?",
"History": "Історія",
"An alternative front-end to YouTube": "Альтернативний фронтенд до YouTube",
"JavaScript license information": "Інформація щодо ліцензій JavaScript",
@@ -40,9 +40,9 @@
"Log in with Google": "Увійти через Google",
"User ID": "ID користувача",
"Password": "Пароль",
- "Time (h:mm:ss):": "Час (г:мм:сс):",
- "Text CAPTCHA": "Текст капчі",
- "Image CAPTCHA": "Зображення капчі",
+ "Time (h:mm:ss):": "Час (г:хх:сс):",
+ "Text CAPTCHA": "Текст CAPTCHA",
+ "Image CAPTCHA": "Зображення CAPTCHA",
"Sign In": "Увійти",
"Register": "Зареєструватися",
"E-mail": "Електронна пошта",
@@ -142,7 +142,7 @@
"Whitelisted regions: ": "Доступно у регіонах: ",
"Blacklisted regions: ": "Недоступно у регіонах: ",
"Shared `x`": "Розміщено `x`",
- "Premieres in `x`": "Прем’єра через `x`",
+ "Premieres in `x`": "Прем’єра за `x`",
"Premieres `x`": "Прем’єра `x`",
"Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Схоже, у вас відключений JavaScript. Щоб побачити коментарі, натисніть сюда, але майте на увазі, що вони можуть завантажуватися трохи довше.",
"View YouTube comments": "Переглянути коментарі з YouTube",
@@ -157,11 +157,11 @@
"Incorrect password": "Неправильний пароль",
"Quota exceeded, try again in a few hours": "Ліміт перевищено, спробуйте знову за декілька годин",
"Unable to log in, make sure two-factor authentication (Authenticator or SMS) is turned on.": "Не вдається увійти. Перевірте, чи не ввімкнена двофакторна аутентифікація (за кодом чи смс).",
- "Invalid TFA code": "Неправильний код двофакторної аутентифікації",
+ "Invalid TFA code": "Неправильний код двофакторної автентифікації",
"Login failed. This may be because two-factor authentication is not turned on for your account.": "Не вдається увійти. Це може бути через те, що у вашій обліківці не ввімкнена двофакторна аутентифікація.",
"Wrong answer": "Неправильна відповідь",
"Erroneous CAPTCHA": "Неправильна капча",
- "CAPTCHA is a required field": "Необхідно пройти капчу",
+ "CAPTCHA is a required field": "Необхідно пройти CAPTCHA",
"User ID is a required field": "Необхідно ввести ID користувача",
"Password is a required field": "Необхідно ввести пароль",
"Wrong username or password": "Неправильний логін чи пароль",
@@ -169,7 +169,7 @@
"Password cannot be empty": "Пароль не може бути порожнім",
"Password cannot be longer than 55 characters": "Пароль не може бути довшим за 55 знаків",
"Please log in": "Будь ласка, увійдіть",
- "Invidious Private Feed for `x`": "Приватний поток відео Invidious для `x`",
+ "Invidious Private Feed for `x`": "Приватний потік відео Invidious для `x`",
"channel:`x`": "канал: `x`",
"Deleted or invalid channel": "Канал видалено або не знайдено",
"This channel does not exist.": "Такого каналу не існує.",
@@ -486,5 +486,6 @@
"search_filters_features_option_purchased": "Придбано",
"search_filters_sort_option_relevance": "Відповідні",
"search_filters_sort_option_rating": "Рейтингові",
- "search_filters_sort_option_views": "Популярні"
+ "search_filters_sort_option_views": "Популярні",
+ "Popular enabled: ": "Популярне ввімкнено: "
}
diff --git a/locales/zh-CN.json b/locales/zh-CN.json
index ed180628..ff48e101 100644
--- a/locales/zh-CN.json
+++ b/locales/zh-CN.json
@@ -454,5 +454,6 @@
"search_message_change_filters_or_query": "尝试扩大你的搜索查询和/或更改过滤器。",
"search_filters_duration_option_none": "任意时长",
"search_filters_type_option_all": "任意类型",
- "search_filters_features_option_vr180": "VR180"
+ "search_filters_features_option_vr180": "VR180",
+ "Popular enabled: ": "已启用流行度: "
}
diff --git a/locales/zh-TW.json b/locales/zh-TW.json
index 4b6fa71b..90614e48 100644
--- a/locales/zh-TW.json
+++ b/locales/zh-TW.json
@@ -454,5 +454,6 @@
"search_filters_title": "過濾條件",
"search_filters_date_label": "上傳日期",
"search_filters_type_option_all": "任何類型",
- "search_filters_date_option_none": "任何日期"
+ "search_filters_date_option_none": "任何日期",
+ "Popular enabled: ": "已啟用人氣: "
}
diff --git a/mocks b/mocks
new file mode 160000
+Subproject 020337194dd482c47ee2d53cd111d0ebf2831e5
diff --git a/scripts/deploy-database.sh b/scripts/deploy-database.sh
new file mode 100644
index 00000000..fa24b8f0
--- /dev/null
+++ b/scripts/deploy-database.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+#
+# Parameters
+#
+
+interactive=true
+
+if [ "$1" = "--no-interactive" ]; then
+ interactive=false
+fi
+
+#
+# Enable and start Postgres
+#
+
+sudo systemctl start postgresql.service
+sudo systemctl enable postgresql.service
+
+#
+# Create databse and user
+#
+
+if [ "$interactive" = "true" ]; then
+ sudo -u postgres -- createuser -P kemal
+ sudo -u postgres -- createdb -O kemal invidious
+else
+ # Generate a DB password
+ if [ -z "$POSTGRES_PASS" ]; then
+ echo "Generating database password"
+ POSTGRES_PASS=$(tr -dc 'A-Za-z0-9.;!?{[()]}\\/' < /dev/urandom | head -c16)
+ fi
+
+ # hostname:port:database:username:password
+ echo "Writing .pgpass"
+ echo "127.0.0.1:*:invidious:kemal:${POSTGRES_PASS}" > "$HOME/.pgpass"
+
+ sudo -u postgres -- psql -c "CREATE USER kemal WITH PASSWORD '$POSTGRES_PASS';"
+ sudo -u postgres -- psql -c "CREATE DATABASE invidious WITH OWNER kemal;"
+ sudo -u postgres -- psql -c "GRANT ALL ON DATABASE invidious TO kemal;"
+fi
+
+
+#
+# Instructions for modification of pg_hba.conf
+#
+
+if [ "$interactive" = "true" ]; then
+ echo
+ echo "-------------"
+ echo " NOTICE "
+ echo "-------------"
+ echo
+ echo "Make sure that your postgreSQL's pg_hba.conf file contains the follwong"
+ echo "lines before previous 'host' configurations:"
+ echo
+ echo "host invidious kemal 127.0.0.1/32 md5"
+ echo "host invidious kemal ::1/128 md5"
+ echo
+fi
diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh
new file mode 100644
index 00000000..1e67bdaf
--- /dev/null
+++ b/scripts/install-dependencies.sh
@@ -0,0 +1,174 @@
+#!/bin/sh
+#
+# Script that installs the various dependencies of invidious
+#
+# Dependencies:
+# - crystal => Language in which Invidious is developed
+# - postgres => Database server
+# - git => required to clone Invidious
+# - librsvg2-bin => For login captcha (provides 'rsvg-convert')
+#
+# - libssl-dev => Used by Crystal's SSL module (standard library)
+# - libxml2-dev => Used by Crystal's XML module (standard library)
+# - libyaml-dev => Used by Crystal's YAML module (standard library)
+# - libgmp-dev => Used by Crystal's BigNumbers module (standard library)
+# - libevent-dev => Used by crystal's internal scheduler (?)
+# - libpcre3-dev => Used by Crystal's regex engine (?)
+#
+# - libsqlite3-dev => Used to open .db files from NewPipe exports
+# - zlib1g-dev => TBD
+# - libreadline-dev => TBD
+#
+#
+# Tested on:
+# - OpenSUSE Leap 15.3
+
+#
+# Load system details
+#
+
+if [ -e /etc/os-release ]; then
+ . /etc/os-release
+elif [ -e /usr/lib/os-release ]; then
+ . /usr/lib/os-release
+else
+ echo "Unsupported Linux system"
+ exit 2
+fi
+
+#
+# Some variables
+#
+
+repo_base_url="https://download.opensuse.org/repositories/devel:/languages:/crystal/"
+repo_end_url="devel:languages:crystal.repo"
+
+apt_gpg_key="/usr/share/keyrings/crystal.gpg"
+apt_list_file="/etc/apt/sources.list.d/crystal.list"
+
+yum_repo_file="/etc/yum.repos.d/crystal.repo"
+
+#
+# Major install functions
+#
+
+make_repo_url() {
+ echo "${repo_base_url}/${1}/${repo_end_url}"
+}
+
+
+install_apt() {
+ repo="$1"
+
+ echo "Adding Crystal repository"
+
+ curl -fsSL "${repo_base_url}/${repo}/Release.key" \
+ | gpg --dearmor \
+ | sudo tee "${apt_gpg_key}" > /dev/null
+
+ echo "deb [signed-by=${apt_gpg_key}] ${repo_base_url}/${repo}/ /" \
+ | sudo tee "$apt_list_file"
+
+ sudo apt-get update
+
+ sudo apt-get install --yes --no-install-recommends \
+ libssl-dev libxml2-dev libyaml-dev libgmp-dev libevent-dev \
+ libpcre3-dev libreadline-dev libsqlite3-dev zlib1g-dev \
+ crystal postgresql-13 git librsvg2-bin make
+}
+
+install_yum() {
+ repo=$(make_repo_url "$1")
+
+ echo "Adding Crystal repository"
+
+ cat << END | sudo tee "${yum_repo_file}" > /dev/null
+[crystal]
+name=Crystal
+type=rpm-md
+baseurl=${repo}/
+gpgcheck=1
+gpgkey=${repo}/repodata/repomd.xml.key
+enabled=1
+END
+
+ sudo yum -y install \
+ openssl-devel libxml2-devel libyaml-devel gmp-devel \
+ readline-devel sqlite-devel \
+ crystal postgresql postgresql-server git librsvg2-tools make
+}
+
+install_pacman() {
+ # TODO: find an alternative to --no-confirm?
+ sudo pacman -S --no-confirm \
+ base-devel librsvg postgresql crystal
+}
+
+install_zypper()
+{
+ repo=$(make_repo_url "$1")
+
+ echo "Adding Crystal repository"
+ sudo zypper --non-interactive addrepo -f "$repo"
+
+ sudo zypper --non-interactive --gpg-auto-import-keys install --no-recommends \
+ libopenssl-devel libxml2-devel libyaml-devel gmp-devel libevent-devel \
+ pcre-devel readline-devel sqlite3-devel zlib-devel \
+ crystal postgresql postgresql-server git rsvg-convert make
+}
+
+
+#
+# System-specific logic
+#
+
+case "$ID" in
+ archlinux) install_pacman;;
+
+ centos) install_dnf "CentOS_${VERSION_ID}";;
+
+ debian)
+ case "$VERSION_CODENAME" in
+ sid) install_apt "Debian_Unstable";;
+ bookworm) install_apt "Debian_Testing";;
+ *) install_apt "Debian_${VERSION_ID}";;
+ esac
+ ;;
+
+ fedora)
+ if [ "$VERSION" == *"Prerelease"* ]; then
+ install_dnf "Fedora_Rawhide"
+ else
+ install_dnf "Fedora_${VERSION}"
+ fi
+ ;;
+
+ opensuse-leap) install_zypper "openSUSE_Leap_${VERSION}";;
+
+ opensuse-tumbleweed) install_zypper "openSUSE_Tumbleweed";;
+
+ rhel) install_dnf "RHEL_${VERSION_ID}";;
+
+ ubuntu)
+ # Small workaround for recently released 22.04
+ case "$VERSION_ID" in
+ 22.04) install_apt "xUbuntu_21.04";;
+ *) install_apt "xUbuntu_${VERSION_ID}";;
+ esac
+ ;;
+
+ *)
+ # Try to match on ID_LIKE instead
+ # Not guaranteed to 100% work
+ case "$ID_LIKE" in
+ archlinux) install_pacman;;
+ centos) install_dnf "CentOS_${VERSION_ID}";;
+ debian) install_apt "Debian_${VERSION_ID}";;
+ *)
+ echo "Error: distribution ${CODENAME} is not supported"
+ echo "Please install dependencies manually"
+ exit 2
+ ;;
+ esac
+ ;;
+esac
diff --git a/spec/invidious/hashtag_spec.cr b/spec/invidious/hashtag_spec.cr
new file mode 100644
index 00000000..77676878
--- /dev/null
+++ b/spec/invidious/hashtag_spec.cr
@@ -0,0 +1,109 @@
+require "../parsers_helper.cr"
+
+Spectator.describe Invidious::Hashtag do
+ it "parses richItemRenderer containers (test 1)" do
+ # Enable mock
+ test_content = load_mock("hashtag/martingarrix_page1")
+ videos = extract_items(test_content)
+
+ expect(typeof(videos)).to eq(Array(SearchItem))
+ expect(videos.size).to eq(60)
+
+ #
+ # Random video check 1
+ #
+ expect(typeof(videos[11])).to eq(SearchItem)
+
+ video_11 = videos[11].as(SearchVideo)
+
+ expect(video_11.id).to eq("06eSsOWcKYA")
+ expect(video_11.title).to eq("Martin Garrix - Live @ Tomorrowland 2018")
+
+ expect(video_11.ucid).to eq("UC5H_KXkPbEsGs0tFt8R35mA")
+ expect(video_11.author).to eq("Martin Garrix")
+ expect(video_11.author_verified).to be_true
+
+ expect(video_11.published).to be_close(Time.utc - 3.years, 1.second)
+ expect(video_11.length_seconds).to eq((56.minutes + 41.seconds).total_seconds.to_i32)
+ expect(video_11.views).to eq(40_504_893)
+
+ expect(video_11.live_now).to be_false
+ expect(video_11.premium).to be_false
+ expect(video_11.premiere_timestamp).to be_nil
+
+ #
+ # Random video check 2
+ #
+ expect(typeof(videos[35])).to eq(SearchItem)
+
+ video_35 = videos[35].as(SearchVideo)
+
+ expect(video_35.id).to eq("b9HpOAYjY9I")
+ expect(video_35.title).to eq("Martin Garrix feat. Mike Yung - Dreamer (Official Video)")
+
+ expect(video_35.ucid).to eq("UC5H_KXkPbEsGs0tFt8R35mA")
+ expect(video_35.author).to eq("Martin Garrix")
+ expect(video_35.author_verified).to be_true
+
+ expect(video_35.published).to be_close(Time.utc - 3.years, 1.second)
+ expect(video_35.length_seconds).to eq((3.minutes + 14.seconds).total_seconds.to_i32)
+ expect(video_35.views).to eq(30_790_049)
+
+ expect(video_35.live_now).to be_false
+ expect(video_35.premium).to be_false
+ expect(video_35.premiere_timestamp).to be_nil
+ end
+
+ it "parses richItemRenderer containers (test 2)" do
+ # Enable mock
+ test_content = load_mock("hashtag/martingarrix_page2")
+ videos = extract_items(test_content)
+
+ expect(typeof(videos)).to eq(Array(SearchItem))
+ expect(videos.size).to eq(60)
+
+ #
+ # Random video check 1
+ #
+ expect(typeof(videos[41])).to eq(SearchItem)
+
+ video_41 = videos[41].as(SearchVideo)
+
+ expect(video_41.id).to eq("qhstH17zAjs")
+ expect(video_41.title).to eq("Martin Garrix Radio - Episode 391")
+
+ expect(video_41.ucid).to eq("UC5H_KXkPbEsGs0tFt8R35mA")
+ expect(video_41.author).to eq("Martin Garrix")
+ expect(video_41.author_verified).to be_true
+
+ expect(video_41.published).to be_close(Time.utc - 2.months, 1.second)
+ expect(video_41.length_seconds).to eq((1.hour).total_seconds.to_i32)
+ expect(video_41.views).to eq(63_240)
+
+ expect(video_41.live_now).to be_false
+ expect(video_41.premium).to be_false
+ expect(video_41.premiere_timestamp).to be_nil
+
+ #
+ # Random video check 2
+ #
+ expect(typeof(videos[48])).to eq(SearchItem)
+
+ video_48 = videos[48].as(SearchVideo)
+
+ expect(video_48.id).to eq("lqGvW0NIfdc")
+ expect(video_48.title).to eq("Martin Garrix SENTIO Full Album Mix by Sakul")
+
+ expect(video_48.ucid).to eq("UC3833PXeLTS6yRpwGMQpp4Q")
+ expect(video_48.author).to eq("SAKUL")
+ expect(video_48.author_verified).to be_false
+
+ expect(video_48.published).to be_close(Time.utc - 3.weeks, 1.second)
+ expect(video_48.length_seconds).to eq((35.minutes + 46.seconds).total_seconds.to_i32)
+ expect(video_48.views).to eq(68_704)
+
+ expect(video_48.live_now).to be_false
+ expect(video_48.premium).to be_false
+ expect(video_48.premiere_timestamp).to be_nil
+ end
+end
diff --git a/spec/invidious/search/query_spec.cr b/spec/invidious/search/query_spec.cr
index 4853e9e9..063b69f1 100644
--- a/spec/invidious/search/query_spec.cr
+++ b/spec/invidious/search/query_spec.cr
@@ -197,4 +197,46 @@ Spectator.describe Invidious::Search::Query do
)
end
end
+
+ describe "#to_http_params" do
+ it "formats regular search" do
+ query = described_class.new(
+ HTTP::Params.parse("q=The+Simpsons+hiding+in+bush&duration=short"),
+ Invidious::Search::Query::Type::Regular, nil
+ )
+
+ params = query.to_http_params
+
+ expect(params).to have_key("duration")
+ expect(params["duration"]?).to eq("short")
+
+ expect(params).to have_key("q")
+ expect(params["q"]?).to eq("The Simpsons hiding in bush")
+
+ # Check if there aren't other parameters
+ params.delete("duration")
+ params.delete("q")
+ expect(params).to be_empty
+ end
+
+ it "formats channel search" do
+ query = described_class.new(
+ HTTP::Params.parse("q=channel:UC2DjFE7Xf11URZqWBigcVOQ%20multimeter"),
+ Invidious::Search::Query::Type::Regular, nil
+ )
+
+ params = query.to_http_params
+
+ expect(params).to have_key("channel")
+ expect(params["channel"]?).to eq("UC2DjFE7Xf11URZqWBigcVOQ")
+
+ expect(params).to have_key("q")
+ expect(params["q"]?).to eq("multimeter")
+
+ # Check if there aren't other parameters
+ params.delete("channel")
+ params.delete("q")
+ expect(params).to be_empty
+ end
+ end
end
diff --git a/spec/parsers_helper.cr b/spec/parsers_helper.cr
new file mode 100644
index 00000000..6155fe33
--- /dev/null
+++ b/spec/parsers_helper.cr
@@ -0,0 +1,33 @@
+require "db"
+require "json"
+require "kemal"
+
+require "protodec/utils"
+
+require "spectator"
+
+require "../src/invidious/helpers/macros"
+require "../src/invidious/helpers/logger"
+require "../src/invidious/helpers/utils"
+
+require "../src/invidious/videos"
+require "../src/invidious/comments"
+
+require "../src/invidious/helpers/serialized_yt_data"
+require "../src/invidious/yt_backend/extractors"
+require "../src/invidious/yt_backend/extractors_utils"
+
+OUTPUT = File.open(File::NULL, "w")
+LOGGER = Invidious::LogHandler.new(OUTPUT, LogLevel::Off)
+
+def load_mock(file) : Hash(String, JSON::Any)
+ file = File.join(__DIR__, "..", "mocks", file + ".json")
+ content = File.read(file)
+
+ return JSON.parse(content).as_h
+end
+
+Spectator.configure do |config|
+ config.fail_blank
+ config.randomize
+end
diff --git a/src/invidious.cr b/src/invidious.cr
index dd240852..070b4d18 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -133,12 +133,13 @@ Invidious::Database.check_integrity(CONFIG)
# Running the script by itself would show some colorful feedback while this doesn't.
# Perhaps we should just move the script to runtime in order to get that feedback?
- {% puts "\nChecking player dependencies...\n" %}
+ {% puts "\nChecking player dependencies, this may take more than 20 minutes... If it is stuck, check your internet connection.\n" %}
{% if flag?(:minified_player_dependencies) %}
{% puts run("../scripts/fetch-player-dependencies.cr", "--minified").stringify %}
{% else %}
{% puts run("../scripts/fetch-player-dependencies.cr").stringify %}
{% end %}
+ {% puts "\nDone checking player dependencies, now compiling Invidious...\n" %}
{% end %}
# Start jobs
@@ -385,6 +386,7 @@ end
Invidious::Routing.get "/opensearch.xml", Invidious::Routes::Search, :opensearch
Invidious::Routing.get "/results", Invidious::Routes::Search, :results
Invidious::Routing.get "/search", Invidious::Routes::Search, :search
+ Invidious::Routing.get "/hashtag/:hashtag", Invidious::Routes::Search, :hashtag
# User routes
define_user_routes()
diff --git a/src/invidious/channels/about.cr b/src/invidious/channels/about.cr
index da71e9a8..f60ee7af 100644
--- a/src/invidious/channels/about.cr
+++ b/src/invidious/channels/about.cr
@@ -31,7 +31,12 @@ def get_about_info(ucid, locale) : AboutChannel
end
if initdata.dig?("alerts", 0, "alertRenderer", "type") == "ERROR"
- raise InfoException.new(initdata["alerts"][0]["alertRenderer"]["text"]["simpleText"].as_s)
+ error_message = initdata["alerts"][0]["alertRenderer"]["text"]["simpleText"].as_s
+ if error_message == "This channel does not exist."
+ raise NotFoundException.new(error_message)
+ else
+ raise InfoException.new(error_message)
+ end
end
if browse_endpoint = initdata["onResponseReceivedActions"]?.try &.[0]?.try &.["navigateAction"]?.try &.["endpoint"]?.try &.["browseEndpoint"]?
@@ -54,13 +59,11 @@ def get_about_info(ucid, locale) : AboutChannel
banner = banners.try &.[-1]?.try &.["url"].as_s?
description_node = initdata["header"]["interactiveTabbedHeaderRenderer"]["description"]
-
- is_family_friendly = initdata["microformat"]["microformatDataRenderer"]["familySafe"].as_bool
- allowed_regions = initdata["microformat"]["microformatDataRenderer"]["availableCountries"].as_a.map(&.as_s)
else
author = initdata["metadata"]["channelMetadataRenderer"]["title"].as_s
author_url = initdata["metadata"]["channelMetadataRenderer"]["channelUrl"].as_s
author_thumbnail = initdata["metadata"]["channelMetadataRenderer"]["avatar"]["thumbnails"][0]["url"].as_s
+ author_verified = has_verified_badge?(initdata.dig?("header", "c4TabbedHeaderRenderer", "badges"))
ucid = initdata["metadata"]["channelMetadataRenderer"]["externalId"].as_s
@@ -71,18 +74,19 @@ def get_about_info(ucid, locale) : AboutChannel
# if banner.includes? "channels/c4/default_banner"
# banner = nil
# end
- # author_verified_badges = initdata["header"]?.try &.["c4TabbedHeaderRenderer"]?.try &.["badges"]?
- author_verified_badge = initdata["header"].dig?("c4TabbedHeaderRenderer", "badges", 0, "metadataBadgeRenderer", "tooltip")
- author_verified = (author_verified_badge && author_verified_badge == "Verified")
description_node = initdata["metadata"]["channelMetadataRenderer"]?.try &.["description"]?
-
- is_family_friendly = initdata["microformat"]["microformatDataRenderer"]["familySafe"].as_bool
- allowed_regions = initdata["microformat"]["microformatDataRenderer"]["availableCountries"].as_a.map(&.as_s)
end
+ is_family_friendly = initdata["microformat"]["microformatDataRenderer"]["familySafe"].as_bool
+
+ allowed_regions = initdata
+ .dig?("microformat", "microformatDataRenderer", "availableCountries")
+ .try &.as_a.map(&.as_s) || [] of String
+
description = !description_node.nil? ? description_node.as_s : ""
description_html = HTML.escape(description)
+
if !description_node.nil?
if description_node.as_h?.nil?
description_node = text_to_parsed_content(description_node.as_s)
diff --git a/src/invidious/channels/community.cr b/src/invidious/channels/community.cr
index 4701ecbd..2a2c74aa 100644
--- a/src/invidious/channels/community.cr
+++ b/src/invidious/channels/community.cr
@@ -6,20 +6,18 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
end
if response.status_code != 200
- raise InfoException.new("This channel does not exist.")
+ raise NotFoundException.new("This channel does not exist.")
end
ucid = response.body.match(/https:\/\/www.youtube.com\/channel\/(?<ucid>UC[a-zA-Z0-9_-]{22})/).not_nil!["ucid"]
if !continuation || continuation.empty?
initial_data = extract_initial_data(response.body)
- body = initial_data["contents"]?.try &.["twoColumnBrowseResultsRenderer"]["tabs"].as_a.select { |tab| tab["tabRenderer"]?.try &.["selected"].as_bool.== true }[0]?
+ body = extract_selected_tab(initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"])["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]
if !body
raise InfoException.new("Could not extract community tab.")
end
-
- body = body["tabRenderer"]["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]
else
continuation = produce_channel_community_continuation(ucid, continuation)
@@ -49,7 +47,11 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
error_message = (message["text"]["simpleText"]? ||
message["text"]["runs"]?.try &.[0]?.try &.["text"]?)
.try &.as_s || ""
- raise InfoException.new(error_message)
+ if error_message == "This channel does not exist."
+ raise NotFoundException.new(error_message)
+ else
+ raise InfoException.new(error_message)
+ end
end
response = JSON.build do |json|
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index d8496978..5112ad3d 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -95,7 +95,7 @@ def fetch_youtube_comments(id, cursor, format, locale, thin_mode, region, sort_b
contents = body["contents"]?
header = body["header"]?
else
- raise InfoException.new("Could not fetch comments")
+ raise NotFoundException.new("Comments not found.")
end
if !contents
@@ -290,7 +290,7 @@ def fetch_reddit_comments(id, sort_by = "confidence")
thread = result[0].data.as(RedditListing).children[0].data.as(RedditLink)
else
- raise InfoException.new("Could not fetch comments")
+ raise NotFoundException.new("Comments not found.")
end
client.close
@@ -481,7 +481,7 @@ def template_reddit_comments(root, locale)
html << <<-END_HTML
<p>
- <a href="javascript:void(0)" data-onclick="toggle_parent">[ - ]</a>
+ <a href="javascript:void(0)" data-onclick="toggle_parent">[ − ]</a>
<b><a href="https://www.reddit.com/user/#{child.author}">#{child.author}</a></b>
#{translate_count(locale, "comments_points_count", child.score, NumberFormatting::Separator)}
<span title="#{child.created_utc.to_s(translate(locale, "%a %B %-d %T %Y UTC"))}">#{translate(locale, "`x` ago", recode_date(child.created_utc, locale))}</span>
@@ -500,6 +500,12 @@ def template_reddit_comments(root, locale)
end
def replace_links(html)
+ # Check if the document is empty
+ # Prevents edge-case bug with Reddit comments, see issue #3115
+ if html.nil? || html.empty?
+ return html
+ end
+
html = XML.parse_html(html)
html.xpath_nodes(%q(//a)).each do |anchor|
@@ -541,6 +547,12 @@ def replace_links(html)
end
def fill_links(html, scheme, host)
+ # Check if the document is empty
+ # Prevents edge-case bug with Reddit comments, see issue #3115
+ if html.nil? || html.empty?
+ return html
+ end
+
html = XML.parse_html(html)
html.xpath_nodes("//a").each do |match|
diff --git a/src/invidious/exceptions.cr b/src/invidious/exceptions.cr
index bfaa3fd5..471a199a 100644
--- a/src/invidious/exceptions.cr
+++ b/src/invidious/exceptions.cr
@@ -18,3 +18,7 @@ class BrokenTubeException < Exception
return "Missing JSON element \"#{@element}\""
end
end
+
+# Exception threw when an element is not found.
+class NotFoundException < InfoException
+end
diff --git a/src/invidious/hashtag.cr b/src/invidious/hashtag.cr
new file mode 100644
index 00000000..afe31a36
--- /dev/null
+++ b/src/invidious/hashtag.cr
@@ -0,0 +1,44 @@
+module Invidious::Hashtag
+ extend self
+
+ def fetch(hashtag : String, page : Int, region : String? = nil) : Array(SearchItem)
+ cursor = (page - 1) * 60
+ ctoken = generate_continuation(hashtag, cursor)
+
+ client_config = YoutubeAPI::ClientConfig.new(region: region)
+ response = YoutubeAPI.browse(continuation: ctoken, client_config: client_config)
+
+ return extract_items(response)
+ end
+
+ def generate_continuation(hashtag : String, cursor : Int)
+ object = {
+ "80226972:embedded" => {
+ "2:string" => "FEhashtag",
+ "3:base64" => {
+ "1:varint" => cursor.to_i64,
+ },
+ "7:base64" => {
+ "325477796:embedded" => {
+ "1:embedded" => {
+ "2:0:embedded" => {
+ "2:string" => '#' + hashtag,
+ "4:varint" => 0_i64,
+ "11:string" => "",
+ },
+ "4:string" => "browse-feedFEhashtag",
+ },
+ "2:string" => hashtag,
+ },
+ },
+ },
+ }
+
+ continuation = object.try { |i| Protodec::Any.cast_json(i) }
+ .try { |i| Protodec::Any.from_json(i) }
+ .try { |i| Base64.urlsafe_encode(i) }
+ .try { |i| URI.encode_www_form(i) }
+
+ return continuation
+ end
+end
diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr
index aefa34cc..c4eb7507 100644
--- a/src/invidious/playlists.cr
+++ b/src/invidious/playlists.cr
@@ -317,7 +317,7 @@ def get_playlist(plid : String)
if playlist = Invidious::Database::Playlists.select(id: plid)
return playlist
else
- raise InfoException.new("Playlist does not exist.")
+ raise NotFoundException.new("Playlist does not exist.")
end
else
return fetch_playlist(plid)
diff --git a/src/invidious/routes/api/manifest.cr b/src/invidious/routes/api/manifest.cr
index 8bc36946..bfb8a377 100644
--- a/src/invidious/routes/api/manifest.cr
+++ b/src/invidious/routes/api/manifest.cr
@@ -16,6 +16,8 @@ module Invidious::Routes::API::Manifest
video = get_video(id, region: region)
rescue ex : VideoRedirect
return env.redirect env.request.resource.gsub(id, ex.video_id)
+ rescue ex : NotFoundException
+ haltf env, status_code: 404
rescue ex
haltf env, status_code: 403
end
@@ -46,7 +48,7 @@ module Invidious::Routes::API::Manifest
end
end
- audio_streams = video.audio_streams
+ audio_streams = video.audio_streams.sort_by { |stream| {stream["bitrate"].as_i} }.reverse!
video_streams = video.video_streams.sort_by { |stream| {stream["width"].as_i, stream["fps"].as_i} }.reverse!
manifest = XML.build(indent: " ", encoding: "UTF-8") do |xml|
@@ -60,16 +62,22 @@ module Invidious::Routes::API::Manifest
mime_streams = audio_streams.select { |stream| stream["mimeType"].as_s.starts_with? mime_type }
next if mime_streams.empty?
- xml.element("AdaptationSet", id: i, mimeType: mime_type, startWithSAP: 1, subsegmentAlignment: true) do
- mime_streams.each do |fmt|
- # OTF streams aren't supported yet (See https://github.com/TeamNewPipe/NewPipe/issues/2415)
- next if !(fmt.has_key?("indexRange") && fmt.has_key?("initRange"))
+ mime_streams.each do |fmt|
+ # OTF streams aren't supported yet (See https://github.com/TeamNewPipe/NewPipe/issues/2415)
+ next if !(fmt.has_key?("indexRange") && fmt.has_key?("initRange"))
+ # Different representations of the same audio should be groupped into one AdaptationSet.
+ # However, most players don't support auto quality switching, so we have to trick them
+ # into providing a quality selector.
+ # See https://github.com/iv-org/invidious/issues/3074 for more details.
+ xml.element("AdaptationSet", id: i, mimeType: mime_type, startWithSAP: 1, subsegmentAlignment: true, label: fmt["bitrate"].to_s + "k") do
codecs = fmt["mimeType"].as_s.split("codecs=")[1].strip('"')
bandwidth = fmt["bitrate"].as_i
itag = fmt["itag"].as_i
url = fmt["url"].as_s
+ xml.element("Role", schemeIdUri: "urn:mpeg:dash:role:2011", value: i == 0 ? "main" : "alternate")
+
xml.element("Representation", id: fmt["itag"], codecs: codecs, bandwidth: bandwidth) do
xml.element("AudioChannelConfiguration", schemeIdUri: "urn:mpeg:dash:23003:3:audio_channel_configuration:2011",
value: "2")
@@ -79,9 +87,8 @@ module Invidious::Routes::API::Manifest
end
end
end
+ i += 1
end
-
- i += 1
end
potential_heights = {4320, 2160, 1440, 1080, 720, 480, 360, 240, 144}
diff --git a/src/invidious/routes/api/v1/authenticated.cr b/src/invidious/routes/api/v1/authenticated.cr
index b559a01a..1f5ad8ef 100644
--- a/src/invidious/routes/api/v1/authenticated.cr
+++ b/src/invidious/routes/api/v1/authenticated.cr
@@ -237,6 +237,8 @@ module Invidious::Routes::API::V1::Authenticated
begin
video = get_video(video_id)
+ rescue ex : NotFoundException
+ return error_json(404, ex)
rescue ex
return error_json(500, ex)
end
diff --git a/src/invidious/routes/api/v1/channels.cr b/src/invidious/routes/api/v1/channels.cr
index 8650976d..6b81c546 100644
--- a/src/invidious/routes/api/v1/channels.cr
+++ b/src/invidious/routes/api/v1/channels.cr
@@ -13,6 +13,8 @@ module Invidious::Routes::API::V1::Channels
rescue ex : ChannelRedirect
env.response.headers["Location"] = env.request.resource.gsub(ucid, ex.channel_id)
return error_json(302, "Channel is unavailable", {"authorId" => ex.channel_id})
+ rescue ex : NotFoundException
+ return error_json(404, ex)
rescue ex
return error_json(500, ex)
end
@@ -170,6 +172,8 @@ module Invidious::Routes::API::V1::Channels
rescue ex : ChannelRedirect
env.response.headers["Location"] = env.request.resource.gsub(ucid, ex.channel_id)
return error_json(302, "Channel is unavailable", {"authorId" => ex.channel_id})
+ rescue ex : NotFoundException
+ return error_json(404, ex)
rescue ex
return error_json(500, ex)
end
@@ -205,6 +209,8 @@ module Invidious::Routes::API::V1::Channels
rescue ex : ChannelRedirect
env.response.headers["Location"] = env.request.resource.gsub(ucid, ex.channel_id)
return error_json(302, "Channel is unavailable", {"authorId" => ex.channel_id})
+ rescue ex : NotFoundException
+ return error_json(404, ex)
rescue ex
return error_json(500, ex)
end
diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr
index a9f891f5..1b7b4fa7 100644
--- a/src/invidious/routes/api/v1/videos.cr
+++ b/src/invidious/routes/api/v1/videos.cr
@@ -12,6 +12,8 @@ module Invidious::Routes::API::V1::Videos
rescue ex : VideoRedirect
env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id)
return error_json(302, "Video is unavailable", {"videoId" => ex.video_id})
+ rescue ex : NotFoundException
+ return error_json(404, ex)
rescue ex
return error_json(500, ex)
end
@@ -42,6 +44,8 @@ module Invidious::Routes::API::V1::Videos
rescue ex : VideoRedirect
env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id)
return error_json(302, "Video is unavailable", {"videoId" => ex.video_id})
+ rescue ex : NotFoundException
+ haltf env, 404
rescue ex
haltf env, 500
end
@@ -167,6 +171,8 @@ module Invidious::Routes::API::V1::Videos
rescue ex : VideoRedirect
env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id)
return error_json(302, "Video is unavailable", {"videoId" => ex.video_id})
+ rescue ex : NotFoundException
+ haltf env, 404
rescue ex
haltf env, 500
end
@@ -324,6 +330,8 @@ module Invidious::Routes::API::V1::Videos
begin
comments = fetch_youtube_comments(id, continuation, format, locale, thin_mode, region, sort_by: sort_by)
+ rescue ex : NotFoundException
+ return error_json(404, ex)
rescue ex
return error_json(500, ex)
end
diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr
index cd2e3323..c6e02cbd 100644
--- a/src/invidious/routes/channels.cr
+++ b/src/invidious/routes/channels.cr
@@ -85,6 +85,9 @@ module Invidious::Routes::Channels
rescue ex : InfoException
env.response.status_code = 500
error_message = ex.message
+ rescue ex : NotFoundException
+ env.response.status_code = 404
+ error_message = ex.message
rescue ex
return error_template(500, ex)
end
@@ -118,7 +121,7 @@ module Invidious::Routes::Channels
resolved_url = YoutubeAPI.resolve_url("https://youtube.com#{env.request.path}#{yt_url_params.size > 0 ? "?#{yt_url_params}" : ""}")
ucid = resolved_url["endpoint"]["browseEndpoint"]["browseId"]
rescue ex : InfoException | KeyError
- raise InfoException.new(translate(locale, "This channel does not exist."))
+ return error_template(404, translate(locale, "This channel does not exist."))
end
selected_tab = env.request.path.split("/")[-1]
@@ -141,7 +144,7 @@ module Invidious::Routes::Channels
user = env.params.query["user"]?
if !user
- raise InfoException.new("This channel does not exist.")
+ return error_template(404, "This channel does not exist.")
else
env.redirect "/user/#{user}#{uri_params}"
end
@@ -197,6 +200,8 @@ module Invidious::Routes::Channels
channel = get_about_info(ucid, locale)
rescue ex : ChannelRedirect
return env.redirect env.request.resource.gsub(ucid, ex.channel_id)
+ rescue ex : NotFoundException
+ return error_template(404, ex)
rescue ex
return error_template(500, ex)
end
diff --git a/src/invidious/routes/embed.cr b/src/invidious/routes/embed.cr
index 207970b0..84da9993 100644
--- a/src/invidious/routes/embed.cr
+++ b/src/invidious/routes/embed.cr
@@ -7,6 +7,8 @@ module Invidious::Routes::Embed
playlist = get_playlist(plid)
offset = env.params.query["index"]?.try &.to_i? || 0
videos = get_playlist_videos(playlist, offset: offset)
+ rescue ex : NotFoundException
+ return error_template(404, ex)
rescue ex
return error_template(500, ex)
end
@@ -60,6 +62,8 @@ module Invidious::Routes::Embed
playlist = get_playlist(plid)
offset = env.params.query["index"]?.try &.to_i? || 0
videos = get_playlist_videos(playlist, offset: offset)
+ rescue ex : NotFoundException
+ return error_template(404, ex)
rescue ex
return error_template(500, ex)
end
@@ -119,6 +123,8 @@ module Invidious::Routes::Embed
video = get_video(id, region: params.region)
rescue ex : VideoRedirect
return env.redirect env.request.resource.gsub(id, ex.video_id)
+ rescue ex : NotFoundException
+ return error_template(404, ex)
rescue ex
return error_template(500, ex)
end
diff --git a/src/invidious/routes/feeds.cr b/src/invidious/routes/feeds.cr
index b5b58399..44a87175 100644
--- a/src/invidious/routes/feeds.cr
+++ b/src/invidious/routes/feeds.cr
@@ -150,6 +150,8 @@ module Invidious::Routes::Feeds
channel = get_about_info(ucid, locale)
rescue ex : ChannelRedirect
return env.redirect env.request.resource.gsub(ucid, ex.channel_id)
+ rescue ex : NotFoundException
+ return error_atom(404, ex)
rescue ex
return error_atom(500, ex)
end
@@ -182,7 +184,7 @@ module Invidious::Routes::Feeds
paid: false,
premium: false,
premiere_timestamp: nil,
- author_verified: false, # ¯\_(ツ)_/¯
+ author_verified: false,
})
end
diff --git a/src/invidious/routes/playlists.cr b/src/invidious/routes/playlists.cr
index de981d81..fe7e4e1c 100644
--- a/src/invidious/routes/playlists.cr
+++ b/src/invidious/routes/playlists.cr
@@ -66,7 +66,13 @@ module Invidious::Routes::Playlists
user = user.as(User)
playlist_id = env.params.query["list"]
- playlist = get_playlist(playlist_id)
+ begin
+ playlist = get_playlist(playlist_id)
+ rescue ex : NotFoundException
+ return error_template(404, ex)
+ rescue ex
+ return error_template(500, ex)
+ end
subscribe_playlist(user, playlist)
env.redirect "/playlist?list=#{playlist.id}"
@@ -304,6 +310,8 @@ module Invidious::Routes::Playlists
playlist_id = env.params.query["playlist_id"]
playlist = get_playlist(playlist_id).as(InvidiousPlaylist)
raise "Invalid user" if playlist.author != user.email
+ rescue ex : NotFoundException
+ return error_json(404, ex)
rescue ex
if redirect
return error_template(400, ex)
@@ -334,6 +342,8 @@ module Invidious::Routes::Playlists
begin
video = get_video(video_id)
+ rescue ex : NotFoundException
+ return error_json(404, ex)
rescue ex
if redirect
return error_template(500, ex)
@@ -394,6 +404,8 @@ module Invidious::Routes::Playlists
begin
playlist = get_playlist(plid)
+ rescue ex : NotFoundException
+ return error_template(404, ex)
rescue ex
return error_template(500, ex)
end
diff --git a/src/invidious/routes/search.cr b/src/invidious/routes/search.cr
index e60d0081..2a9705cf 100644
--- a/src/invidious/routes/search.cr
+++ b/src/invidious/routes/search.cr
@@ -59,8 +59,45 @@ module Invidious::Routes::Search
return error_template(500, ex)
end
+ params = query.to_http_params
+ url_prev_page = "/search?#{params}&page=#{query.page - 1}"
+ url_next_page = "/search?#{params}&page=#{query.page + 1}"
+
+ redirect_url = Invidious::Frontend::Misc.redirect_url(env)
+
env.set "search", query.text
templated "search"
end
end
+
+ def self.hashtag(env : HTTP::Server::Context)
+ locale = env.get("preferences").as(Preferences).locale
+
+ hashtag = env.params.url["hashtag"]?
+ if hashtag.nil? || hashtag.empty?
+ return error_template(400, "Invalid request")
+ end
+
+ page = env.params.query["page"]?
+ if page.nil?
+ page = 1
+ else
+ page = Math.max(1, page.to_i)
+ env.params.query.delete_all("page")
+ end
+
+ begin
+ videos = Invidious::Hashtag.fetch(hashtag, page)
+ rescue ex
+ return error_template(500, ex)
+ end
+
+ params = env.params.query.empty? ? "" : "&#{env.params.query}"
+
+ hashtag_encoded = URI.encode_www_form(hashtag, space_to_plus: false)
+ url_prev_page = "/hashtag/#{hashtag_encoded}?page=#{page - 1}#{params}"
+ url_next_page = "/hashtag/#{hashtag_encoded}?page=#{page + 1}#{params}"
+
+ templated "hashtag"
+ end
end
diff --git a/src/invidious/routes/video_playback.cr b/src/invidious/routes/video_playback.cr
index 3a92ef96..560f9c19 100644
--- a/src/invidious/routes/video_playback.cr
+++ b/src/invidious/routes/video_playback.cr
@@ -265,7 +265,13 @@ module Invidious::Routes::VideoPlayback
return error_template(403, "Administrator has disabled this endpoint.")
end
- video = get_video(id, region: region)
+ begin
+ video = get_video(id, region: region)
+ rescue ex : NotFoundException
+ return error_template(404, ex)
+ rescue ex
+ return error_template(500, ex)
+ end
fmt = video.fmt_stream.find(nil) { |f| f["itag"].as_i == itag } || video.adaptive_fmts.find(nil) { |f| f["itag"].as_i == itag }
url = fmt.try &.["url"]?.try &.as_s
diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr
index 7280de4f..fe1d8e54 100644
--- a/src/invidious/routes/watch.cr
+++ b/src/invidious/routes/watch.cr
@@ -63,6 +63,9 @@ module Invidious::Routes::Watch
video = get_video(id, region: params.region)
rescue ex : VideoRedirect
return env.redirect env.request.resource.gsub(id, ex.video_id)
+ rescue ex : NotFoundException
+ LOGGER.error("get_video not found: #{id} : #{ex.message}")
+ return error_template(404, ex)
rescue ex
LOGGER.error("get_video: #{id} : #{ex.message}")
return error_template(500, ex)
diff --git a/src/invidious/search/query.cr b/src/invidious/search/query.cr
index 34b36b1d..24e79609 100644
--- a/src/invidious/search/query.cr
+++ b/src/invidious/search/query.cr
@@ -57,7 +57,7 @@ module Invidious::Search
# Get the page number (also common to all search types)
@page = params["page"]?.try &.to_i? || 1
- # Stop here is raw query in empty
+ # Stop here if raw query is empty
# NOTE: maybe raise in the future?
return if self.empty_raw_query?
@@ -127,6 +127,16 @@ module Invidious::Search
return items
end
+ # Return the HTTP::Params corresponding to this Query (invidious format)
+ def to_http_params : HTTP::Params
+ params = @filters.to_iv_params
+
+ params["q"] = @query
+ params["channel"] = @channel if !@channel.empty?
+
+ return params
+ end
+
# TODO: clean code
private def unnest_items(all_items) : Array(SearchItem)
items = [] of SearchItem
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index f65b05bb..19ee064c 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -323,7 +323,7 @@ struct Video
json.field "viewCount", self.views
json.field "likeCount", self.likes
- json.field "dislikeCount", self.dislikes
+ json.field "dislikeCount", 0_i64
json.field "paid", self.paid
json.field "premium", self.premium
@@ -354,7 +354,7 @@ struct Video
json.field "lengthSeconds", self.length_seconds
json.field "allowRatings", self.allow_ratings
- json.field "rating", self.average_rating
+ json.field "rating", 0_i64
json.field "isListed", self.is_listed
json.field "liveNow", self.live_now
json.field "isUpcoming", self.is_upcoming
@@ -556,11 +556,6 @@ struct Video
info["dislikes"]?.try &.as_i64 || 0_i64
end
- def average_rating : Float64
- # (likes / (likes + dislikes) * 4 + 1)
- info["videoDetails"]["averageRating"]?.try { |t| t.as_f? || t.as_i64?.try &.to_f64 }.try &.round(4) || 0.0
- end
-
def published : Time
info
.dig?("microformat", "playerMicroformatRenderer", "publishDate")
@@ -813,14 +808,6 @@ struct Video
return info.dig?("streamingData", "adaptiveFormats", 0, "projectionType").try &.as_s
end
- def wilson_score : Float64
- ci_lower_bound(likes, likes + dislikes).round(4)
- end
-
- def engagement : Float64
- (((likes + dislikes) / views) * 100).round(4)
- end
-
def reason : String?
info["reason"]?.try &.as_s
end
@@ -853,6 +840,7 @@ end
# the same 11 first entries as the compact rendered.
#
# TODO: "compactRadioRenderer" (Mix) and
+# TODO: Use a proper struct/class instead of a hacky JSON object
def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)?
return nil if !related["videoId"]?
@@ -868,11 +856,7 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)?
.try &.dig?("runs", 0)
author = channel_info.try &.dig?("text")
- author_verified_badge = related["ownerBadges"]?.try do |badges_array|
- badges_array.as_a.find(&.dig("metadataBadgeRenderer", "tooltip").as_s.== "Verified")
- end
-
- author_verified = (author_verified_badge && author_verified_badge.size > 0).to_s
+ author_verified = has_verified_badge?(related["ownerBadges"]?).to_s
ucid = channel_info.try { |ci| HelperExtractors.get_browse_id(ci) }
@@ -911,13 +895,20 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_
player_response = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config)
- if player_response.dig?("playabilityStatus", "status").try &.as_s != "OK"
+ playability_status = player_response.dig?("playabilityStatus", "status").try &.as_s
+
+ if playability_status != "OK"
subreason = player_response.dig?("playabilityStatus", "errorScreen", "playerErrorMessageRenderer", "subreason")
reason = subreason.try &.[]?("simpleText").try &.as_s
reason ||= subreason.try &.[]("runs").as_a.map(&.[]("text")).join("")
reason ||= player_response.dig("playabilityStatus", "reason").as_s
+
params["reason"] = JSON::Any.new(reason)
- return params
+
+ # Stop here if video is not a scheduled livestream
+ if playability_status != "LIVE_STREAM_OFFLINE"
+ return params
+ end
end
params["shortDescription"] = player_response.dig?("videoDetails", "shortDescription") || JSON::Any.new(nil)
@@ -1008,7 +999,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_
params["relatedVideos"] = JSON::Any.new(related)
- # Likes/dislikes
+ # Likes
toplevel_buttons = video_primary_renderer
.try &.dig?("videoActions", "menuRenderer", "topLevelButtons")
@@ -1026,30 +1017,10 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_
LOGGER.trace("extract_video_info: Found \"likes\" button. Button text is \"#{likes_txt}\"")
LOGGER.debug("extract_video_info: Likes count is #{likes}") if likes
end
-
- dislikes_button = toplevel_buttons.as_a
- .find(&.dig("toggleButtonRenderer", "defaultIcon", "iconType").as_s.== "DISLIKE")
- .try &.["toggleButtonRenderer"]
-
- if dislikes_button
- dislikes_txt = (dislikes_button["defaultText"]? || dislikes_button["toggledText"]?)
- .try &.dig?("accessibility", "accessibilityData", "label")
- dislikes = dislikes_txt.as_s.gsub(/\D/, "").to_i64? if dislikes_txt
-
- LOGGER.trace("extract_video_info: Found \"dislikes\" button. Button text is \"#{dislikes_txt}\"")
- LOGGER.debug("extract_video_info: Dislikes count is #{dislikes}") if dislikes
- end
- end
-
- if likes && likes != 0_i64 && (!dislikes || dislikes == 0_i64)
- if rating = player_response.dig?("videoDetails", "averageRating").try { |x| x.as_i64? || x.as_f? }
- dislikes = (likes * ((5 - rating)/(rating - 1))).round.to_i64
- LOGGER.debug("extract_video_info: Dislikes count (using fallback method) is #{dislikes}")
- end
end
params["likes"] = JSON::Any.new(likes || 0_i64)
- params["dislikes"] = JSON::Any.new(dislikes || 0_i64)
+ params["dislikes"] = JSON::Any.new(0_i64)
# Description
@@ -1089,17 +1060,19 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_
# Author infos
- author_info = video_secondary_renderer.try &.dig?("owner", "videoOwnerRenderer")
- author_thumbnail = author_info.try &.dig?("thumbnail", "thumbnails", 0, "url")
+ if author_info = video_secondary_renderer.try &.dig?("owner", "videoOwnerRenderer")
+ author_thumbnail = author_info.dig?("thumbnail", "thumbnails", 0, "url")
+ params["authorThumbnail"] = JSON::Any.new(author_thumbnail.try &.as_s || "")
- author_verified_badge = author_info.try &.dig?("badges", 0, "metadataBadgeRenderer", "tooltip")
- author_verified = (!author_verified_badge.nil? && author_verified_badge == "Verified")
- params["authorVerified"] = JSON::Any.new(author_verified)
+ author_verified = has_verified_badge?(author_info["badges"]?)
+ params["authorVerified"] = JSON::Any.new(author_verified)
- params["authorThumbnail"] = JSON::Any.new(author_thumbnail.try &.as_s || "")
+ subs_text = author_info["subscriberCountText"]?
+ .try { |t| t["simpleText"]? || t.dig?("runs", 0, "text") }
+ .try &.as_s.split(" ", 2)[0]
- params["subCountText"] = JSON::Any.new(author_info.try &.["subscriberCountText"]?
- .try { |t| t["simpleText"]? || t.dig?("runs", 0, "text") }.try &.as_s.split(" ", 2)[0] || "-")
+ params["subCountText"] = JSON::Any.new(subs_text || "-")
+ end
# Return data
@@ -1159,7 +1132,11 @@ def fetch_video(id, region)
end
if reason = info["reason"]?
- raise InfoException.new(reason.as_s || "")
+ if reason == "Video unavailable"
+ raise NotFoundException.new(reason.as_s || "")
+ else
+ raise InfoException.new(reason.as_s || "")
+ end
end
video = Video.new({
diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr
index fb7ad1dc..0e959ff2 100644
--- a/src/invidious/views/components/item.ecr
+++ b/src/invidious/views/components/item.ecr
@@ -5,7 +5,7 @@
<a href="/channel/<%= item.ucid %>">
<% if !env.get("preferences").as(Preferences).thin_mode %>
<center>
- <img loading="lazy" style="width:56.25%" src="/ggpht<%= URI.parse(item.author_thumbnail).request_target.gsub(/=s\d+/, "=s176") %>"/>
+ <img loading="lazy" tabindex="-1" style="width:56.25%" src="/ggpht<%= URI.parse(item.author_thumbnail).request_target.gsub(/=s\d+/, "=s176") %>"/>
</center>
<% end %>
<p dir="auto"><%= HTML.escape(item.author) %><% if !item.author_verified.nil? && item.author_verified %>&nbsp;<i class="icon ion ion-md-checkmark-circle"></i><% end %></p>
@@ -23,7 +23,7 @@
<a style="width:100%" href="<%= url %>">
<% if !env.get("preferences").as(Preferences).thin_mode %>
<div class="thumbnail">
- <img loading="lazy" class="thumbnail" src="<%= URI.parse(item.thumbnail || "/").request_target %>"/>
+ <img loading="lazy" tabindex="-1" class="thumbnail" src="<%= URI.parse(item.thumbnail || "/").request_target %>"/>
<p class="length"><%= translate_count(locale, "generic_videos_count", item.video_count, NumberFormatting::Separator) %></p>
</div>
<% end %>
@@ -36,7 +36,7 @@
<a href="/watch?v=<%= item.id %>&list=<%= item.rdid %>">
<% if !env.get("preferences").as(Preferences).thin_mode %>
<div class="thumbnail">
- <img loading="lazy" class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
+ <img loading="lazy" tabindex="-1" class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
<% if item.length_seconds != 0 %>
<p class="length"><%= recode_length_seconds(item.length_seconds) %></p>
<% end %>
@@ -51,16 +51,13 @@
<a style="width:100%" href="/watch?v=<%= item.id %>&list=<%= item.plid %>&index=<%= item.index %>">
<% if !env.get("preferences").as(Preferences).thin_mode %>
<div class="thumbnail">
- <img loading="lazy" class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
+ <img loading="lazy" tabindex="-1" class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
+
<% if plid_form = env.get?("remove_playlist_items") %>
<form data-onsubmit="return_false" action="/playlist_ajax?action_remove_video=1&set_video_id=<%= item.index %>&playlist_id=<%= plid_form %>&referer=<%= env.get("current_page") %>" method="post">
<input type="hidden" name="csrf_token" value="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>">
<p class="watched">
- <a data-onclick="remove_playlist_item" data-index="<%= item.index %>" data-plid="<%= plid_form %>" href="javascript:void(0)">
- <button type="submit" style="all:unset">
- <i class="icon ion-md-trash"></i>
- </button>
- </a>
+ <button type="submit" style="all:unset" data-onclick="remove_playlist_item" data-index="<%= item.index %>" data-plid="<%= plid_form %>"><i class="icon ion-md-trash"></i></button>
</p>
</form>
<% end %>
@@ -103,29 +100,21 @@
<a style="width:100%" href="/watch?v=<%= item.id %>">
<% if !env.get("preferences").as(Preferences).thin_mode %>
<div class="thumbnail">
- <img loading="lazy" class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
+ <img loading="lazy" tabindex="-1" class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
<% if env.get? "show_watched" %>
<form data-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="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>">
<p class="watched">
- <a data-onclick="mark_watched" data-id="<%= item.id %>" href="javascript:void(0)">
- <button type="submit" style="all:unset">
- <i data-mouse="switch_classes" data-switch-classes="ion-ios-eye-off,ion-ios-eye"
- class="icon ion-ios-eye">
- </i>
- </button>
- </a>
+ <button type="submit" style="all:unset" data-onclick="mark_watched" data-id="<%= item.id %>">
+ <i data-mouse="switch_classes" data-switch-classes="ion-ios-eye-off,ion-ios-eye" class="icon ion-ios-eye"></i>
+ </button>
</p>
</form>
<% elsif plid_form = env.get? "add_playlist_items" %>
<form data-onsubmit="return_false" action="/playlist_ajax?action_add_video=1&video_id=<%= item.id %>&playlist_id=<%= plid_form %>&referer=<%= env.get("current_page") %>" method="post">
<input type="hidden" name="csrf_token" value="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>">
<p class="watched">
- <a data-onclick="add_playlist_item" data-id="<%= item.id %>" data-plid="<%= plid_form %>" href="javascript:void(0)">
- <button type="submit" style="all:unset">
- <i class="icon ion-md-add"></i>
- </button>
- </a>
+ <button type="submit" style="all:unset" data-onclick="add_playlist_item" data-id="<%= item.id %>" data-plid="<%= plid_form %>"><i class="icon ion-md-add"></i></button>
</p>
</form>
<% end %>
diff --git a/src/invidious/views/components/player.ecr b/src/invidious/views/components/player.ecr
index fffefc9a..c3c02df0 100644
--- a/src/invidious/views/components/player.ecr
+++ b/src/invidious/views/components/player.ecr
@@ -7,14 +7,25 @@
<source src="<%= URI.parse(hlsvp).request_target %><% if params.local %>?local=true<% end %>" type="application/x-mpegURL" label="livestream">
<% else %>
<% if params.listen %>
- <% audio_streams.each_with_index do |fmt, i|
+ <% # default to 128k m4a stream
+ best_m4a_stream_index = 0
+ best_m4a_stream_bitrate = 0
+ audio_streams.each_with_index do |fmt, i|
+ bandwidth = fmt["bitrate"].as_i
+ if (fmt["mimeType"].as_s.starts_with?("audio/mp4") && bandwidth > best_m4a_stream_bitrate)
+ best_m4a_stream_bitrate = bandwidth
+ best_m4a_stream_index = i
+ end
+ end
+
+ audio_streams.each_with_index do |fmt, i|
src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}"
src_url += "&local=true" if params.local
bitrate = fmt["bitrate"]
mimetype = HTML.escape(fmt["mimeType"].as_s)
- selected = i == 0 ? true : false
+ selected = (i == best_m4a_stream_index)
%>
<source src="<%= src_url %>" type='<%= mimetype %>' label="<%= bitrate %>k" selected="<%= selected %>">
<% if !params.local && !CONFIG.disabled?("local") %>
diff --git a/src/invidious/views/embed.ecr b/src/invidious/views/embed.ecr
index ce5ff7f0..1bf5cc3e 100644
--- a/src/invidious/views/embed.ecr
+++ b/src/invidious/views/embed.ecr
@@ -11,6 +11,7 @@
<link rel="stylesheet" href="/css/default.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/embed.css?v=<%= ASSET_COMMIT %>">
<title><%= HTML.escape(video.title) %> - Invidious</title>
+ <script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
</head>
<body class="dark-theme">
diff --git a/src/invidious/views/feeds/history.ecr b/src/invidious/views/feeds/history.ecr
index 6c1243c5..471d21db 100644
--- a/src/invidious/views/feeds/history.ecr
+++ b/src/invidious/views/feeds/history.ecr
@@ -38,9 +38,7 @@
<form data-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.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>">
<p class="watched">
- <a data-onclick="mark_unwatched" data-id="<%= item %>" href="javascript:void(0)">
- <button type="submit" style="all:unset"><i class="icon ion-md-trash"></i></button>
- </a>
+ <button type="submit" style="all:unset" data-onclick="mark_unwatched" data-id="<%= item %>"><i class="icon ion-md-trash"></i></button>
</p>
</form>
</div>
diff --git a/src/invidious/views/hashtag.ecr b/src/invidious/views/hashtag.ecr
new file mode 100644
index 00000000..0ecfe832
--- /dev/null
+++ b/src/invidious/views/hashtag.ecr
@@ -0,0 +1,39 @@
+<% content_for "header" do %>
+<title><%= HTML.escape(hashtag) %> - Invidious</title>
+<% end %>
+
+<hr/>
+
+<div class="pure-g h-box v-box">
+ <div class="pure-u-1 pure-u-lg-1-5">
+ <%- if page > 1 -%>
+ <a href="<%= url_prev_page %>"><%= translate(locale, "Previous page") %></a>
+ <%- end -%>
+ </div>
+ <div class="pure-u-1 pure-u-lg-3-5"></div>
+ <div class="pure-u-1 pure-u-lg-1-5" style="text-align:right">
+ <%- if videos.size >= 60 -%>
+ <a href="<%= url_next_page %>"><%= translate(locale, "Next page") %></a>
+ <%- end -%>
+ </div>
+</div>
+
+<div class="pure-g">
+ <%- videos.each do |item| -%>
+ <%= rendered "components/item" %>
+ <%- end -%>
+</div>
+
+<div class="pure-g h-box">
+ <div class="pure-u-1 pure-u-lg-1-5">
+ <%- if page > 1 -%>
+ <a href="<%= url_prev_page %>"><%= translate(locale, "Previous page") %></a>
+ <%- end -%>
+ </div>
+ <div class="pure-u-1 pure-u-lg-3-5"></div>
+ <div class="pure-u-1 pure-u-lg-1-5" style="text-align:right">
+ <%- if videos.size >= 60 -%>
+ <a href="<%= url_next_page %>"><%= translate(locale, "Next page") %></a>
+ <%- end -%>
+ </div>
+</div>
diff --git a/src/invidious/views/licenses.ecr b/src/invidious/views/licenses.ecr
index 861913d0..25b24ed4 100644
--- a/src/invidious/views/licenses.ecr
+++ b/src/invidious/views/licenses.ecr
@@ -11,6 +11,20 @@
<table id="jslicense-labels1">
<tr>
<td>
+ <a href="/js/_helpers.js?v=<%= ASSET_COMMIT %>">_helpers.js</a>
+ </td>
+
+ <td>
+ <a href="https://www.gnu.org/licenses/agpl-3.0.html">AGPL-3.0</a>
+ </td>
+
+ <td>
+ <a href="/js/_helpers.js?v=<%= ASSET_COMMIT %>"><%= translate(locale, "source") %></a>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
<a href="/js/community.js?v=<%= ASSET_COMMIT %>">community.js</a>
</td>
diff --git a/src/invidious/views/search.ecr b/src/invidious/views/search.ecr
index 7110703e..254449a1 100644
--- a/src/invidious/views/search.ecr
+++ b/src/invidious/views/search.ecr
@@ -3,16 +3,6 @@
<link rel="stylesheet" href="/css/search.css?v=<%= ASSET_COMMIT %>">
<% end %>
-<%-
- search_query_encoded = URI.encode_www_form(query.text, space_to_plus: true)
- filter_params = query.filters.to_iv_params
-
- url_prev_page = "/search?q=#{search_query_encoded}&#{filter_params}&page=#{query.page - 1}"
- url_next_page = "/search?q=#{search_query_encoded}&#{filter_params}&page=#{query.page + 1}"
-
- redirect_url = Invidious::Frontend::Misc.redirect_url(env)
--%>
-
<!-- Search redirection and filtering UI -->
<%= Invidious::Frontend::SearchFilters.generate(query.filters, query.text, query.page, locale) %>
<hr/>
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index bd908dd6..4e2b29f0 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -17,6 +17,7 @@
<link rel="stylesheet" href="/css/grids-responsive-min.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/ionicons.min.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/default.css?v=<%= ASSET_COMMIT %>">
+ <script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
</head>
<%
diff --git a/src/invidious/views/user/subscription_manager.ecr b/src/invidious/views/user/subscription_manager.ecr
index c2a89ca2..c9801f09 100644
--- a/src/invidious/views/user/subscription_manager.ecr
+++ b/src/invidious/views/user/subscription_manager.ecr
@@ -39,9 +39,7 @@
<h3 style="padding-right:0.5em">
<form data-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="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>">
- <a data-onclick="remove_subscription" data-ucid="<%= channel.id %>" href="#">
- <input style="all:unset" type="submit" value="<%= translate(locale, "unsubscribe") %>">
- </a>
+ <input style="all:unset" type="submit" data-onclick="remove_subscription" data-ucid="<%= channel.id %>" value="<%= translate(locale, "unsubscribe") %>">
</form>
</h3>
</div>
diff --git a/src/invidious/views/user/token_manager.ecr b/src/invidious/views/user/token_manager.ecr
index 79f905a1..a73fa048 100644
--- a/src/invidious/views/user/token_manager.ecr
+++ b/src/invidious/views/user/token_manager.ecr
@@ -31,9 +31,7 @@
<h3 style="padding-right:0.5em">
<form data-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="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>">
- <a data-onclick="revoke_token" data-session="<%= token[:session] %>" href="#">
- <input style="all:unset" type="submit" value="<%= translate(locale, "revoke") %>">
- </a>
+ <input style="all:unset" type="submit" data-onclick="revoke_token" data-session="<%= token[:session] %>" value="<%= translate(locale, "revoke") %>">
</form>
</h3>
</div>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index 783eff1d..50c63d21 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -173,7 +173,7 @@ we're going to need to do it here in order to allow for translations.
<p id="views"><i class="icon ion-ios-eye"></i> <%= number_with_separator(video.views) %></p>
<p id="likes"><i class="icon ion-ios-thumbs-up"></i> <%= number_with_separator(video.likes) %></p>
- <p id="dislikes"></p>
+ <p id="dislikes" style="display: none; visibility: hidden;"></p>
<p id="genre"><%= translate(locale, "Genre: ") %>
<% if !video.genre_url %>
<%= video.genre %>
@@ -185,9 +185,9 @@ we're going to need to do it here in order to allow for translations.
<p id="license"><%= translate(locale, "License: ") %><%= video.license %></p>
<% end %>
<p id="family_friendly"><%= translate(locale, "Family friendly? ") %><%= translate_bool(locale, video.is_family_friendly) %></p>
- <p id="wilson"><%= translate(locale, "Wilson score: ") %><%= video.wilson_score %></p>
- <p id="rating"></p>
- <p id="engagement"><%= translate(locale, "Engagement: ") %><%= video.engagement %>%</p>
+ <p id="wilson" style="display: none; visibility: hidden;"></p>
+ <p id="rating" style="display: none; visibility: hidden;"></p>
+ <p id="engagement" style="display: none; visibility: hidden;"></p>
<% if video.allowed_regions.size != REGIONS.size %>
<p id="allowed_regions">
<% if video.allowed_regions.size < REGIONS.size // 2 %>
@@ -278,24 +278,24 @@ we're going to need to do it here in order to allow for translations.
</div>
<% end %>
<p style="width:100%"><%= rv["title"] %></p>
- <h5 class="pure-g">
- <div class="pure-u-14-24">
- <% if rv["ucid"]? %>
- <b style="width:100%"><a href="/channel/<%= rv["ucid"] %>"><%= rv["author"]? %><% if rv["author_verified"]? == "true" %>&nbsp;<i class="icon ion ion-md-checkmark-circle"></i><% end %></a></b>
- <% else %>
- <b style="width:100%"><%= rv["author"]? %><% if rv["author_verified"]? == "true" %>&nbsp;<i class="icon ion ion-md-checkmark-circle"></i><% end %></b>
- <% end %>
- </div>
-
- <div class="pure-u-10-24" style="text-align:right">
- <b class="width:100%"><%=
- views = rv["view_count"]?.try &.to_i?
- views ||= rv["view_count_short"]?.try { |x| short_text_to_number(x) }
- translate_count(locale, "generic_views_count", views || 0, NumberFormatting::Short)
- %></b>
- </div>
- </h5>
</a>
+ <h5 class="pure-g">
+ <div class="pure-u-14-24">
+ <% if rv["ucid"]? %>
+ <b style="width:100%"><a href="/channel/<%= rv["ucid"] %>"><%= rv["author"]? %><% if rv["author_verified"]? == "true" %>&nbsp;<i class="icon ion ion-md-checkmark-circle"></i><% end %></a></b>
+ <% else %>
+ <b style="width:100%"><%= rv["author"]? %><% if rv["author_verified"]? == "true" %>&nbsp;<i class="icon ion ion-md-checkmark-circle"></i><% end %></b>
+ <% end %>
+ </div>
+
+ <div class="pure-u-10-24" style="text-align:right">
+ <b class="width:100%"><%=
+ views = rv["view_count"]?.try &.to_i?
+ views ||= rv["view_count_short"]?.try { |x| short_text_to_number(x) }
+ translate_count(locale, "generic_views_count", views || 0, NumberFormatting::Short)
+ %></b>
+ </div>
+ </h5>
<% end %>
<% end %>
</div>
diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr
index a2ec7d59..b9609eb9 100644
--- a/src/invidious/yt_backend/extractors.cr
+++ b/src/invidious/yt_backend/extractors.cr
@@ -1,3 +1,5 @@
+require "../helpers/serialized_yt_data"
+
# This file contains helper methods to parse the Youtube API json data into
# neat little packages we can use
@@ -14,6 +16,7 @@ private ITEM_PARSERS = {
Parsers::GridPlaylistRendererParser,
Parsers::PlaylistRendererParser,
Parsers::CategoryRendererParser,
+ Parsers::RichItemRendererParser,
}
record AuthorFallback, name : String, id : String
@@ -57,6 +60,8 @@ private module Parsers
author_id = author_fallback.id
end
+ author_verified = has_verified_badge?(item_contents["ownerBadges"]?)
+
# For live videos (and possibly recently premiered videos) there is no published information.
# Instead, in its place is the amount of people currently watching. This behavior should be replicated
# on Invidious once all features of livestreams are supported. On an unrelated note, defaulting to the current
@@ -102,11 +107,7 @@ private module Parsers
premium = false
premiere_timestamp = item_contents.dig?("upcomingEventData", "startTime").try { |t| Time.unix(t.as_s.to_i64) }
- author_verified_badge = item_contents["ownerBadges"]?.try do |badges_array|
- badges_array.as_a.find(&.dig("metadataBadgeRenderer", "tooltip").as_s.== "Verified")
- end
- author_verified = (author_verified_badge && author_verified_badge.size > 0)
item_contents["badges"]?.try &.as_a.each do |badge|
b = badge["metadataBadgeRenderer"]
case b["label"].as_s
@@ -133,7 +134,7 @@ private module Parsers
live_now: live_now,
premium: premium,
premiere_timestamp: premiere_timestamp,
- author_verified: author_verified || false,
+ author_verified: author_verified,
})
end
@@ -161,12 +162,9 @@ private module Parsers
private def self.parse(item_contents, author_fallback)
author = extract_text(item_contents["title"]) || author_fallback.name
author_id = item_contents["channelId"]?.try &.as_s || author_fallback.id
- author_verified_badge = item_contents["ownerBadges"]?.try do |badges_array|
- badges_array.as_a.find(&.dig("metadataBadgeRenderer", "tooltip").as_s.== "Verified")
- end
-
- author_verified = (author_verified_badge && author_verified_badge.size > 0)
+ author_verified = has_verified_badge?(item_contents["ownerBadges"]?)
author_thumbnail = HelperExtractors.get_thumbnails(item_contents)
+
# When public subscriber count is disabled, the subscriberCountText isn't sent by InnerTube.
# Always simpleText
# TODO change default value to nil
@@ -188,7 +186,7 @@ private module Parsers
video_count: video_count,
description_html: description_html,
auto_generated: auto_generated,
- author_verified: author_verified || false,
+ author_verified: author_verified,
})
end
@@ -216,11 +214,9 @@ private module Parsers
private def self.parse(item_contents, author_fallback)
title = extract_text(item_contents["title"]) || ""
plid = item_contents["playlistId"]?.try &.as_s || ""
- author_verified_badge = item_contents["ownerBadges"]?.try do |badges_array|
- badges_array.as_a.find(&.dig("metadataBadgeRenderer", "tooltip").as_s.== "Verified")
- end
- author_verified = (author_verified_badge && author_verified_badge.size > 0)
+ author_verified = has_verified_badge?(item_contents["ownerBadges"]?)
+
video_count = HelperExtractors.get_video_count(item_contents)
playlist_thumbnail = HelperExtractors.get_thumbnails(item_contents)
@@ -232,7 +228,7 @@ private module Parsers
video_count: video_count,
videos: [] of SearchPlaylistVideo,
thumbnail: playlist_thumbnail,
- author_verified: author_verified || false,
+ author_verified: author_verified,
})
end
@@ -266,11 +262,8 @@ private module Parsers
author_info = item_contents.dig?("shortBylineText", "runs", 0)
author = author_info.try &.["text"].as_s || author_fallback.name
author_id = author_info.try { |x| HelperExtractors.get_browse_id(x) } || author_fallback.id
- author_verified_badge = item_contents["ownerBadges"]?.try do |badges_array|
- badges_array.as_a.find(&.dig("metadataBadgeRenderer", "tooltip").as_s.== "Verified")
- end
+ author_verified = has_verified_badge?(item_contents["ownerBadges"]?)
- author_verified = (author_verified_badge && author_verified_badge.size > 0)
videos = item_contents["videos"]?.try &.as_a.map do |v|
v = v["childVideoRenderer"]
v_title = v.dig?("title", "simpleText").try &.as_s || ""
@@ -293,7 +286,7 @@ private module Parsers
video_count: video_count,
videos: videos,
thumbnail: playlist_thumbnail,
- author_verified: author_verified || false,
+ author_verified: author_verified,
})
end
@@ -374,6 +367,29 @@ private module Parsers
return {{@type.name}}
end
end
+
+ # Parses an InnerTube richItemRenderer into a SearchVideo.
+ # Returns nil when the given object isn't a shelfRenderer
+ #
+ # A richItemRenderer seems to be a simple wrapper for a videoRenderer, used
+ # by the result page for hashtags. It is located inside a continuationItems
+ # container.
+ #
+ module RichItemRendererParser
+ def self.process(item : JSON::Any, author_fallback : AuthorFallback)
+ if item_contents = item.dig?("richItemRenderer", "content")
+ return self.parse(item_contents, author_fallback)
+ end
+ end
+
+ private def self.parse(item_contents, author_fallback)
+ return VideoRendererParser.process(item_contents, author_fallback)
+ end
+
+ def self.parser_name
+ return {{@type.name}}
+ end
+ end
end
# The following are the extractors for extracting an array of items from
@@ -401,7 +417,7 @@ private module Extractors
# {"tabRenderer": {
# "endpoint": {...}
# "title": "Playlists",
- # "selected": true,
+ # "selected": true, # Is nil unless tab is selected
# "content": {...},
# ...
# }}
@@ -501,6 +517,8 @@ private module Extractors
self.extract(target)
elsif target = initial_data["appendContinuationItemsAction"]?
self.extract(target)
+ elsif target = initial_data["reloadContinuationItemsCommand"]?
+ self.extract(target)
end
end
diff --git a/src/invidious/yt_backend/extractors_utils.cr b/src/invidious/yt_backend/extractors_utils.cr
index add5f488..f8245160 100644
--- a/src/invidious/yt_backend/extractors_utils.cr
+++ b/src/invidious/yt_backend/extractors_utils.cr
@@ -29,6 +29,45 @@ def extract_text(item : JSON::Any?) : String?
end
end
+# Check if an "ownerBadges" or a "badges" element contains a verified badge.
+# There is currently two known types of verified badges:
+#
+# "ownerBadges": [{
+# "metadataBadgeRenderer": {
+# "icon": { "iconType": "CHECK_CIRCLE_THICK" },
+# "style": "BADGE_STYLE_TYPE_VERIFIED",
+# "tooltip": "Verified",
+# "accessibilityData": { "label": "Verified" }
+# }
+# }],
+#
+# "ownerBadges": [{
+# "metadataBadgeRenderer": {
+# "icon": { "iconType": "OFFICIAL_ARTIST_BADGE" },
+# "style": "BADGE_STYLE_TYPE_VERIFIED_ARTIST",
+# "tooltip": "Official Artist Channel",
+# "accessibilityData": { "label": "Official Artist Channel" }
+# }
+# }],
+#
+def has_verified_badge?(badges : JSON::Any?)
+ return false if badges.nil?
+
+ badges.as_a.each do |badge|
+ style = badge.dig("metadataBadgeRenderer", "style").as_s
+
+ return true if style == "BADGE_STYLE_TYPE_VERIFIED"
+ return true if style == "BADGE_STYLE_TYPE_VERIFIED_ARTIST"
+ end
+
+ return false
+rescue ex
+ LOGGER.debug("Unable to parse owner badges. Got exception: #{ex.message}")
+ LOGGER.trace("Owner badges data: #{badges.to_json}")
+
+ return false
+end
+
def extract_videos(initial_data : Hash(String, JSON::Any), author_fallback : String? = nil, author_id_fallback : String? = nil)
extracted = extract_items(initial_data, author_fallback, author_id_fallback)
@@ -45,7 +84,7 @@ end
def extract_selected_tab(tabs)
# Extract the selected tab from the array of tabs Youtube returns
- return selected_target = tabs.as_a.select(&.["tabRenderer"]?.try &.["selected"].as_bool)[0]["tabRenderer"]
+ return selected_target = tabs.as_a.select(&.["tabRenderer"]?.try &.["selected"]?.try &.as_bool)[0]["tabRenderer"]
end
def fetch_continuation_token(items : Array(JSON::Any))