Merge branch 'master' of github.com:iv-org/invidious

This commit is contained in:
テクニカル諏訪子 2021-12-28 09:41:58 +09:00
commit c9870736a8
17 changed files with 329 additions and 45 deletions

View file

@ -44,6 +44,10 @@
<a href="https://web.libera.chat/?channel=#invidious">
<img alt="Libera.chat (IRC)" src="https://img.shields.io/badge/IRC%20%28Libera.chat%29-%23invidious-darkgreen">
</a>
<br>
<a rel="me" href="https://social.tchncs.de/@invidious">
<img alt="Mastodon: @invidious@social.tchncs.de" src="https://img.shields.io/badge/Mastodon-%40invidious%40social.tchncs.de-darkgreen">
</a>
</div>

View file

@ -38,6 +38,8 @@ embed_url.searchParams.delete('v');
short_url = location.origin + '/' + video_data.id + embed_url.search;
embed_url = location.origin + '/embed/' + video_data.id + embed_url.search;
var save_player_pos_key = "save_player_pos";
var shareOptions = {
socials: ['fbFeed', 'tw', 'reddit', 'email'],
@ -199,6 +201,32 @@ if (video_data.premiere_timestamp && Math.round(new Date() / 1000) < video_data.
player.getChild('bigPlayButton').hide();
}
if (video_data.params.save_player_pos) {
const url = new URL(location);
const hasTimeParam = url.searchParams.has("t");
const remeberedTime = get_video_time();
let lastUpdated = 0;
if(!hasTimeParam) {
set_seconds_after_start(remeberedTime);
}
const updateTime = () => {
const raw = player.currentTime();
const time = Math.floor(raw);
if(lastUpdated !== time) {
save_video_time(time);
lastUpdated = time;
}
};
player.on("timeupdate", updateTime);
}
else {
remove_all_video_times();
}
if (video_data.params.autoplay) {
var bpb = player.getChild('bigPlayButton');
bpb.hide();
@ -330,6 +358,55 @@ function skip_seconds(delta) {
player.currentTime(newTime);
}
function set_seconds_after_start(delta) {
const start = video_data.params.video_start;
player.currentTime(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);
}
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 {
return 0;
}
}
function set_all_video_times(times) {
const json = JSON.stringify(times);
localStorage.setItem(save_player_pos_key, json);
}
function get_all_video_times() {
try {
const raw = localStorage.getItem(save_player_pos_key);
const times = JSON.parse(raw);
return times || {};
}
catch {
return {};
}
}
function remove_all_video_times() {
localStorage.removeItem(save_player_pos_key);
}
function set_time_percent(percent) {
const duration = player.duration();
const newTime = duration * (percent / 100);

View file

@ -433,5 +433,33 @@
"footer_documentation": "التوثيق",
"footer_donate_page": "تبرّع",
"preferences_region_label": "بلد المحتوى:. ",
"preferences_quality_dash_label": "جودة فيديو DASH المفضلة: "
"preferences_quality_dash_label": "جودة فيديو DASH المفضلة: ",
"preferences_quality_option_dash": "DASH (جودة تكييفية)",
"preferences_quality_option_hd720": "HD720",
"preferences_quality_option_medium": "متوسطة",
"preferences_quality_option_small": "صغيرة",
"preferences_quality_dash_option_auto": "تلقائي",
"preferences_quality_dash_option_best": "الأفضل",
"preferences_quality_dash_option_worst": "أسوأ",
"preferences_quality_dash_option_4320p": "4320p",
"preferences_quality_dash_option_2160p": "2160p",
"preferences_quality_dash_option_1440p": "1440p",
"preferences_quality_dash_option_1080p": "1080p",
"preferences_quality_dash_option_720p": "720p",
"preferences_quality_dash_option_480p": "480p",
"preferences_quality_dash_option_360p": "360p",
"preferences_quality_dash_option_240p": "240p",
"preferences_quality_dash_option_144p": "144p",
"purchased": "تم شراؤها",
"none": "لاشيء",
"videoinfo_started_streaming_x_ago": "بدأ البث منذ `x`",
"videoinfo_watch_on_youTube": "مشاهدة على يوتيوب",
"videoinfo_youTube_embed_link": "مضمن",
"videoinfo_invidious_embed_link": "رابط مضمن",
"user_created_playlists": "'x' إنشاء قوائم التشغيل",
"user_saved_playlists": "قوائم التشغيل المحفوظة 'x'",
"Video unavailable": "الفيديو غير متوفر",
"360": "360°",
"download_subtitles": "ترجمات - 'x' (.vtt)",
"invidious": "الخيالي"
}

View file

@ -461,5 +461,6 @@
"download_subtitles": "Subtitles - `x` (.vtt)",
"user_created_playlists": "`x` created playlists",
"user_saved_playlists": "`x` saved playlists",
"Video unavailable": "Video unavailable"
"Video unavailable": "Video unavailable",
"preferences_save_player_pos_label": "Save the current video time: "
}

