Skip to content

Commit e2fc642

Browse files
authored
Merge pull request #2874 from SamantazFox/small-fixes
Small fixes
2 parents 170e754 + ec55b90 commit e2fc642

File tree

9 files changed

+115
-123
lines changed

9 files changed

+115
-123
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ test:
6262
crystal spec
6363

6464
verify:
65-
crystal build src/invidious.cr --no-codegen --progress --stats --error-trace
65+
crystal build src/invidious.cr -Dskip_videojs_download \
66+
--no-codegen --progress --stats --error-trace
6667

6768

6869
# -----------------------

assets/js/handlers.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@
150150

151151
// Ignore shortcuts if any text input is focused
152152
let focused_tag = document.activeElement.tagName.toLowerCase();
153-
let focused_type = document.activeElement.type.toLowerCase();
154-
let allowed = /^(button|checkbox|file|radio|submit)$/;
153+
const allowed = /^(button|checkbox|file|radio|submit)$/;
155154

156-
if (focused_tag === "textarea" ||
157-
(focused_tag === "input" && !focused_type.match(allowed))
158-
)
159-
return;
155+
if (focused_tag === "textarea") return;
156+
if (focused_tag === "input") {
157+
let focused_type = document.activeElement.type.toLowerCase();
158+
if (!focused_type.match(allowed)) return;
159+
}
160160

