Merge pull request #2874 from SamantazFox/small-fixes

Small fixes
pull/2885/head
Samantaz Fox 3 years ago committed by GitHub
commit e2fc64296d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -62,7 +62,8 @@ test:
crystal spec crystal spec
verify: verify:
crystal build src/invidious.cr --no-codegen --progress --stats --error-trace crystal build src/invidious.cr -Dskip_videojs_download \
--no-codegen --progress --stats --error-trace
# ----------------------- # -----------------------

@ -150,13 +150,13 @@
// Ignore shortcuts if any text input is focused // Ignore shortcuts if any text input is focused
let focused_tag = document.activeElement.tagName.toLowerCase(); let focused_tag = document.activeElement.tagName.toLowerCase();
let focused_type = document.activeElement.type.toLowerCase(); const allowed = /^(button|checkbox|file|radio|submit)$/;
let allowed = /^(button|checkbox|file|radio|submit)$/;
if (focused_tag === "textarea" || if (focused_tag === "textarea") return;
(focused_tag === "input" && !focused_type.match(allowed)) if (focused_tag === "input") {
) let focused_type = document.activeElement.type.toLowerCase();
return; if (!focused_type.match(allowed)) return;
}
// Focus search bar on '/' // Focus search bar on '/'
if (event.key == "/") { if (event.key == "/") {

@ -60,29 +60,19 @@ videojs.Vhs.xhr.beforeRequest = function(options) {
var player = videojs('player', options); var player = videojs('player', options);
const storage = (() => { const storage = (() => {
try { try { if (localStorage.length !== -1) return localStorage; }
if (localStorage.length !== -1) { catch (e) { console.info('No storage available: ' + e); }
return localStorage;
}
} catch (e) {
console.info('No storage available: ' + e);
}
return undefined; return undefined;
})(); })();
if (location.pathname.startsWith('/embed/')) { 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({ player.overlay({
overlays: [{ overlays: [
start: 'loadstart', { start: 'loadstart', content: overlay_content, end: 'playing', align: 'top'},
content: '<h1><a rel="noopener" target="_blank" href="' + location.origin + '/watch?v=' + video_data.id + '">' + player_data.title + '</a></h1>', { start: 'pause', content: overlay_content, end: 'playing', align: 'top'}
end: 'playing', ]
align: 'top'
}, {
start: 'pause',
content: '<h1><a rel="noopener" target="_blank" href="' + location.origin + '/watch?v=' + video_data.id + '">' + player_data.title + '</a></h1>',
end: 'playing',
align: 'top'
}]
}); });
} }
@ -99,9 +89,7 @@ if (isMobile()) {
buttons = ["playToggle", "volumePanel", "captionsButton"]; buttons = ["playToggle", "volumePanel", "captionsButton"];
if (video_data.params.quality !== 'dash') { if (video_data.params.quality !== 'dash') buttons.push("qualitySelector")
buttons.push("qualitySelector")
}
// Create new control bar object for operation buttons // Create new control bar object for operation buttons
const ControlBar = videojs.getComponent("controlBar"); const ControlBar = videojs.getComponent("controlBar");
@ -146,16 +134,12 @@ player.on('error', function (event) {
player.load(); player.load();
if (currentTime > 0.5) { if (currentTime > 0.5) currentTime -= 0.5;
currentTime -= 0.5;
}
player.currentTime(currentTime); player.currentTime(currentTime);
player.playbackRate(playbackRate); player.playbackRate(playbackRate);
if (!paused) { if (!paused) player.play();
player.play();
}
}, 5000); }, 5000);
} }
}); });
@ -183,13 +167,8 @@ if (video_data.params.video_start > 0 || video_data.params.video_end > 0) {
player.markers({ player.markers({
onMarkerReached: function (marker) { onMarkerReached: function (marker) {
if (marker.text === 'End') { if (marker.text === 'End')
if (player.loop()) { player.loop() ? player.markers.prev('Start') : player.pause();
player.markers.prev('Start');
} else {
player.pause();
}
}
}, },
markers: markers markers: markers
}); });
@ -217,9 +196,7 @@ if (video_data.params.save_player_pos) {
const remeberedTime = get_video_time(); const remeberedTime = get_video_time();
let lastUpdated = 0; let lastUpdated = 0;
if(!hasTimeParam) { if(!hasTimeParam) set_seconds_after_start(remeberedTime);
set_seconds_after_start(remeberedTime);
}
const updateTime = () => { const updateTime = () => {
const raw = player.currentTime(); const raw = player.currentTime();
@ -233,9 +210,7 @@ if (video_data.params.save_player_pos) {
player.on("timeupdate", updateTime); player.on("timeupdate", updateTime);
} }
else { else remove_all_video_times();
remove_all_video_times();
}
if (video_data.params.autoplay) { if (video_data.params.autoplay) {
var bpb = player.getChild('bigPlayButton'); var bpb = player.getChild('bigPlayButton');
@ -433,26 +408,10 @@ function set_time_percent(percent) {
player.currentTime(newTime); player.currentTime(newTime);
} }
function play() { function play() { player.play(); }
player.play(); function pause() { player.pause(); }
} function stop() { player.pause(); player.currentTime(0); }
function toggle_play() { player.paused() ? play() : pause(); }
function pause() {
player.pause();
}
function stop() {
player.pause();
player.currentTime(0);
}
function toggle_play() {
if (player.paused()) {
play();
} else {
pause();
}
}
const toggle_captions = (function () { const toggle_captions = (function () {
let toggledTrack = null; let toggledTrack = null;
@ -490,9 +449,7 @@ const toggle_captions = (function () {
const tracks = player.textTracks(); const tracks = player.textTracks();
for (let i = 0; i < tracks.length; i++) { for (let i = 0; i < tracks.length; i++) {
const track = tracks[i]; const track = tracks[i];
if (track.kind !== 'captions') { if (track.kind !== 'captions') continue;
continue;
}
if (fallbackCaptionsTrack === null) { if (fallbackCaptionsTrack === null) {
fallbackCaptionsTrack = track; fallbackCaptionsTrack = track;
@ -513,11 +470,7 @@ const toggle_captions = (function () {
})(); })();
function toggle_fullscreen() { function toggle_fullscreen() {
if (player.isFullscreen()) { player.isFullscreen() ? player.exitFullscreen() : player.requestFullscreen();
player.exitFullscreen();
} else {
player.requestFullscreen();
}
} }
function increase_playback_rate(steps) { function increase_playback_rate(steps) {
@ -560,27 +513,15 @@ window.addEventListener('keydown', e => {
action = toggle_play; action = toggle_play;
break; break;
case 'MediaPlay': case 'MediaPlay': action = play; break;
action = play; case 'MediaPause': action = pause; break;
break; case 'MediaStop': action = stop; break;
case 'MediaPause':
action = pause;
break;
case 'MediaStop':
action = stop;
break;
case 'ArrowUp': case 'ArrowUp':
if (isPlayerFocused) { if (isPlayerFocused) action = increase_volume.bind(this, 0.1);
action = increase_volume.bind(this, 0.1);
}
break; break;
case 'ArrowDown': case 'ArrowDown':
if (isPlayerFocused) { if (isPlayerFocused) action = increase_volume.bind(this, -0.1);
action = increase_volume.bind(this, -0.1);
}
break; break;
case 'm': case 'm':
@ -612,16 +553,15 @@ window.addEventListener('keydown', e => {
case '7': case '7':
case '8': case '8':
case '9': case '9':
// Ignore numpad numbers
if (code > 57) break;
const percent = (code - 48) * 10; const percent = (code - 48) * 10;
action = set_time_percent.bind(this, percent); action = set_time_percent.bind(this, percent);
break; break;
case 'c': case 'c': action = toggle_captions; break;
action = toggle_captions; case 'f': action = toggle_fullscreen; break;
break;
case 'f':
action = toggle_fullscreen;
break;
case 'N': case 'N':
case 'MediaTrackNext': case 'MediaTrackNext':
@ -639,12 +579,8 @@ window.addEventListener('keydown', e => {
// TODO: Add support for previous-frame-stepping. // TODO: Add support for previous-frame-stepping.
break; break;
case '>': case '>': action = increase_playback_rate.bind(this, 1); break;
action = increase_playback_rate.bind(this, 1); case '<': action = increase_playback_rate.bind(this, -1); break;
break;
case '<':
action = increase_playback_rate.bind(this, -1);
break;
default: default:
console.info('Unhandled key down event: %s:', decoratedKey, e); console.info('Unhandled key down event: %s:', decoratedKey, e);

@ -94,7 +94,7 @@
"preferences_related_videos_label": "Show related videos: ", "preferences_related_videos_label": "Show related videos: ",
"preferences_annotations_label": "Show annotations by default: ", "preferences_annotations_label": "Show annotations by default: ",
"preferences_extend_desc_label": "Automatically extend video description: ", "preferences_extend_desc_label": "Automatically extend video description: ",
"preferences_vr_mode_label": "Interactive 360 degree videos: ", "preferences_vr_mode_label": "Interactive 360 degree videos (requires WebGL): ",
"preferences_category_visual": "Visual preferences", "preferences_category_visual": "Visual preferences",
"preferences_region_label": "Content country: ", "preferences_region_label": "Content country: ",
"preferences_player_style_label": "Player style: ", "preferences_player_style_label": "Player style: ",
@ -236,6 +236,8 @@
"No such user": "No such user", "No such user": "No such user",
"Token is expired, please try again": "Token is expired, please try again", "Token is expired, please try again": "Token is expired, please try again",
"English": "English", "English": "English",
"English (United Kingdom)": "English (United Kingdom)",
"English (United States)": "English (United States)",
"English (auto-generated)": "English (auto-generated)", "English (auto-generated)": "English (auto-generated)",
"Afrikaans": "Afrikaans", "Afrikaans": "Afrikaans",
"Albanian": "Albanian", "Albanian": "Albanian",
@ -249,23 +251,31 @@
"Bosnian": "Bosnian", "Bosnian": "Bosnian",
"Bulgarian": "Bulgarian", "Bulgarian": "Bulgarian",
"Burmese": "Burmese", "Burmese": "Burmese",
"Cantonese (Hong Kong)": "Cantonese (Hong Kong)",
"Catalan": "Catalan", "Catalan": "Catalan",
"Cebuano": "Cebuano", "Cebuano": "Cebuano",
"Chinese": "Chinese",
"Chinese (China)": "Chinese (China)",
"Chinese (Hong Kong)": "Chinese (Hong Kong)",
"Chinese (Simplified)": "Chinese (Simplified)", "Chinese (Simplified)": "Chinese (Simplified)",
"Chinese (Taiwan)": "Chinese (Taiwan)",
"Chinese (Traditional)": "Chinese (Traditional)", "Chinese (Traditional)": "Chinese (Traditional)",
"Corsican": "Corsican", "Corsican": "Corsican",
"Croatian": "Croatian", "Croatian": "Croatian",
"Czech": "Czech", "Czech": "Czech",
"Danish": "Danish", "Danish": "Danish",
"Dutch": "Dutch", "Dutch": "Dutch",
"Dutch (auto-generated)": "Dutch (auto-generated)",
"Esperanto": "Esperanto", "Esperanto": "Esperanto",
"Estonian": "Estonian", "Estonian": "Estonian",
"Filipino": "Filipino", "Filipino": "Filipino",
"Finnish": "Finnish", "Finnish": "Finnish",
"French": "French", "French": "French",
"French (auto-generated)": "French (auto-generated)",
"Galician": "Galician", "Galician": "Galician",
"Georgian": "Georgian", "Georgian": "Georgian",
"German": "German", "German": "German",
"German (auto-generated)": "German (auto-generated)",
"Greek": "Greek", "Greek": "Greek",
"Gujarati": "Gujarati", "Gujarati": "Gujarati",
"Haitian Creole": "Haitian Creole", "Haitian Creole": "Haitian Creole",
@ -278,14 +288,19 @@
"Icelandic": "Icelandic", "Icelandic": "Icelandic",
"Igbo": "Igbo", "Igbo": "Igbo",
"Indonesian": "Indonesian", "Indonesian": "Indonesian",
"Indonesian (auto-generated)": "Indonesian (auto-generated)",
"Interlingue": "Interlingue",
"Irish": "Irish", "Irish": "Irish",
"Italian": "Italian", "Italian": "Italian",
"Italian (auto-generated)": "Italian (auto-generated)",
"Japanese": "Japanese", "Japanese": "Japanese",
"Japanese (auto-generated)": "Japanese (auto-generated)",
"Javanese": "Javanese", "Javanese": "Javanese",
"Kannada": "Kannada", "Kannada": "Kannada",
"Kazakh": "Kazakh", "Kazakh": "Kazakh",
"Khmer": "Khmer", "Khmer": "Khmer",
"Korean": "Korean", "Korean": "Korean",
"Korean (auto-generated)": "Korean (auto-generated)",
"Kurdish": "Kurdish", "Kurdish": "Kurdish",
"Kyrgyz": "Kyrgyz", "Kyrgyz": "Kyrgyz",
"Lao": "Lao", "Lao": "Lao",
@ -308,9 +323,12 @@
"Persian": "Persian", "Persian": "Persian",
"Polish": "Polish", "Polish": "Polish",
"Portuguese": "Portuguese", "Portuguese": "Portuguese",
"Portuguese (auto-generated)": "Portuguese (auto-generated)",
"Portuguese (Brazil)": "Portuguese (Brazil)",
"Punjabi": "Punjabi", "Punjabi": "Punjabi",
"Romanian": "Romanian", "Romanian": "Romanian",
"Russian": "Russian", "Russian": "Russian",
"Russian (auto-generated)": "Russian (auto-generated)",
"Samoan": "Samoan", "Samoan": "Samoan",
"Scottish Gaelic": "Scottish Gaelic", "Scottish Gaelic": "Scottish Gaelic",
"Serbian": "Serbian", "Serbian": "Serbian",
@ -322,7 +340,10 @@
"Somali": "Somali", "Somali": "Somali",
"Southern Sotho": "Southern Sotho", "Southern Sotho": "Southern Sotho",
"Spanish": "Spanish", "Spanish": "Spanish",
"Spanish (auto-generated)": "Spanish (auto-generated)",
"Spanish (Latin America)": "Spanish (Latin America)", "Spanish (Latin America)": "Spanish (Latin America)",
"Spanish (Mexico)": "Spanish (Mexico)",
"Spanish (Spain)": "Spanish (Spain)",
"Sundanese": "Sundanese", "Sundanese": "Sundanese",
"Swahili": "Swahili", "Swahili": "Swahili",
"Swedish": "Swedish", "Swedish": "Swedish",
@ -331,10 +352,12 @@
"Telugu": "Telugu", "Telugu": "Telugu",
"Thai": "Thai", "Thai": "Thai",
"Turkish": "Turkish", "Turkish": "Turkish",
"Turkish (auto-generated)": "Turkish (auto-generated)",
"Ukrainian": "Ukrainian", "Ukrainian": "Ukrainian",
"Urdu": "Urdu", "Urdu": "Urdu",
"Uzbek": "Uzbek", "Uzbek": "Uzbek",
"Vietnamese": "Vietnamese", "Vietnamese": "Vietnamese",
"Vietnamese (auto-generated)": "Vietnamese (auto-generated)",
"Welsh": "Welsh", "Welsh": "Welsh",
"Western Frisian": "Western Frisian", "Western Frisian": "Western Frisian",
"Xhosa": "Xhosa", "Xhosa": "Xhosa",

@ -114,16 +114,18 @@ LOGGER = Invidious::LogHandler.new(OUTPUT, CONFIG.log_level)
# Check table integrity # Check table integrity
Invidious::Database.check_integrity(CONFIG) Invidious::Database.check_integrity(CONFIG)
# Resolve player dependencies. This is done at compile time. {% if !flag?(:skip_videojs_download) %}
# # Resolve player dependencies. This is done at compile time.
# 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? # 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" %}
{% if flag?(:minified_player_dependencies) %} {% puts "\nChecking player dependencies...\n" %}
{% puts run("../scripts/fetch-player-dependencies.cr", "--minified").stringify %} {% if flag?(:minified_player_dependencies) %}
{% else %} {% puts run("../scripts/fetch-player-dependencies.cr", "--minified").stringify %}
{% puts run("../scripts/fetch-player-dependencies.cr").stringify %} {% else %}
{% puts run("../scripts/fetch-player-dependencies.cr").stringify %}
{% end %}
{% end %} {% end %}
# Start jobs # Start jobs

@ -1,8 +1,12 @@
# Exception used to hold the name of the missing item # Exception used to hold the name of the missing item
# Should be used in all parsing functions # Should be used in all parsing functions
class BrokenTubeException < InfoException class BrokenTubeException < Exception
getter element : String getter element : String
def initialize(@element) def initialize(@element)
end end
def message
return "Missing JSON element \"#{@element}\""
end
end end

@ -38,12 +38,15 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce
issue_title = "#{exception.message} (#{exception.class})" issue_title = "#{exception.message} (#{exception.class})"
issue_template = %(Title: `#{issue_title}`) issue_template = <<-TEXT
issue_template += %(\nDate: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`) Title: `#{HTML.escape(issue_title)}`
issue_template += %(\nRoute: `#{env.request.resource}`) Date: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`
issue_template += %(\nVersion: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}`) Route: `#{HTML.escape(env.request.resource)}`
# issue_template += github_details("Preferences", env.get("preferences").as(Preferences).to_pretty_json) Version: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}`
issue_template += github_details("Backtrace", exception.inspect_with_backtrace)
TEXT
issue_template += github_details("Backtrace", HTML.escape(exception.inspect_with_backtrace))
# URLs for the error message below # URLs for the error message below
url_faq = "https://github.com/iv-org/documentation/blob/master/FAQ.md" url_faq = "https://github.com/iv-org/documentation/blob/master/FAQ.md"

@ -2,6 +2,8 @@ CAPTION_LANGUAGES = {
"", "",
"English", "English",
"English (auto-generated)", "English (auto-generated)",
"English (United Kingdom)",
"English (United States)",
"Afrikaans", "Afrikaans",
"Albanian", "Albanian",
"Amharic", "Amharic",
@ -14,23 +16,31 @@ CAPTION_LANGUAGES = {
"Bosnian", "Bosnian",
"Bulgarian", "Bulgarian",
"Burmese", "Burmese",
"Cantonese (Hong Kong)",
"Catalan", "Catalan",
"Cebuano", "Cebuano",
"Chinese",
"Chinese (China)",
"Chinese (Hong Kong)",
"Chinese (Simplified)", "Chinese (Simplified)",
"Chinese (Taiwan)",
"Chinese (Traditional)", "Chinese (Traditional)",
"Corsican", "Corsican",
"Croatian", "Croatian",
"Czech", "Czech",
"Danish", "Danish",
"Dutch", "Dutch",
"Dutch (auto-generated)",
"Esperanto", "Esperanto",
"Estonian", "Estonian",
"Filipino", "Filipino",
"Finnish", "Finnish",
"French", "French",
"French (auto-generated)",
"Galician", "Galician",
"Georgian", "Georgian",
"German", "German",
"German (auto-generated)",
"Greek", "Greek",
"Gujarati", "Gujarati",
"Haitian Creole", "Haitian Creole",
@ -43,14 +53,19 @@ CAPTION_LANGUAGES = {
"Icelandic", "Icelandic",
"Igbo", "Igbo",
"Indonesian", "Indonesian",
"Indonesian (auto-generated)",
"Interlingue",
"Irish", "Irish",
"Italian", "Italian",
"Italian (auto-generated)",
"Japanese", "Japanese",
"Japanese (auto-generated)",
"Javanese", "Javanese",
"Kannada", "Kannada",
"Kazakh", "Kazakh",
"Khmer", "Khmer",
"Korean", "Korean",
"Korean (auto-generated)",
"Kurdish", "Kurdish",
"Kyrgyz", "Kyrgyz",
"Lao", "Lao",
@ -73,9 +88,12 @@ CAPTION_LANGUAGES = {
"Persian", "Persian",
"Polish", "Polish",
"Portuguese", "Portuguese",
"Portuguese (auto-generated)",
"Portuguese (Brazil)",
"Punjabi", "Punjabi",
"Romanian", "Romanian",
"Russian", "Russian",
"Russian (auto-generated)",
"Samoan", "Samoan",
"Scottish Gaelic", "Scottish Gaelic",
"Serbian", "Serbian",
@ -87,7 +105,10 @@ CAPTION_LANGUAGES = {
"Somali", "Somali",
"Southern Sotho", "Southern Sotho",
"Spanish", "Spanish",
"Spanish (auto-generated)",
"Spanish (Latin America)", "Spanish (Latin America)",
"Spanish (Mexico)",
"Spanish (Spain)",
"Sundanese", "Sundanese",
"Swahili", "Swahili",
"Swedish", "Swedish",
@ -96,10 +117,12 @@ CAPTION_LANGUAGES = {
"Telugu", "Telugu",
"Thai", "Thai",
"Turkish", "Turkish",
"Turkish (auto-generated)",
"Ukrainian", "Ukrainian",
"Urdu", "Urdu",
"Uzbek", "Uzbek",
"Vietnamese", "Vietnamese",
"Vietnamese (auto-generated)",
"Welsh", "Welsh",
"Western Frisian", "Western Frisian",
"Xhosa", "Xhosa",

@ -7,7 +7,7 @@
<meta name="thumbnail" content="<%= thumbnail %>"> <meta name="thumbnail" content="<%= thumbnail %>">
<%= rendered "components/player_sources" %> <%= rendered "components/player_sources" %>
<link rel="stylesheet" href="/videojs/videojs-overlay/videojs-overlay.css?v=<%= ASSET_COMMIT %>"> <link rel="stylesheet" href="/videojs/videojs-overlay/videojs-overlay.css?v=<%= ASSET_COMMIT %>">
<script src="videojs/videojs-overlay/videojs-overlay.js?v=<%= ASSET_COMMIT %>"></script> <script src="/videojs/videojs-overlay/videojs-overlay.js?v=<%= ASSET_COMMIT %>"></script>
<link rel="stylesheet" href="/css/default.css?v=<%= ASSET_COMMIT %>"> <link rel="stylesheet" href="/css/default.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/embed.css?v=<%= ASSET_COMMIT %>"> <link rel="stylesheet" href="/css/embed.css?v=<%= ASSET_COMMIT %>">
<title><%= HTML.escape(video.title) %> - Invidious</title> <title><%= HTML.escape(video.title) %> - Invidious</title>

Loading…
Cancel
Save