View file

@ -433,5 +433,33 @@
"footer_modfied_source_code": "Código fuente modificado",
"footer_donate_page": "Donar",
"preferences_region_label": "País del contenido: ",
"preferences_quality_dash_label": "Calidad de vídeo DASH preferida: "
"preferences_quality_dash_label": "Calidad de vídeo DASH preferida: ",
"preferences_quality_option_hd720": "HD720",
"preferences_quality_option_medium": "Intermedia",
"preferences_quality_dash_option_auto": "Automática",
"none": "ninguno",
"videoinfo_started_streaming_x_ago": "Comenzó difusión hace `x`",
"download_subtitles": "Subtítulos- `x` (.vtt)",
"user_created_playlists": "`x` listas de reproducción creadas",
"user_saved_playlists": "`x` listas de reproducción guardadas",
"Video unavailable": "Vídeo no disponible",
"videoinfo_youTube_embed_link": "Embeber",
"preferences_quality_dash_option_2160p": "2160p",
"preferences_quality_dash_option_4320p": "4320p",
"invidious": "Invidious",
"preferences_quality_dash_option_480p": "480p",
"preferences_quality_option_dash": "DASH (calidad adaptativa)",
"preferences_quality_dash_option_720p": "720p",
"preferences_quality_dash_option_360p": "360p",
"preferences_quality_dash_option_240p": "240p",
"preferences_quality_dash_option_144p": "144p",
"preferences_quality_option_small": "Pequeña",
"preferences_quality_dash_option_1440p": "1440p",
"preferences_quality_dash_option_best": "La mejor",
"preferences_quality_dash_option_worst": "La peor",
"videoinfo_invidious_embed_link": "Enlace para Embeber",
"preferences_quality_dash_option_1080p": "1080p",
"purchased": "Comprado",
"360": "360°",
"videoinfo_watch_on_youTube": "Ver en YouTube"
}

View file

@ -433,5 +433,33 @@
"long": "Longue (> 20 minutes)",
"adminprefs_modified_source_code_url_label": "URL du dépôt du code source modifié",
"footer_documentation": "Documentation",
"footer_original_source_code": "Code source original"
"footer_original_source_code": "Code source original",
"preferences_quality_option_medium": "Moyenne",
"preferences_quality_option_small": "Petite",
"preferences_quality_dash_option_auto": "Auto",
"preferences_quality_dash_option_best": "La plus haute",
"preferences_quality_dash_option_worst": "La plus basse",
"preferences_quality_dash_option_4320p": "4320p",
"preferences_quality_dash_option_2160p": "2160p",
"preferences_quality_dash_option_720p": "720p",
"preferences_quality_dash_option_480p": "480p",
"preferences_quality_dash_option_360p": "360p",
"preferences_quality_dash_option_240p": "240p",
"preferences_quality_dash_option_144p": "144p",
"invidious": "Invidious",
"360": "360°",
"none": "aucun",
"videoinfo_started_streaming_x_ago": "En stream depuis `x`",
"videoinfo_watch_on_youTube": "Regarder sur YouTube",
"videoinfo_youTube_embed_link": "Intégrer",
"purchased": "Acheter",
"videoinfo_invidious_embed_link": "Lien intégré",
"download_subtitles": "Sous-titres - `x` (.vtt)",
"user_saved_playlists": "`x` listes de lecture sauvegardées",
"Video unavailable": "Vidéo non disponible",
"preferences_quality_option_hd720": "HD720",
"preferences_quality_option_dash": "DASH (qualité adaptative)",
"preferences_quality_dash_option_1440p": "1440p",
"preferences_quality_dash_option_1080p": "1080p",
"user_created_playlists": "`x` listes de lecture créées"
}