161161
// Focus search bar on '/'
162162
if (event.key == "/") {

assets/js/player.js

Lines changed: 33 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,19 @@ videojs.Vhs.xhr.beforeRequest = function(options) {
6060
var player = videojs('player', options);
6161

6262
const storage = (() => {
63-
try {
64-
if (localStorage.length !== -1) {
65-
return localStorage;
66-
}
67-
} catch (e) {
68-
console.info('No storage available: ' + e);
69-
}
63+
try { if (localStorage.length !== -1) return localStorage; }
64+
catch (e) { console.info('No storage available: ' + e); }
65+
7066
return undefined;
7167
})();
7268

7369
if (location.pathname.startsWith('/embed/')) {
70+
var overlay_content = '<h1><a rel="noopener" target="_blank" href="' + location.origin + '/watch?v=' + video_data.id + '">' + player_data.title + '</a></h1>';
7471
player.overlay({
75-
overlays: [{
76-
start: 'loadstart',
77-
content: '<h1><a rel="noopener" target="_blank" href="' + location.origin + '/watch?v=' + video_data.id + '">' + player_data.title + '</a></h1>',
78-
end: 'playing',
79-
align: 'top'
80-
}, {
81-
start: 'pause',
82-
content: '<h1><a rel="noopener" target="_blank" href="' + location.origin + '/watch?v=' + video_data.id + '">' + player_data.title + '</a></h1>',
83-
end: 'playing',
84-
align: 'top'
85-
}]
72+
overlays: [
73+
{ start: 'loadstart', content: overlay_content, end: 'playing', align: 'top'},
74+
{ start: 'pause', content: overlay_content, end: 'playing', align: 'top'}
75+
]
8676
});
8777
}
8878

@@ -99,9 +89,7 @@ if (isMobile()) {
9989

10090
buttons = ["playToggle", "volumePanel", "captionsButton"];
10191

102-
if (video_data.params.quality !== 'dash') {
103-
buttons.push("qualitySelector")
104-
}
92+
if (video_data.params.quality !== 'dash') buttons.push("qualitySelector")
10593

10694
// Create new control bar object for operation buttons
10795
const ControlBar = videojs.getComponent("controlBar");
@@ -146,16 +134,12 @@ player.on('error', function (event) {
146134

147135
player.load();
148136

149-
if (currentTime > 0.5) {
150-
currentTime -= 0.5;
151-
}
137+
if (currentTime > 0.5) currentTime -= 0.5;
152138

153139
player.currentTime(currentTime);
154140
player.playbackRate(playbackRate);
155141

156-
if (!paused) {
157-
player.play();
158-
}
142+
if (!paused) player.play();
159143
}, 5000);
160144
}
161145
});
@@ -183,13 +167,8 @@ if (video_data.params.video_start > 0 || video_data.params.video_end > 0) {
183167

184168
player.markers({
185169
onMarkerReached: function (marker) {
186-
if (marker.text === 'End') {
187-
if (player.loop()) {
188-
player.markers.prev('Start');
189-
} else {
190-
player.pause();
191-
}
192-
}
170+
if (marker.text === 'End')
171+
player.loop() ? player.markers.prev('Start') : player.pause();
193172
},
194173
markers: markers
195174
});
@@ -217,9 +196,7 @@ if (video_data.params.save_player_pos) {
217196
const remeberedTime = get_video_time();
218197
let lastUpdated = 0;
219198

220-
if(!hasTimeParam) {
221-
set_seconds_after_start(remeberedTime);
222-
}
199+
if(!hasTimeParam) set_seconds_after_start(remeberedTime);
223200

224201
const updateTime = () => {
225202
const raw = player.currentTime();
@@ -233,9 +210,7 @@ if (video_data.params.save_player_pos) {
233210

234211
player.on("timeupdate", updateTime);
235212
}
236-
else {
237-
remove_all_video_times();
238-
}
213+
else remove_all_video_times();
239214

240215
if (video_data.params.autoplay) {
241216
var bpb = player.getChild('bigPlayButton');
@@ -433,26 +408,10 @@ function set_time_percent(percent) {
433408
player.currentTime(newTime);
434409
}
435410

436-
function play() {
437-
player.play();
438-
}
439-
440-
function pause() {
441-
player.pause();
442-
}
443-
444-
function stop() {
445-
player.pause();
446-
player.currentTime(0);
447-
}
448-
449-
function toggle_play() {
450-
if (player.paused()) {
451-
play();
452-
} else {
453-
pause();
454-
}
455-
}
411+
function play() { player.play(); }
412+
function pause() { player.pause(); }
413+
function stop() { player.pause(); player.currentTime(0); }
414+
function toggle_play() { player.paused() ? play() : pause(); }
456415

457416
const toggle_captions = (function () {
458417
let toggledTrack = null;
@@ -490,9 +449,7 @@ const toggle_captions = (function () {
490449
const tracks = player.textTracks();
491450
for (let i = 0; i < tracks.length; i++) {
492451
const track = tracks[i];
493-
if (track.kind !== 'captions') {
494-
continue;
495-
}
452+
if (track.kind !== 'captions') continue;
496453

497454
if (fallbackCaptionsTrack === null) {
498455
fallbackCaptionsTrack = track;
@@ -513,11 +470,7 @@ const toggle_captions = (function () {
513470
})();
514471

515472
function toggle_fullscreen() {
516-
if (player.isFullscreen()) {
517-
player.exitFullscreen();
518-
} else {
519-
player.requestFullscreen();
520-
}
473+
player.isFullscreen() ? player.exitFullscreen() : player.requestFullscreen();
521474
}
522475

523476
function increase_playback_rate(steps) {
@@ -560,27 +513,15 @@ window.addEventListener('keydown', e => {
560513
action = toggle_play;
561514
break;
562515

563-
case 'MediaPlay':
564-
action = play;
565-
break;
566-
567-
case 'MediaPause':
568-
action = pause;
569-
break;
570-
571-
case 'MediaStop':
572-
action = stop;
573-
break;
516+
case 'MediaPlay': action = play; break;
517+
case 'MediaPause': action = pause; break;
518+
case 'MediaStop': action = stop; break;
574519

575520
case 'ArrowUp':
576-
if (isPlayerFocused) {
577-
action = increase_volume.bind(this, 0.1);
578-
}
521+
if (isPlayerFocused) action = increase_volume.bind(this, 0.1);
579522
break;
580523
case 'ArrowDown':
581-
if (isPlayerFocused) {
582-
action = increase_volume.bind(this, -0.1);
583-
}
524+
if (isPlayerFocused) action = increase_volume.bind(this, -0.1);
584525
break;
585526

586527
case 'm':
@@ -612,16 +553,15 @@ window.addEventListener('keydown', e => {
612553
case '7':
613554
case '8':
614555
case '9':
556+
// Ignore numpad numbers
557+
if (code > 57) break;
558+
615559
const percent = (code - 48) * 10;
616560
action = set_time_percent.bind(this, percent);
617561
break;
618562

619-
case 'c':
620-
action = toggle_captions;
621-
break;
622-
case 'f':
623-
action = toggle_fullscreen;
624-
break;
563+
case 'c': action = toggle_captions; break;
564+
case 'f': action = toggle_fullscreen; break;
625565

626566
case 'N':
627567
case 'MediaTrackNext':
@@ -639,12 +579,8 @@ window.addEventListener('keydown', e => {
639579
// TODO: Add support for previous-frame-stepping.
640580
break;
641581

642-
case '>':
643-
action = increase_playback_rate.bind(this, 1);
644-
break;
645-
case '<':
646-
action = increase_playback_rate.bind(this, -1);
647-
break;
582+
case '>': action = increase_playback_rate.bind(this, 1); break;
583+
case '<': action = increase_playback_rate.bind(this, -1); break;
648584

649585
default:
650586
console.info('Unhandled key down event: %s:', decoratedKey, e);

locales/en-US.json

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"preferences_related_videos_label": "Show related videos: ",
9595
"preferences_annotations_label": "Show annotations by default: ",
9696
"preferences_extend_desc_label": "Automatically extend video description: ",
97-
"preferences_vr_mode_label": "Interactive 360 degree videos: ",
97+
"preferences_vr_mode_label": "Interactive 360 degree videos (requires WebGL): ",
9898
"preferences_category_visual": "Visual preferences",
9999
"preferences_region_label": "Content country: ",
100100
"preferences_player_style_label": "Player style: ",
@@ -236,6 +236,8 @@
236236
"No such user": "No such user",
237237
"Token is expired, please try again": "Token is expired, please try again",
238238
"English": "English",
239+
"English (United Kingdom)": "English (United Kingdom)",
240+
"English (United States)": "English (United States)",
239241
"English (auto-generated)": "English (auto-generated)",
240242
"Afrikaans": "Afrikaans",
241243
"Albanian": "Albanian",
@@ -249,23 +251,31 @@
249251
"Bosnian": "Bosnian",
250252
"Bulgarian": "Bulgarian",
251253
"Burmese": "Burmese",
254+
"Cantonese (Hong Kong)": "Cantonese (Hong Kong)",
252255
"Catalan": "Catalan",
253256
"Cebuano": "Cebuano",
257+
"Chinese": "Chinese",
258+
"Chinese (China)": "Chinese (China)",
259+
"Chinese (Hong Kong)": "Chinese (Hong Kong)",
254260
"Chinese (Simplified)": "Chinese (Simplified)",
261+
"Chinese (Taiwan)": "Chinese (Taiwan)",
255262
"Chinese (Traditional)": "Chinese (Traditional)",
256263
"Corsican": "Corsican",
257264
"Croatian": "Croatian",
258265
"Czech": "Czech",
259266
"Danish": "Danish",
260267
"Dutch": "Dutch",
268+
"Dutch (auto-generated)": "Dutch (auto-generated)",
261269
"Esperanto": "Esperanto",
262270
"Estonian": "Estonian",
263271
"Filipino": "Filipino",
264272
"Finnish": "Finnish",
265273
"French": "French",
274+
"French (auto-generated)": "French (auto-generated)",
266275
"Galician": "Galician",
267276
"Georgian": "Georgian",
268277
"German": "German",
278+
"German (auto-generated)": "German (auto-generated)",
269279
"Greek": "Greek",
270280
"Gujarati": "Gujarati",
271281
"Haitian Creole": "Haitian Creole",
@@ -278,14 +288,19 @@
278288
"Icelandic": "Icelandic",
279289
"Igbo": "Igbo",
280290
"Indonesian": "Indonesian",
291+
"Indonesian (auto-generated)": "Indonesian (auto-generated)",
292+
"Interlingue": "Interlingue",
281293
"Irish": "Irish",
282294
"Italian": "Italian",
295+
"Italian (auto-generated)": "Italian (auto-generated)",
283296
"Japanese": "Japanese",
297+
"Japanese (auto-generated)": "Japanese (auto-generated)",
284298
"Javanese": "Javanese",
285299
"Kannada": "Kannada",
286300
"Kazakh": "Kazakh",
287301
"Khmer": "Khmer",
288302
"Korean": "Korean",
303+
"Korean (auto-generated)": "Korean (auto-generated)",
289304
"Kurdish": "Kurdish",
290305
"Kyrgyz": "Kyrgyz",
291306
"Lao": "Lao",
@@ -308,9 +323,12 @@
308323
"Persian": "Persian",
309324
"Polish": "Polish",
310325
"Portuguese": "Portuguese",
326+
"Portuguese (auto-generated)": "Portuguese (auto-generated)",
327+
"Portuguese (Brazil)": "Portuguese (Brazil)",
311328
"Punjabi": "Punjabi",
312329
"Romanian": "Romanian",
313330
"Russian": "Russian",
331+
"Russian (auto-generated)": "Russian (auto-generated)",
314332
"Samoan": "Samoan",
315333
"Scottish Gaelic": "Scottish Gaelic",
316334
"Serbian": "Serbian",
@@ -322,7 +340,10 @@
322340
"Somali": "Somali",
323341
"Southern Sotho": "Southern Sotho",
324342
"Spanish": "Spanish",
343+
"Spanish (auto-generated)": "Spanish (auto-generated)",
325344
"Spanish (Latin America)": "Spanish (Latin America)",
345+
"Spanish (Mexico)": "Spanish (Mexico)",
346+
"Spanish (Spain)": "Spanish (Spain)",
326347
"Sundanese": "Sundanese",
327348
"Swahili": "Swahili",
328349
"Swedish": "Swedish",
@@ -331,10 +352,12 @@
331352
"Telugu": "Telugu",
332353
"Thai": "Thai",
333354
"Turkish": "Turkish",
355+
"Turkish (auto-generated)": "Turkish (auto-generated)",
334356
"Ukrainian": "Ukrainian",
335357
"Urdu": "Urdu",
336358
"Uzbek": "Uzbek",
337359
"Vietnamese": "Vietnamese",
360+
"Vietnamese (auto-generated)": "Vietnamese (auto-generated)",
338361
"Welsh": "Welsh",
339362
"Western Frisian": "Western Frisian",
340363
"Xhosa": "Xhosa",

src/invidious.cr

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,18 @@ LOGGER = Invidious::LogHandler.new(OUTPUT, CONFIG.log_level)
114114
# Check table integrity
115115
Invidious::Database.check_integrity(CONFIG)
116116

117-
# Resolve player dependencies. This is done at compile time.
118-
#
119-
# Running the script by itself would show some colorful feedback while this doesn't.
120-
# Perhaps we should just move the script to runtime in order to get that feedback?
121-
122-
{% puts "\nChecking player dependencies...\n" %}
123-
{% if flag?(:minified_player_dependencies) %}
124-
{% puts run("../scripts/fetch-player-dependencies.cr", "--minified").stringify %}
125-
{% else %}
126-
{% puts run("../scripts/fetch-player-dependencies.cr").stringify %}
117+
{% if !flag?(:skip_videojs_download) %}
118+
# Resolve player dependencies. This is done at compile time.
119+
#
120+
# Running the script by itself would show some colorful feedback while this doesn't.
121+
# Perhaps we should just move the script to runtime in order to get that feedback?
122+
123+
{% puts "\nChecking player dependencies...\n" %}
124+
{% if flag?(:minified_player_dependencies) %}
125+
{% puts run("../scripts/fetch-player-dependencies.cr", "--minified").stringify %}
126+
{% else %}
127+
{% puts run("../scripts/fetch-player-dependencies.cr").stringify %}
128+
{% end %}
127129
{% end %}
128130

129131
# Start jobs

0 commit comments

Comments
 (0)