View file

@ -433,5 +433,33 @@
"footer_modfied_source_code": "Kode sumber yang dimodifikasi",
"footer_documentation": "Dokumentasi",
"preferences_region_label": "Konten dari negara: ",
"preferences_quality_dash_label": "Kualitas video DASH yang disukai: "
"preferences_quality_dash_label": "Kualitas video DASH yang disukai: ",
"preferences_quality_option_medium": "Medium",
"preferences_quality_option_small": "Rendah",
"preferences_quality_dash_option_best": "Terbaik",
"preferences_quality_dash_option_worst": "Terburuk",
"preferences_quality_dash_option_4320p": "4320p",
"preferences_quality_dash_option_2160p": "2160p",
"preferences_quality_dash_option_1080p": "1080p",
"preferences_quality_dash_option_720p": "720p",
"preferences_quality_dash_option_360p": "360p",
"preferences_quality_dash_option_240p": "240p",
"preferences_quality_dash_option_144p": "144p",
"invidious": "Invidious",
"purchased": "Dibeli",
"360": "360°",
"none": "tidak ada",
"videoinfo_watch_on_youTube": "Tonton di YouTube",
"videoinfo_youTube_embed_link": "Tersemat",
"videoinfo_invidious_embed_link": "Tautan Tersemat",
"download_subtitles": "Takarir- `x` (.vtt)",
"user_saved_playlists": "`x` daftar putar yang disimpan",
"videoinfo_started_streaming_x_ago": "Mulai siaran `x` yang lalu",
"user_created_playlists": "`x` daftar putar yang dibuat",
"preferences_quality_option_dash": "DASH (kualitas adaptif)",
"preferences_quality_option_hd720": "HD720",
"preferences_quality_dash_option_1440p": "1440p",
"preferences_quality_dash_option_auto": "Otomatis",
"preferences_quality_dash_option_480p": "480p",
"Video unavailable": "Video tidak tersedia"
}

View file

@ -433,5 +433,21 @@
"long": "20 分以上",
"preferences_region_label": "地域: ",
"footer_donate_page": "寄付する",
"preferences_quality_dash_label": "優先するDash画質 : "
"preferences_quality_dash_label": "優先するDash画質 : ",
"preferences_quality_dash_option_4320p": "4320p",
"preferences_quality_dash_option_240p": "240p",
"preferences_quality_dash_option_144p": "144p",
"preferences_quality_option_hd720": "HD720",
"preferences_quality_option_medium": "中",
"preferences_quality_option_small": "小",
"invidious": "Invidious",
"preferences_quality_dash_option_auto": "自動",
"preferences_quality_dash_option_720p": "720p",
"preferences_quality_dash_option_360p": "360p",
"preferences_quality_dash_option_2160p": "2160p",
"preferences_quality_dash_option_1080p": "1080p",
"preferences_quality_dash_option_1440p": "1440p",
"preferences_quality_dash_option_480p": "480p",
"videoinfo_youTube_embed_link": "埋め込み",
"videoinfo_invidious_embed_link": "埋め込みリンク"
}

View file

@ -453,7 +453,7 @@
"none": "intet",
"videoinfo_watch_on_youTube": "Se på YouTube",
"videoinfo_youTube_embed_link": "Bak inn",
"videoinfo_invidious_embed_link": "Bak in lenke",
"videoinfo_invidious_embed_link": "Bak inn lenke",
"download_subtitles": "Undertekster - `x` (.vtt)",
"user_created_playlists": "`x` spillelister opprettet",
"user_saved_playlists": "`x` spillelister lagret",

View file

@ -433,5 +433,33 @@
"adminprefs_modified_source_code_url_label": "Değiştirilmiş kaynak kodları deposunun URL'si",
"footer_donate_page": "Bağış yap",
"preferences_region_label": "İçerik ülkesi: ",
"preferences_quality_dash_label": "Tercih edilen DASH video kalitesi: "
"preferences_quality_dash_label": "Tercih edilen DASH video kalitesi: ",
"preferences_quality_option_hd720": "HD720",
"preferences_quality_dash_option_best": "En iyi",
"preferences_quality_dash_option_worst": "En kötü",
"preferences_quality_dash_option_4320p": "4320p",
"preferences_quality_dash_option_2160p": "2160p",
"preferences_quality_dash_option_480p": "480p",
"preferences_quality_dash_option_360p": "360p",
"preferences_quality_dash_option_240p": "240p",
"preferences_quality_dash_option_144p": "144p",
"invidious": "Invidious",
"none": "yok",
"videoinfo_started_streaming_x_ago": "`x` önce yayına başladı",
"videoinfo_youTube_embed_link": "Göm",
"videoinfo_invidious_embed_link": "Bağlantıyı Göm",
"user_created_playlists": "`x` oluşturulan oynatma listeleri",
"user_saved_playlists": "`x` kaydedilen oynatma listeleri",
"preferences_quality_option_small": "Küçük",
"preferences_quality_dash_option_720p": "720p",
"preferences_quality_option_medium": "Orta",
"preferences_quality_dash_option_1440p": "1440p",
"preferences_quality_dash_option_1080p": "1080p",
"Video unavailable": "Video kullanılamıyor",
"preferences_quality_option_dash": "DASH (uyarlanabilir kalite)",
"preferences_quality_dash_option_auto": "Otomatik",
"purchased": "Satın alınan",
"360": "360°",
"videoinfo_watch_on_youTube": "YouTube'da izle",
"download_subtitles": "Alt yazılar - `x` (.vtt)"
}

View file

@ -433,5 +433,33 @@
"adminprefs_modified_source_code_url_label": "修改後的原始碼倉庫 URL",
"footer_donate_page": "捐款",
"preferences_region_label": "內容國家: ",
"preferences_quality_dash_label": "偏好的 DASH 影片品質: "
"preferences_quality_dash_label": "偏好的 DASH 影片品質: ",
"preferences_quality_option_hd720": "HD720",
"preferences_quality_dash_option_worst": "最差",
"preferences_quality_dash_option_4320p": "4320p",
"preferences_quality_dash_option_2160p": "2160p",
"preferences_quality_dash_option_1440p": "1440p",
"preferences_quality_dash_option_1080p": "1080p",
"preferences_quality_dash_option_720p": "720p",
"preferences_quality_dash_option_480p": "480p",
"preferences_quality_dash_option_360p": "360p",
"preferences_quality_dash_option_240p": "240p",
"preferences_quality_dash_option_144p": "144p",
"invidious": "Invidious",
"purchased": "已購買",
"360": "360°",
"none": "無",
"videoinfo_started_streaming_x_ago": "`x` 前開始串流",
"videoinfo_watch_on_youTube": "在 YouTube 上觀看",
"videoinfo_youTube_embed_link": "嵌入",
"videoinfo_invidious_embed_link": "嵌入連結",
"download_subtitles": "字幕 - `x` (.vtt)",
"user_created_playlists": "`x` 已建立的播放清單",
"user_saved_playlists": "`x` 已儲存的播放清單",
"Video unavailable": "影片不可用",
"preferences_quality_option_small": "小",
"preferences_quality_option_dash": "DASH主動調整品質",
"preferences_quality_option_medium": "中等",
"preferences_quality_dash_option_auto": "自動",
"preferences_quality_dash_option_best": "最佳"
}

View file

@ -42,6 +42,7 @@ struct ConfigPreferences
property volume : Int32 = 100
property vr_mode : Bool = true
property show_nick : Bool = true
property save_player_pos : Bool = false
def to_tuple
{% begin %}

View file

@ -1,43 +1,43 @@
# "bn_BD" => load_locale("bn_BD"), # Bengali (Bangladesh) [Incomplete]
# "eu" => load_locale("eu"), # Basque [Incomplete]
# "sk" => load_locale("sk"), # Slovak [Incomplete]
# "sr" => load_locale("sr"), # Serbian [Incomplete]
# "sr_Cyrl" => load_locale("sr_Cyrl"), # Serbian (cyrillic) [Incomplete]
LOCALES_LIST = {
"ar" => "العربية", # Arabic
"cs" => "Čeština", # Czech
"da" => "Dansk", # Danish
"de" => "Deutsch", # German
"el" => "Ελληνικά", # Greek
"en-US" => "English", # English
"eo" => "Esperanto", # Esperanto
"es" => "Español", # Spanish
"fa" => "فارسی", # Persian
"fi" => "Suomi", # Finnish
"fr" => "Français", # French
"he" => "עברית", # Hebrew
"hr" => "Hrvatski", # Croatian
"hu-HU" => "Magyar Nyelv", # Hungarian
"id" => "Bahasa Indonesia", # Indonesian
"is" => "Íslenska", # Icelandic
"it" => "Italiano", # Italian
"ja" => "日本語", # Japanese
"ko" => "한국어", # Korean
"lt" => "Lietuvių", # Lithuanian
"nb-NO" => "Norsk bokmål", # Norwegian Bokmål
"nl" => "Nederlands", # Dutch
"pl" => "Polski", # Polish
"pt" => "Português", # Portuguese
"pt-BR" => "Português Brasileiro", # Portuguese (Brazil)
"pt-PT" => "Português de Portugal", # Portuguese (Portugal)
"ro" => "Română", # Romanian
"ru" => "русский", # Russian
"sv-SE" => "Svenska", # Swedish
"tr" => "Türkçe", # Turkish
"uk" => "Українська", # Ukrainian
"vi" => "Tiếng Việt", # Vietnamese
"zh-CN" => "汉语", # Chinese (Simplified)
"zh-TW" => "漢語", # Chinese (Traditional)
"ar" => "العربية", # Arabic
"cs" => "Čeština", # Czech
"da" => "Dansk", # Danish
"de" => "Deutsch", # German
"el" => "Ελληνικά", # Greek
"en-US" => "English", # English
"eo" => "Esperanto", # Esperanto
"es" => "Español", # Spanish
"fa" => "فارسی", # Persian
"fi" => "Suomi", # Finnish
"fr" => "Français", # French
"he" => "עברית", # Hebrew
"hr" => "Hrvatski", # Croatian
"hu-HU" => "Magyar Nyelv", # Hungarian
"id" => "Bahasa Indonesia", # Indonesian
"is" => "Íslenska", # Icelandic
"it" => "Italiano", # Italian
"ja" => "日本語", # Japanese
"ko" => "한국어", # Korean
"lt" => "Lietuvių", # Lithuanian
"nb-NO" => "Norsk bokmål", # Norwegian Bokmål
"nl" => "Nederlands", # Dutch
"pl" => "Polski", # Polish
"pt" => "Português", # Portuguese
"pt-BR" => "Português Brasileiro", # Portuguese (Brazil)
"pt-PT" => "Português de Portugal", # Portuguese (Portugal)
"ro" => "Română", # Romanian
"ru" => "русский", # Russian
"sr" => "srpski (latinica)", # Serbian (Latin)
"sr_Cyrl" => "српски (ћирилица)", # Serbian (Cyrillic)
"sv-SE" => "Svenska", # Swedish
"tr" => "Türkçe", # Turkish
"uk" => "Українська", # Ukrainian
"vi" => "Tiếng Việt", # Vietnamese
"zh-CN" => "汉语", # Chinese (Simplified)
"zh-TW" => "漢語", # Chinese (Traditional)
}
LOCALES = load_all_locales()

View file

@ -70,6 +70,10 @@ module Invidious::Routes::PreferencesRoute
vr_mode ||= "off"
vr_mode = vr_mode == "on"
save_player_pos = env.params.body["save_player_pos"]?.try &.as(String)
save_player_pos ||= "off"
save_player_pos = save_player_pos == "on"
show_nick = env.params.body["show_nick"]?.try &.as(String)
show_nick ||= "off"
show_nick = show_nick == "on"
@ -165,6 +169,7 @@ module Invidious::Routes::PreferencesRoute
extend_desc: extend_desc,
vr_mode: vr_mode,
show_nick: show_nick,
save_player_pos: save_player_pos,
}.to_json).to_json
if user = env.get? "user"

View file

@ -53,6 +53,7 @@ struct Preferences
property video_loop : Bool = CONFIG.default_user_preferences.video_loop
property extend_desc : Bool = CONFIG.default_user_preferences.extend_desc
property volume : Int32 = CONFIG.default_user_preferences.volume
property save_player_pos : Bool = CONFIG.default_user_preferences.save_player_pos
module BoolToString
def self.to_json(value : String, json : JSON::Builder)

View file

@ -246,6 +246,7 @@ struct VideoPreferences
property video_start : Float64 | Int32
property volume : Int32
property vr_mode : Bool
property save_player_pos : Bool
end
struct Video
@ -1090,6 +1091,7 @@ def process_video_params(query, preferences)
extend_desc = query["extend_desc"]?.try { |q| (q == "true" || q == "1").to_unsafe }
volume = query["volume"]?.try &.to_i?
vr_mode = query["vr_mode"]?.try { |q| (q == "true" || q == "1").to_unsafe }
save_player_pos = query["save_player_pos"]?.try { |q| (q == "true" || q == "1").to_unsafe }
if preferences
# region ||= preferences.region
@ -1110,6 +1112,7 @@ def process_video_params(query, preferences)
extend_desc ||= preferences.extend_desc.to_unsafe
volume ||= preferences.volume
vr_mode ||= preferences.vr_mode.to_unsafe
save_player_pos ||= preferences.save_player_pos.to_unsafe
end
annotations ||= CONFIG.default_user_preferences.annotations.to_unsafe
@ -1129,6 +1132,7 @@ def process_video_params(query, preferences)
extend_desc ||= CONFIG.default_user_preferences.extend_desc.to_unsafe
volume ||= CONFIG.default_user_preferences.volume
vr_mode ||= CONFIG.default_user_preferences.vr_mode.to_unsafe
save_player_pos ||= CONFIG.default_user_preferences.save_player_pos.to_unsafe
annotations = annotations == 1
autoplay = autoplay == 1
@ -1140,6 +1144,7 @@ def process_video_params(query, preferences)
video_loop = video_loop == 1
extend_desc = extend_desc == 1
vr_mode = vr_mode == 1
save_player_pos = save_player_pos == 1
if CONFIG.disabled?("dash") && quality == "dash"
quality = "high"
@ -1190,6 +1195,7 @@ def process_video_params(query, preferences)
video_start: video_start,
volume: volume,
vr_mode: vr_mode,
save_player_pos: save_player_pos,
})
return params

View file

@ -116,6 +116,11 @@
<input name="vr_mode" id="vr_mode" type="checkbox" <% if preferences.vr_mode %>checked<% end %>>
</div>
<div class="pure-control-group">
<label for="save_player_pos"><%= translate(locale, "preferences_save_player_pos_label") %></label>
<input name="save_player_pos" id="save_player_pos" type="checkbox" <% if preferences.save_player_pos %>checked<% end %>>
</div>
<legend><%= translate(locale, "preferences_category_visual") %></legend>
<div class="pure-control-group">