From 7bcff627f85af2e431502fcd2ea83f9b146352c8 Mon Sep 17 00:00:00 2001 From: epicsam123 <92618898+epicsam123@users.noreply.github.com> Date: Thu, 6 Feb 2025 00:30:29 -0500 Subject: [PATCH] include youtube links setting --- assets/js/player.js | 15 ++++++---- assets/js/watch.js | 2 +- config/config.example.yml | 14 ++++++++++ locales/ar.json | 1 + locales/bg.json | 1 + locales/ca.json | 1 + locales/cs.json | 1 + locales/da.json | 1 + locales/de.json | 1 + locales/el.json | 1 + locales/en-US.json | 1 + locales/eo.json | 1 + locales/es.json | 1 + locales/eu.json | 1 + locales/fa.json | 1 + locales/fi.json | 1 + locales/fr.json | 1 + locales/hi.json | 1 + locales/hr.json | 1 + locales/hu-HU.json | 1 + locales/id.json | 1 + locales/is.json | 1 + locales/it.json | 1 + locales/ja.json | 1 + locales/ko.json | 1 + locales/lmo.json | 1 + locales/lt.json | 1 + locales/nb-NO.json | 1 + locales/nl.json | 1 + locales/pl.json | 1 + locales/pt-BR.json | 1 + locales/pt-PT.json | 1 + locales/pt.json | 1 + locales/ro.json | 1 + locales/ru.json | 1 + locales/sl.json | 1 + locales/sq.json | 1 + locales/sr.json | 1 + locales/sr_Cyrl.json | 1 + locales/sv-SE.json | 1 + locales/tr.json | 1 + locales/uk.json | 1 + locales/vi.json | 1 + locales/zh-CN.json | 1 + locales/zh-TW.json | 1 + src/invidious/channels/community.cr | 12 ++++---- src/invidious/comments/youtube.cr | 8 +++--- src/invidious/config.cr | 1 + src/invidious/frontend/comments_youtube.cr | 24 ++++++++-------- src/invidious/helpers/errors.cr | 12 +++++++- src/invidious/routes/api/v1/channels.cr | 9 ++++-- src/invidious/routes/api/v1/videos.cr | 3 +- src/invidious/routes/channels.cr | 11 ++++---- src/invidious/routes/preferences.cr | 5 ++++ src/invidious/routes/watch.cr | 14 ++++++---- src/invidious/user/preferences.cr | 1 + src/invidious/views/community.ecr | 2 +- .../views/components/channel_info.ecr | 9 ++++-- .../components/video-context-buttons.ecr | 9 ++++-- src/invidious/views/playlist.ecr | 20 +++++++------ src/invidious/views/post.ecr | 2 +- src/invidious/views/privacy.ecr | 2 +- src/invidious/views/user/data_control.ecr | 2 +- src/invidious/views/user/preferences.ecr | 5 ++++ src/invidious/views/watch.ecr | 28 ++++++++++--------- 65 files changed, 176 insertions(+), 76 deletions(-) diff --git a/assets/js/player.js b/assets/js/player.js index 353a5296..aa6c51c5 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -136,11 +136,14 @@ player.on('timeupdate', function () { let elem_yt_watch = document.getElementById('link-yt-watch'); let elem_yt_embed = document.getElementById('link-yt-embed'); - let base_url_yt_watch = elem_yt_watch.getAttribute('data-base-url'); - let base_url_yt_embed = elem_yt_embed.getAttribute('data-base-url'); - - elem_yt_watch.href = addCurrentTimeToURL(base_url_yt_watch); - elem_yt_embed.href = addCurrentTimeToURL(base_url_yt_embed); + // YT links could be turned off by the user + if (elem_yt_watch) { + let base_url_yt_watch = elem_yt_watch.getAttribute('data-base-url'); + let base_url_yt_embed = elem_yt_embed.getAttribute('data-base-url'); + + elem_yt_watch.href = addCurrentTimeToURL(base_url_yt_watch); + elem_yt_embed.href = addCurrentTimeToURL(base_url_yt_embed); + } // Invidious links @@ -174,7 +177,7 @@ var shareOptions = { }; if (location.pathname.startsWith('/embed/')) { - var overlay_content = '

' + player_data.title + '

'; + var overlay_content = '

' + player_data.title + '

'; player.overlay({ overlays: [ { start: 'loadstart', content: overlay_content, end: 'playing', align: 'top'}, diff --git a/assets/js/watch.js b/assets/js/watch.js index d869d40d..ee9c29e8 100644 --- a/assets/js/watch.js +++ b/assets/js/watch.js @@ -141,7 +141,7 @@ function get_reddit_comments() { \

\ \ - {redditPermalinkText} \ + {redditPermalinkText} \ \ \
{contentHtml}
\ diff --git a/config/config.example.yml b/config/config.example.yml index bc2deda5..cccd3c8c 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -938,6 +938,20 @@ default_user_preferences: ## #automatic_instance_redirect: false + ## + ## Display YouTube redirect links on pages where they are provided. + ## - Watch on Youtube (video page) + ## - [YT] Comment link (comments) + ## - After which you should try to page (error page) + ## - watch on youtube button (search results page) + ## - View channel on YouTube (channel page) + ## - View playlist on YouTube (playlist page) + ## + ## Accepted values: true, false + ## Default: true + ## + #include_youtube_links: true + ## ## Show the entire video description by default (when set to 'false', ## only the first few lines of the description are shown and a diff --git a/locales/ar.json b/locales/ar.json index b6bab59b..dcc2596a 100644 --- a/locales/ar.json +++ b/locales/ar.json @@ -73,6 +73,7 @@ "preferences_thin_mode_label": "الوضع الخفيف: ", "preferences_category_misc": "تفضيلات متنوعة", "preferences_automatic_instance_redirect_label": "إعادة توجيه المثيل التلقائي (إعادة التوجيه إلى redirect.invidious.io): ", + "preferences_include_youtube_links_label": "عرض روابط إعادة التوجيه على يوتيوب: ", "preferences_category_subscription": "تفضيلات الاشتراك", "preferences_annotations_subscribed_label": "عرض الملاحظات في الفيديوهات تلقائيا في القنوات المشترك بها فقط: ", "Redirect homepage to feed: ": "إعادة التوجية من الصفحة الرئيسية لصفحة المشتركين (لرؤية اخر فيديوهات المشتركين): ", diff --git a/locales/bg.json b/locales/bg.json index baa683c9..bdf6b103 100644 --- a/locales/bg.json +++ b/locales/bg.json @@ -445,6 +445,7 @@ "source": "източник", "Fallback comments: ": "Резервни коментари: ", "preferences_automatic_instance_redirect_label": "Автоматично препращане на инстанция (чрез redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Покажете пренасочващите връзки на YouTube: ", "Maori": "Маори", "generic_button_delete": "Изтрий", "Import YouTube playlist (.csv)": "Импортиране на YouTube плейлист (.csv)", diff --git a/locales/ca.json b/locales/ca.json index bbcadf89..740fa1bc 100644 --- a/locales/ca.json +++ b/locales/ca.json @@ -140,6 +140,7 @@ "Default": "Per defecte", "Amharic": "Amàric", "preferences_automatic_instance_redirect_label": "Redirecció automàtica d'instàncies (retorna a redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Mostra els enllaços de redirecció de YouTube: ", "Login enabled: ": "Activa inici de sessió: ", "Registration enabled: ": "Activa registre: ", "Whitelisted regions: ": "Regions a la llista blanca: ", diff --git a/locales/cs.json b/locales/cs.json index 6e66178d..3d82aec0 100644 --- a/locales/cs.json +++ b/locales/cs.json @@ -422,6 +422,7 @@ "Erroneous CAPTCHA": "Chybná CAPTCHA", "Password is a required field": "Heslo je vyžadované pole", "preferences_automatic_instance_redirect_label": "Automatické přesměrování instance (fallback na redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Zobrazit přesměrovací odkazy na YouTube: ", "Switch Invidious Instance": "Přepnout instanci Invidious", "Empty playlist": "Prázdný playlist", "footer_source_code": "Zdrojový kód", diff --git a/locales/da.json b/locales/da.json index 9cbb446a..b4fbf2ed 100644 --- a/locales/da.json +++ b/locales/da.json @@ -289,6 +289,7 @@ "Dutch": "Hollandsk", "Estonian": "Estisk", "preferences_automatic_instance_redirect_label": "Automatisk eksempel omdirigering (Fallback til redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Vis YouTube-omdirigeringslinks: ", "Nepali": "Nepalesisk", "Norwegian Bokmål": "Norsk Bokmål", "(edited)": "(ændret)", diff --git a/locales/de.json b/locales/de.json index 151f2abe..bda33925 100644 --- a/locales/de.json +++ b/locales/de.json @@ -74,6 +74,7 @@ "preferences_thin_mode_label": "Schlanker Modus: ", "preferences_category_misc": "Sonstige Einstellungen", "preferences_automatic_instance_redirect_label": "Automatische Instanzweiterleitung (über redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Zeige YouTube-Weiterleitungslinks: ", "preferences_category_subscription": "Abonnementeinstellungen", "preferences_annotations_subscribed_label": "Anmerkungen für abonnierte Kanäle standardmäßig anzeigen? ", "Redirect homepage to feed: ": "Startseite zu Feed umleiten: ", diff --git a/locales/el.json b/locales/el.json index 38550458..c4dfe912 100644 --- a/locales/el.json +++ b/locales/el.json @@ -481,6 +481,7 @@ "error_video_not_in_playlist": "Το αιτούμενο βίντεο δεν υπάρχει στη δεδομένη λίστα αναπαραγωγής. Πατήστε εδώ για επιστροφή στη κεντρική σελίδα λιστών αναπαραγωγής.", "search_filters_duration_option_none": "Οποιαδήποτε διάρκεια", "preferences_automatic_instance_redirect_label": "Αυτόματη ανακατεύθυνση instance (εναλλακτική σε redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Εμφάνιση συνδέσμων ανακατεύθυνσης YouTube: ", "generic_button_delete": "Διαγραφή", "Import YouTube playlist (.csv)": "Εισαγωγή λίστας αναπαραγωγής YouTube (.csv)", "Switch Invidious Instance": "Αλλαγή Instance Invidious", diff --git a/locales/en-US.json b/locales/en-US.json index c23f6bc3..299eeb29 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -118,6 +118,7 @@ "preferences_thin_mode_label": "Thin mode: ", "preferences_category_misc": "Miscellaneous preferences", "preferences_automatic_instance_redirect_label": "Automatic instance redirection (fallback to redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Show YouTube redirect links: ", "preferences_category_subscription": "Subscription preferences", "preferences_annotations_subscribed_label": "Show annotations by default for subscribed channels? ", "Redirect homepage to feed: ": "Redirect homepage to feed: ", diff --git a/locales/eo.json b/locales/eo.json index 7276c890..cd60e951 100644 --- a/locales/eo.json +++ b/locales/eo.json @@ -73,6 +73,7 @@ "preferences_thin_mode_label": "Maldika reĝimo: ", "preferences_category_misc": "Aliaj agordoj", "preferences_automatic_instance_redirect_label": "Aŭtomata alidirektado de nodo (retropaŝo al redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Montri YouTube-retebligajn ligilojn: ", "preferences_category_subscription": "Abonaj agordoj", "preferences_annotations_subscribed_label": "Ĉu montri prinotojn defaŭlte por abonitaj kanaloj? ", "Redirect homepage to feed: ": "Alidirekti hejmpâgon al fluo: ", diff --git a/locales/es.json b/locales/es.json index fda29198..3dee435b 100644 --- a/locales/es.json +++ b/locales/es.json @@ -73,6 +73,7 @@ "preferences_thin_mode_label": "Modo compacto: ", "preferences_category_misc": "Preferencias misceláneas", "preferences_automatic_instance_redirect_label": "Redirección automática de instancia (segunda opción a redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Mostrar enlaces de redirección de YouTube: ", "preferences_category_subscription": "Preferencias de la suscripción", "preferences_annotations_subscribed_label": "¿Mostrar anotaciones por defecto para los canales suscritos? ", "Redirect homepage to feed: ": "Redirigir la página de inicio a la fuente: ", diff --git a/locales/eu.json b/locales/eu.json index fbca537b..29a41723 100644 --- a/locales/eu.json +++ b/locales/eu.json @@ -200,6 +200,7 @@ "preferences_category_data": "Dataren lehentasunak", "preferences_default_home_label": "Homepage lehenetsia: ", "preferences_automatic_instance_redirect_label": "berbideratze adibide automatikoa (atzera egin berbideratzeko: invidious.io) ", + "preferences_include_youtube_links_label": "Erakutsi YouTubeko birbideratze estekak ", "`x` uploaded a video": "' x'(e)k bideo bat igo du", "published - reverse": "argitaratuta - alderantziz", "Could not get channel info.": "Kanalaren adierazpena ezin lortu.", diff --git a/locales/fa.json b/locales/fa.json index b146385e..449943fc 100644 --- a/locales/fa.json +++ b/locales/fa.json @@ -83,6 +83,7 @@ "preferences_thin_mode_label": "حالت نازک: ", "preferences_category_misc": "ترجیحات متفرقه", "preferences_automatic_instance_redirect_label": "هدایت خودکار نمونه (انتقال به redirect.invidious.io): ", + "preferences_include_youtube_links_label": "نمایش لینک‌های ریدایرکت یوتیوب: ", "preferences_category_subscription": "ترجیحات اشتراک", "preferences_annotations_subscribed_label": "نمایش حاشیه نویسی ها به طور پیشفرض برای کانال های مشترک شده: ", "Redirect homepage to feed: ": "تغییر مسیر صفحه خانه به خوراک: ", diff --git a/locales/fi.json b/locales/fi.json index b0df1e46..fa96342a 100644 --- a/locales/fi.json +++ b/locales/fi.json @@ -73,6 +73,7 @@ "preferences_thin_mode_label": "Kapea tila: ", "preferences_category_misc": "Sekalaiset asetukset", "preferences_automatic_instance_redirect_label": "Automaattinen instanssin uudelleenohjaus (perääntyminen sivulle redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Näytä YouTuben uudelleenohjauslinkit: ", "preferences_category_subscription": "Tilausten asetukset", "preferences_annotations_subscribed_label": "Näytä oletuksena tilattujen kanavien huomautukset: ", "Redirect homepage to feed: ": "Uudelleenohjaa kotisivu syötteeseen: ", diff --git a/locales/fr.json b/locales/fr.json index 6147a159..14c77dec 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -96,6 +96,7 @@ "preferences_thin_mode_label": "Mode léger : ", "preferences_category_misc": "Paramètres divers", "preferences_automatic_instance_redirect_label": "Redirection automatique vers une autre instance (via redirect.invidious.io) : ", + "preferences_include_youtube_links_label": "Afficher les liens de redirection YouTube : ", "preferences_category_subscription": "Préférences des abonnements", "preferences_annotations_subscribed_label": "Afficher les annotations par défaut sur les chaînes auxquelles vous êtes abonnés : ", "Redirect homepage to feed: ": "Rediriger la page d'accueil vers la page d'abonnements : ", diff --git a/locales/hi.json b/locales/hi.json index 0a1c09dd..46a30d8f 100644 --- a/locales/hi.json +++ b/locales/hi.json @@ -130,6 +130,7 @@ "preferences_thin_mode_label": "हल्का मोड: ", "preferences_category_misc": "विविध प्राथमिकताएँ", "preferences_automatic_instance_redirect_label": "अपने आप अनुप्रेषित करें (redirect.invidious.io पर फ़ॉलबैक करें): ", + "preferences_include_youtube_links_label": "यूट्यूब रीडायरेक्ट लिंक दिखाएं: ", "preferences_category_subscription": "सदस्यताओं की प्राथमिकताएँ", "preferences_annotations_subscribed_label": "सदस्यता लिए गए चैनलों पर डिफ़ॉल्ट से टिप्पणियाँ दिखाएँ? ", "Redirect homepage to feed: ": "फ़ीड पर मुखपृष्ठ को अनुप्रेषित करें: ", diff --git a/locales/hr.json b/locales/hr.json index 7b76a41f..a8bf0ac1 100644 --- a/locales/hr.json +++ b/locales/hr.json @@ -73,6 +73,7 @@ "preferences_thin_mode_label": "Pojednostavljen prikaz: ", "preferences_category_misc": "Razne postavke", "preferences_automatic_instance_redirect_label": "Automatsko preusmjeravanje instance (u krajnjem slučaju će se koristiti redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Prikaži YouTube preusmjeravajuće linkove: ", "preferences_category_subscription": "Postavke pretplata", "preferences_annotations_subscribed_label": "Standardno prikaži napomene za pretplaćene kanale: ", "Redirect homepage to feed: ": "Preusmjeri početnu stranicu na feed: ", diff --git a/locales/hu-HU.json b/locales/hu-HU.json index 8fbdd82f..ede14318 100644 --- a/locales/hu-HU.json +++ b/locales/hu-HU.json @@ -388,6 +388,7 @@ "footer_modfied_source_code": "Módosított forráskód", "adminprefs_modified_source_code_url_label": "A módosított forráskód repositoryjának URL-je:", "preferences_automatic_instance_redirect_label": "Váltáskor másik Invidious oldal automatikus betöltése (redirect.invidious.io töltődik, ha nem működne): ", + "preferences_include_youtube_links_label": "Mutassa a YouTube átirányító linkeket: ", "preferences_region_label": "Ország tartalmainak mutatása: ", "search_filters_sort_option_relevance": "Relevancia", "search_filters_sort_option_rating": "Pontszám", diff --git a/locales/id.json b/locales/id.json index 4c6e8548..813d94d8 100644 --- a/locales/id.json +++ b/locales/id.json @@ -78,6 +78,7 @@ "preferences_thin_mode_label": "Mode tipis: ", "preferences_category_misc": "Preferensi lainnya", "preferences_automatic_instance_redirect_label": "Pengalihan peladen otomatis (balik kembali ke redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Tampilkan tautan pengalihan YouTube: ", "preferences_category_subscription": "Preferensi langganan", "preferences_annotations_subscribed_label": "Tampilkan anotasi secara baku untuk kanal yang dilanggan? ", "Redirect homepage to feed: ": "Arahkan kembali laman beranda ke umpan: ", diff --git a/locales/is.json b/locales/is.json index 9d13c5cf..babf1a48 100644 --- a/locales/is.json +++ b/locales/is.json @@ -460,6 +460,7 @@ "preferences_quality_option_small": "Lítið", "preferences_category_misc": "Ýmsar kjörstillingar", "preferences_automatic_instance_redirect_label": "Sjálfvirk endurbeining tilvika (farið til vara á redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Sýna YouTube umleiðingartengla: ", "Portuguese (auto-generated)": "Portúgalska (sjálfvirkt útbúið)", "Portuguese (Brazil)": "Portúgalska (Brasilía)", "generic_button_edit": "Breyta", diff --git a/locales/it.json b/locales/it.json index 309adb13..5f81c931 100644 --- a/locales/it.json +++ b/locales/it.json @@ -411,6 +411,7 @@ "download_subtitles": "Sottotitoli - `x` (.vtt)", "user_saved_playlists": "playlist salvate da `x`", "preferences_automatic_instance_redirect_label": "Reindirizzamento automatico dell'istanza (ripiego su redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Mostra i link di reindirizzamento di YouTube: ", "Video unavailable": "Video non disponibile", "preferences_show_nick_label": "Mostra nickname in alto: ", "videoinfo_youTube_embed_link": "Incorpora", diff --git a/locales/ja.json b/locales/ja.json index 7fc9d604..40db80d8 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -78,6 +78,7 @@ "preferences_thin_mode_label": "最小モード: ", "preferences_category_misc": "ほかの設定", "preferences_automatic_instance_redirect_label": "インスタンスの自動転送 (redirect.invidious.ioにフォールバック): ", + "preferences_include_youtube_links_label": "YouTubeのリダイレクトリンクを表示する: ", "preferences_category_subscription": "登録チャンネル設定", "preferences_annotations_subscribed_label": "最初から登録チャンネルのアノテーションを表示 ", "Redirect homepage to feed: ": "ホームからフィードにリダイレクト: ", diff --git a/locales/ko.json b/locales/ko.json index 4864860a..11d0a4bf 100644 --- a/locales/ko.json +++ b/locales/ko.json @@ -5,6 +5,7 @@ "preferences_annotations_subscribed_label": "구독한 채널에 기본으로 주석 표시: ", "preferences_category_subscription": "구독 설정", "preferences_automatic_instance_redirect_label": "자동 인스턴스 리디렉션 (redirect.invidious.io로 대체): ", + "preferences_include_youtube_links_label": "YouTube 리디렉션 링크 표시: ", "preferences_thin_mode_label": "단순 모드: ", "light": "라이트", "dark": "다크", diff --git a/locales/lmo.json b/locales/lmo.json index 9d2fe2a8..a0d6b0de 100644 --- a/locales/lmo.json +++ b/locales/lmo.json @@ -191,6 +191,7 @@ "preferences_dark_mode_label": "Tema: ", "preferences_thin_mode_label": "Modalità legera: ", "preferences_automatic_instance_redirect_label": "Reindirizazzion automatega de la instansa (rivèrt a redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Mostra i link de reindirizzament de YouTube: ", "Hide annotations": "Piaca le notazioni", "Show annotations": "Mostra le notazioni", "Family friendly? ": "Adàt a tüti? ", diff --git a/locales/lt.json b/locales/lt.json index 740be7b6..26e17b1c 100644 --- a/locales/lt.json +++ b/locales/lt.json @@ -73,6 +73,7 @@ "preferences_thin_mode_label": "Sugretintas rėžimas: ", "preferences_category_misc": "Įvairios nuostatos", "preferences_automatic_instance_redirect_label": "Automatinis šaltinio nukreipimas (atsarginis nukreipimas į redirect.Invidous.io): ", + "preferences_include_youtube_links_label": "Rodyti YouTube nukreipimo nuorodas: ", "preferences_category_subscription": "Prenumeratų nuostatos", "preferences_annotations_subscribed_label": "Prenumeruojamiems kanalams subtitrus rodyti pagal nutylėjimą: ", "Redirect homepage to feed: ": "Peradresuoti pagrindinį puslapį į kanalų sąrašą: ", diff --git a/locales/nb-NO.json b/locales/nb-NO.json index 17d64baf..5a5a2343 100644 --- a/locales/nb-NO.json +++ b/locales/nb-NO.json @@ -73,6 +73,7 @@ "preferences_thin_mode_label": "Tynt modus: ", "preferences_category_misc": "Ulike innstillinger", "preferences_automatic_instance_redirect_label": "Automatisk instansomdirigering (faller tilbake til redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Vis YouTube-omdirigeringslenker: ", "preferences_category_subscription": "Abonnementsinnstillinger", "preferences_annotations_subscribed_label": "Vis merknader som forvalg for kanaler det abonneres på? ", "Redirect homepage to feed: ": "Videresend hjemmeside til kilde: ", diff --git a/locales/nl.json b/locales/nl.json index f10b3593..4f70d235 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -344,6 +344,7 @@ "Current version: ": "Huidige versie: ", "Switch Invidious Instance": "Schakel tussen de Invidious Instanties", "preferences_automatic_instance_redirect_label": "Automatische instantie-omleiding (terugval naar redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Toon YouTube-omleidingslinks: ", "preferences_quality_dash_label": "Gewenste DASH-videokwaliteit: ", "preferences_region_label": "Inhoud land: ", "preferences_category_misc": "Diverse voorkeuren", diff --git a/locales/pl.json b/locales/pl.json index 73d65647..b19be2e2 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -73,6 +73,7 @@ "preferences_thin_mode_label": "Tryb minimalny: ", "preferences_category_misc": "Różne preferencje", "preferences_automatic_instance_redirect_label": "Automatycznie przekierowanie instancji (powrót do redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Pokaż linki przekierowujące do YouTube: ", "preferences_category_subscription": "Preferencje subskrypcji", "preferences_annotations_subscribed_label": "Domyślnie wyświetlaj adnotacje dla subskrybowanych kanałów: ", "Redirect homepage to feed: ": "Przekieruj stronę główną do subskrybcji: ", diff --git a/locales/pt-BR.json b/locales/pt-BR.json index 1d29d2fe..b3ba60d8 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -73,6 +73,7 @@ "preferences_thin_mode_label": "Modo compacto: ", "preferences_category_misc": "Preferências diversas", "preferences_automatic_instance_redirect_label": "Redirecionamento automático de instâncias (alternativa para redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Mostrar links de redirecionamento do YouTube: ", "preferences_category_subscription": "Preferências de inscrições", "preferences_annotations_subscribed_label": "Mostrar anotações por padrão para canais inscritos? ", "Redirect homepage to feed: ": "Redirecionar página inicial para o feed: ", diff --git a/locales/pt-PT.json b/locales/pt-PT.json index f83a80a9..e50cd4f6 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -73,6 +73,7 @@ "preferences_thin_mode_label": "Modo compacto: ", "preferences_category_misc": "Preferências diversas", "preferences_automatic_instance_redirect_label": "Redirecionamento de instância automática (solução de último recurso para redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Mostrar links de redirecionamento do YouTube: ", "preferences_category_subscription": "Preferências de subscrições", "preferences_annotations_subscribed_label": "Mostrar sempre anotações aos canais subscritos: ", "Redirect homepage to feed: ": "Redirecionar página inicial para subscrições: ", diff --git a/locales/pt.json b/locales/pt.json index 0bb1be66..1b5437d4 100644 --- a/locales/pt.json +++ b/locales/pt.json @@ -10,6 +10,7 @@ "Released under the AGPLv3 on Github.": "Disponibilizada sob a AGPLv3 no GitHub.", "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_include_youtube_links_label": "Mostrar links de redirecionamento do YouTube: ", "preferences_category_misc": "Preferências diversas", "preferences_vr_mode_label": "Vídeos interativos de 360 graus (requer WebGL): ", "preferences_extend_desc_label": "Expandir automaticamente a descrição do vídeo: ", diff --git a/locales/ro.json b/locales/ro.json index ccbeef63..f19447be 100644 --- a/locales/ro.json +++ b/locales/ro.json @@ -372,6 +372,7 @@ "preferences_quality_dash_option_1080p": "1080p", "preferences_category_misc": "Setări diverse", "preferences_automatic_instance_redirect_label": "Redirecționare automată de instanță (trecere prin redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Afișați linkurile de redirecționare YouTube: ", "preferences_quality_dash_option_480p": "480p", "preferences_quality_option_medium": "Medie", "Switch Invidious Instance": "Schimbă instanța Invidious", diff --git a/locales/ru.json b/locales/ru.json index 80c98de8..024f83e3 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -73,6 +73,7 @@ "preferences_thin_mode_label": "Облегчённое оформление: ", "preferences_category_misc": "Прочие настройки", "preferences_automatic_instance_redirect_label": "Автоматическая смена зеркала (переход на redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Показать ссылки перенаправления на YouTube: ", "preferences_category_subscription": "Настройки подписок", "preferences_annotations_subscribed_label": "Всегда показывать аннотации на каналах из ваших подписок? ", "Redirect homepage to feed: ": "Показывать подписки на главной странице: ", diff --git a/locales/sl.json b/locales/sl.json index 3803d09c..58a1d8c7 100644 --- a/locales/sl.json +++ b/locales/sl.json @@ -54,6 +54,7 @@ "light": "svetla", "preferences_thin_mode_label": "Tanki način: ", "preferences_automatic_instance_redirect_label": "Samodejna preusmeritev (na redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Prikaži povezave za preusmeritev na YouTube: ", "preferences_annotations_subscribed_label": "Privzeto prikazati opombe za naročene kanale? ", "Redirect homepage to feed: ": "Preusmeri domačo stran na vir: ", "preferences_max_results_label": "Število videoposnetkov, prikazanih v viru: ", diff --git a/locales/sq.json b/locales/sq.json index ea20ce56..3936f0f9 100644 --- a/locales/sq.json +++ b/locales/sq.json @@ -87,6 +87,7 @@ "preferences_thin_mode_label": "Mënyrë e hollë: ", "preferences_category_misc": "Parapëlqime të ndryshme", "preferences_automatic_instance_redirect_label": "Ridrejtim i automatizuar i instancës (si parazgjedhje, te redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Trego lidhjet e ridrejtimit të YouTube: ", "preferences_category_subscription": "Parapëlqime pajtimesh", "preferences_annotations_subscribed_label": "Të shfaqen, si parazgjedhje, shënime për kanalet e pajtuar? ", "Redirect homepage to feed: ": "Ridrejtoje faqen hyrëse te prurje: ", diff --git a/locales/sr.json b/locales/sr.json index d28b2459..5b9937e0 100644 --- a/locales/sr.json +++ b/locales/sr.json @@ -155,6 +155,7 @@ "preferences_thin_mode_label": "Kompaktni režim: ", "preferences_category_misc": "Ostala podešavanja", "preferences_automatic_instance_redirect_label": "Automatsko preusmeravanje instance (povratak na redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Prikaži linkove za preusmeravanje na YouTube: ", "alphabetically - reverse": "abecedno - obrnuto", "Enable web notifications": "Omogući veb obaveštenja", "`x` is live": "`x` je uživo", diff --git a/locales/sr_Cyrl.json b/locales/sr_Cyrl.json index 483e7fc4..da1f1edf 100644 --- a/locales/sr_Cyrl.json +++ b/locales/sr_Cyrl.json @@ -317,6 +317,7 @@ "Released under the AGPLv3 on Github.": "Објављено под лиценцом AGPLv3 на GitHub-у.", "Afrikaans": "Африканс", "preferences_automatic_instance_redirect_label": "Аутоматско преусмеравање инстанце (повратак на redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Прикажи линкове за преусмеравање на YouTube-у: ", "Please log in": "Молимо, пријавите се", "English (auto-generated)": "Енглески (аутоматски генерисано)", "Hindi": "Хинди", diff --git a/locales/sv-SE.json b/locales/sv-SE.json index f1313a4d..9e99495d 100644 --- a/locales/sv-SE.json +++ b/locales/sv-SE.json @@ -476,6 +476,7 @@ "preferences_quality_dash_option_240p": "240p", "Chinese": "Kinesiska", "preferences_automatic_instance_redirect_label": "Automatisk instansomdirigering (återgång till redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Visa omdirigeringslänkar för YouTube: ", "generic_button_delete": "Radera", "Import YouTube playlist (.csv)": "Importera YouTube spellista (.csv)", "next_steps_error_message": "Därefter bör du försöka: ", diff --git a/locales/tr.json b/locales/tr.json index 282cbf88..f7087107 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -73,6 +73,7 @@ "preferences_thin_mode_label": "İnce Mod: ", "preferences_category_misc": "Çeşitli Tercihler", "preferences_automatic_instance_redirect_label": "Otomatik Örnek Yeniden Yönlendirmesi (Yedek: redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Youtube yönlendirme bağlantılarını göster: ", "preferences_category_subscription": "Abonelik Tercihleri", "preferences_annotations_subscribed_label": "Abone Olunan Kanallar İçin Ek Açıklamaları Öntanımlı Olarak Göster: ", "Redirect homepage to feed: ": "Ana Sayfayı Akışa Yönlendir: ", diff --git a/locales/uk.json b/locales/uk.json index 64329032..e0100e2e 100644 --- a/locales/uk.json +++ b/locales/uk.json @@ -415,6 +415,7 @@ "preferences_quality_option_hd720": "HD720", "preferences_quality_dash_option_2160p": "2160p", "preferences_automatic_instance_redirect_label": "Автоматична зміна сервера (redirect.invidious.io як резерв): ", + "preferences_include_youtube_links_label": "Показати посилання на перенаправлення YouTube: ", "Switch Invidious Instance": "Інший сервер Invidious", "preferences_quality_dash_option_480p": "480p", "Chinese (Taiwan)": "Китайська (Тайвань)", diff --git a/locales/vi.json b/locales/vi.json index 229f8fa9..69b4e020 100644 --- a/locales/vi.json +++ b/locales/vi.json @@ -75,6 +75,7 @@ "preferences_thin_mode_label": "Chế độ mỏng: ", "preferences_category_misc": "Tùy chọn khác", "preferences_automatic_instance_redirect_label": "Tự động chuyển hướng phiên bản (dự phòng về redirect.invidious.io): ", + "preferences_include_youtube_links_label": "Hiển thị liên kết chuyển hướng YouTube: ", "preferences_category_subscription": "Tùy chọn đăng ký", "preferences_annotations_subscribed_label": "Hiển thị chú thích theo mặc định cho các kênh đã đăng ký: ", "Redirect homepage to feed: ": "Chuyển hướng trang chủ đến nguồn cấp dữ liệu: ", diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 776c5ddb..c43947c8 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -78,6 +78,7 @@ "preferences_thin_mode_label": "窄页模式: ", "preferences_category_misc": "其他选项", "preferences_automatic_instance_redirect_label": "自动实例重定向 (回退到redirect.invidious.io): ", + "preferences_include_youtube_links_label": "显示YouTube重定向链接: ", "preferences_category_subscription": "订阅设置", "preferences_annotations_subscribed_label": "默认情况下显示已订阅频道的注释: ", "Redirect homepage to feed: ": "跳转主页到 feed: ", diff --git a/locales/zh-TW.json b/locales/zh-TW.json index 1e17deb6..86be3381 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -78,6 +78,7 @@ "preferences_thin_mode_label": "精簡模式: ", "preferences_category_misc": "其他偏好設定", "preferences_automatic_instance_redirect_label": "自動站台重新導向(汰退至 redirect.invidious.io): ", + "preferences_include_youtube_links_label": "顯示YouTube重定向連結: ", "preferences_category_subscription": "訂閱偏好設定", "preferences_annotations_subscribed_label": "預設為已訂閱的頻道顯示註釋: ", "Redirect homepage to feed: ": "重新導向首頁至 feed: ", diff --git a/src/invidious/channels/community.cr b/src/invidious/channels/community.cr index 49ffd990..34c9fa29 100644 --- a/src/invidious/channels/community.cr +++ b/src/invidious/channels/community.cr @@ -1,7 +1,7 @@ private IMAGE_QUALITIES = {320, 560, 640, 1280, 2000} # TODO: Add "sort_by" -def fetch_channel_community(ucid, cursor, locale, format, thin_mode) +def fetch_channel_community(ucid, cursor, locale, format, thin_mode, include_youtube_links) if cursor.nil? # Egljb21tdW5pdHk%3D is the protobuf object to load "community" initial_data = YoutubeAPI.browse(ucid, params: "Egljb21tdW5pdHk%3D") @@ -21,10 +21,10 @@ def fetch_channel_community(ucid, cursor, locale, format, thin_mode) items = container.as_a end - return extract_channel_community(items, ucid: ucid, locale: locale, format: format, thin_mode: thin_mode) + return extract_channel_community(items, ucid: ucid, locale: locale, format: format, thin_mode: thin_mode, include_youtube_links: include_youtube_links) end -def fetch_channel_community_post(ucid, post_id, locale, format, thin_mode) +def fetch_channel_community_post(ucid, post_id, locale, format, thin_mode, include_youtube_links) object = { "2:string" => "community", "25:embedded" => { @@ -47,10 +47,10 @@ def fetch_channel_community_post(ucid, post_id, locale, format, thin_mode) items << item end - return extract_channel_community(items, ucid: ucid, locale: locale, format: format, thin_mode: thin_mode, is_single_post: true) + return extract_channel_community(items, ucid: ucid, locale: locale, format: format, thin_mode: thin_mode, include_youtube_links: include_youtube_links, is_single_post: true) end -def extract_channel_community(items, *, ucid, locale, format, thin_mode, is_single_post : Bool = false) +def extract_channel_community(items, *, ucid, locale, format, thin_mode, include_youtube_links, is_single_post : Bool = false) if message = items[0]["messageRenderer"]? error_message = (message["text"]["simpleText"]? || message["text"]["runs"]?.try &.[0]?.try &.["text"]?) @@ -279,7 +279,7 @@ def extract_channel_community(items, *, ucid, locale, format, thin_mode, is_sing if format == "html" response = JSON.parse(response) - content_html = IV::Frontend::Comments.template_youtube(response, locale, thin_mode) + content_html = IV::Frontend::Comments.template_youtube(response, locale, thin_mode, include_youtube_links) response = JSON.build do |json| json.object do diff --git a/src/invidious/comments/youtube.cr b/src/invidious/comments/youtube.cr index 0716fcde..7bde9a17 100644 --- a/src/invidious/comments/youtube.cr +++ b/src/invidious/comments/youtube.cr @@ -1,7 +1,7 @@ module Invidious::Comments extend self - def fetch_youtube(id, cursor, format, locale, thin_mode, region, sort_by = "top") + def fetch_youtube(id, cursor, format, locale, thin_mode, region, include_youtube_links, sort_by = "top") case cursor when nil, "" ctoken = Comments.produce_continuation(id, cursor: "", sort_by: sort_by) @@ -13,7 +13,7 @@ module Invidious::Comments client_config = YoutubeAPI::ClientConfig.new(region: region) response = YoutubeAPI.next(continuation: ctoken, client_config: client_config) - return parse_youtube(id, response, format, locale, thin_mode, sort_by) + return parse_youtube(id, response, format, locale, thin_mode, include_youtube_links, sort_by) end def fetch_community_post_comments(ucid, post_id) @@ -57,7 +57,7 @@ module Invidious::Comments return initial_data end - def parse_youtube(id, response, format, locale, thin_mode, sort_by = "top", is_post = false) + def parse_youtube(id, response, format, locale, thin_mode, include_youtube_links, sort_by = "top", is_post = false) contents = nil if on_response_received_endpoints = response["onResponseReceivedEndpoints"]? @@ -302,7 +302,7 @@ module Invidious::Comments if format == "html" response = JSON.parse(response) - content_html = Frontend::Comments.template_youtube(response, locale, thin_mode) + content_html = Frontend::Comments.template_youtube(response, locale, thin_mode, include_youtube_links) response = JSON.build do |json| json.object do json.field "contentHtml", content_html diff --git a/src/invidious/config.cr b/src/invidious/config.cr index 4b3bdafc..27fbf42a 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -33,6 +33,7 @@ struct ConfigPreferences property default_home : String? = "Popular" property feed_menu : Array(String) = ["Popular", "Trending", "Subscriptions", "Playlists"] property automatic_instance_redirect : Bool = false + property include_youtube_links : Bool = true property region : String = "US" property related_videos : Bool = true property sort : String = "published" diff --git a/src/invidious/frontend/comments_youtube.cr b/src/invidious/frontend/comments_youtube.cr index a0e1d783..8464e5fe 100644 --- a/src/invidious/frontend/comments_youtube.cr +++ b/src/invidious/frontend/comments_youtube.cr @@ -1,7 +1,7 @@ module Invidious::Frontend::Comments extend self - def template_youtube(comments, locale, thin_mode, is_replies = false) + def template_youtube(comments, locale, thin_mode, include_youtube_links, is_replies = false) String.build do |html| root = comments["comments"].as_a root.each do |child| @@ -147,16 +147,18 @@ module Invidious::Frontend::Comments | END_HTML - if comments["videoId"]? - html << <<-END_HTML - [YT] - | - END_HTML - elsif comments["authorId"]? - html << <<-END_HTML - [YT] - | - END_HTML + if include_youtube_links + if comments["videoId"]? + html << <<-END_HTML + [YT] + | + END_HTML + elsif comments["authorId"]? + html << <<-END_HTML + [YT] + | + END_HTML + end end html << <<-END_HTML diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr index 900cb0c6..0ff87954 100644 --- a/src/invidious/helpers/errors.cr +++ b/src/invidious/helpers/errors.cr @@ -182,7 +182,7 @@ def error_redirect_helper(env : HTTP::Server::Context) go_to_youtube = translate(locale, "next_steps_error_message_go_to_youtube") switch_instance = translate(locale, "Switch Invidious Instance") - return <<-END_HTML + html = return <<-END_HTML

#{next_steps_text}

END_HTML + + return html else return "" end diff --git a/src/invidious/routes/api/v1/channels.cr b/src/invidious/routes/api/v1/channels.cr index 588bbc2a..fc6139a0 100644 --- a/src/invidious/routes/api/v1/channels.cr +++ b/src/invidious/routes/api/v1/channels.cr @@ -370,6 +370,7 @@ module Invidious::Routes::API::V1::Channels def self.community(env) locale = env.get("preferences").as(Preferences).locale + include_youtube_links = env.get("preferences").as(Preferences).include_youtube_links env.response.content_type = "application/json" @@ -385,7 +386,7 @@ module Invidious::Routes::API::V1::Channels # sort_by = env.params.query["sort_by"]?.try &.downcase begin - fetch_channel_community(ucid, continuation, locale, format, thin_mode) + fetch_channel_community(ucid, continuation, locale, format, thin_mode, include_youtube_links) rescue ex return error_json(500, ex) end @@ -393,6 +394,7 @@ module Invidious::Routes::API::V1::Channels def self.post(env) locale = env.get("preferences").as(Preferences).locale + include_youtube_links = env.get("preferences").as(Preferences).include_youtube_links env.response.content_type = "application/json" id = env.params.url["id"].to_s @@ -413,7 +415,7 @@ module Invidious::Routes::API::V1::Channels end begin - fetch_channel_community_post(ucid, id, locale, format, thin_mode) + fetch_channel_community_post(ucid, id, locale, format, thin_mode, include_youtube_links) rescue ex return error_json(500, ex) end @@ -421,6 +423,7 @@ module Invidious::Routes::API::V1::Channels def self.post_comments(env) locale = env.get("preferences").as(Preferences).locale + include_youtube_links = env.get("preferences").as(Preferences).include_youtube_links env.response.content_type = "application/json" @@ -441,7 +444,7 @@ module Invidious::Routes::API::V1::Channels else comments = YoutubeAPI.browse(continuation: continuation) end - return Comments.parse_youtube(id, comments, format, locale, thin_mode, is_post: true) + return Comments.parse_youtube(id, comments, format, locale, thin_mode, include_youtube_links, is_post: true) end def self.channels(env) diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr index 368304ac..864765e0 100644 --- a/src/invidious/routes/api/v1/videos.cr +++ b/src/invidious/routes/api/v1/videos.cr @@ -320,6 +320,7 @@ module Invidious::Routes::API::V1::Videos def self.comments(env) locale = env.get("preferences").as(Preferences).locale + include_youtube_links = env.get("preferences").as(Preferences).include_youtube_links region = env.params.query["region"]? env.response.content_type = "application/json" @@ -345,7 +346,7 @@ module Invidious::Routes::API::V1::Videos sort_by ||= "top" begin - comments = Comments.fetch_youtube(id, continuation, format, locale, thin_mode, region, sort_by: sort_by) + comments = Comments.fetch_youtube(id, continuation, format, locale, thin_mode, region, include_youtube_links, sort_by: sort_by) rescue ex : NotFoundException return error_json(404, ex) rescue ex diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index 7d634cbb..b3f28aec 100644 --- a/src/invidious/routes/channels.cr +++ b/src/invidious/routes/channels.cr @@ -212,6 +212,8 @@ module Invidious::Routes::Channels thin_mode = env.params.query["thin_mode"]? || env.get("preferences").as(Preferences).thin_mode thin_mode = thin_mode == "true" + include_youtube_links = env.get("preferences").as(Preferences).include_youtube_links + continuation = env.params.query["continuation"]? if !channel.tabs.includes? "community" @@ -223,7 +225,7 @@ module Invidious::Routes::Channels sort_options = [] of String begin - items = JSON.parse(fetch_channel_community(ucid, continuation, locale, "json", thin_mode)) + items = JSON.parse(fetch_channel_community(ucid, continuation, locale, "json", thin_mode, include_youtube_links)) rescue ex : InfoException env.response.status_code = 500 error_message = ex.message @@ -245,6 +247,7 @@ module Invidious::Routes::Channels prefs = env.get("preferences").as(Preferences) locale = prefs.locale + include_youtube_links = prefs.include_youtube_links thin_mode = env.params.query["thin_mode"]? || prefs.thin_mode thin_mode = thin_mode == "true" @@ -256,21 +259,19 @@ module Invidious::Routes::Channels if !ucid.nil? ucid = ucid.to_s - post_response = fetch_channel_community_post(ucid, id, locale, "json", thin_mode) else # resolve the url to get the author's UCID response = YoutubeAPI.resolve_url("https://www.youtube.com/post/#{id}") return error_template(400, "Invalid post ID") if response["error"]? ucid = response.dig("endpoint", "browseEndpoint", "browseId").as_s - post_response = fetch_channel_community_post(ucid, id, locale, "json", thin_mode) end - post_response = JSON.parse(post_response) + post_response = JSON.parse(fetch_channel_community_post(ucid, id, locale, "json", thin_mode, include_youtube_links)) if nojs comments = Comments.fetch_community_post_comments(ucid, id) - comment_html = JSON.parse(Comments.parse_youtube(id, comments, "html", locale, thin_mode, is_post: true))["contentHtml"] + comment_html = JSON.parse(Comments.parse_youtube(id, comments, "html", locale, thin_mode, include_youtube_links, is_post: true))["contentHtml"] end templated "post" end diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr index 39ca77c0..8e9556e0 100644 --- a/src/invidious/routes/preferences.cr +++ b/src/invidious/routes/preferences.cr @@ -114,6 +114,10 @@ module Invidious::Routes::PreferencesRoute automatic_instance_redirect ||= "off" automatic_instance_redirect = automatic_instance_redirect == "on" + include_youtube_links = env.params.body["include_youtube_links"]?.try &.as(String) + include_youtube_links ||= "off" + include_youtube_links = include_youtube_links == "on" + region = env.params.body["region"]?.try &.as(String) locale = env.params.body["locale"]?.try &.as(String) @@ -168,6 +172,7 @@ module Invidious::Routes::PreferencesRoute default_home: default_home, feed_menu: feed_menu, automatic_instance_redirect: automatic_instance_redirect, + include_youtube_links: include_youtube_links, region: region, related_videos: related_videos, sort: sort, diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr index 1f384546..4fd61f2e 100644 --- a/src/invidious/routes/watch.cr +++ b/src/invidious/routes/watch.cr @@ -2,8 +2,12 @@ module Invidious::Routes::Watch def self.handle(env) - locale = env.get("preferences").as(Preferences).locale + preferences = env.get("preferences").as(Preferences) + + locale = preferences.locale + thin_mode = preferences.thin_mode region = env.params.query["region"]? + include_youtube_links = preferences.include_youtube_links if env.params.query.to_s.includes?("%20") || env.params.query.to_s.includes?("+") url = "/watch?" + env.params.query.to_s.gsub("%20", "").delete("+") @@ -38,8 +42,6 @@ module Invidious::Routes::Watch nojs ||= "0" nojs = nojs == "1" - preferences = env.get("preferences").as(Preferences) - user = env.get?("user").try &.as(User) if user subscriptions = user.subscriptions @@ -87,7 +89,7 @@ module Invidious::Routes::Watch if source == "youtube" begin - comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, preferences.thin_mode, region))["contentHtml"] + comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, thin_mode, region, include_youtube_links))["contentHtml"] rescue ex if preferences.comments[1] == "reddit" comments, reddit_thread = Comments.fetch_reddit(id) @@ -106,12 +108,12 @@ module Invidious::Routes::Watch comment_html = Comments.replace_links(comment_html) rescue ex if preferences.comments[1] == "youtube" - comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, preferences.thin_mode, region))["contentHtml"] + comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, thin_mode, region, include_youtube_links))["contentHtml"] end end end else - comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, preferences.thin_mode, region))["contentHtml"] + comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, thin_mode, region, include_youtube_links))["contentHtml"] end comment_html ||= "" diff --git a/src/invidious/user/preferences.cr b/src/invidious/user/preferences.cr index 0a8525f3..3cc82b64 100644 --- a/src/invidious/user/preferences.cr +++ b/src/invidious/user/preferences.cr @@ -7,6 +7,7 @@ struct Preferences property preload : Bool = CONFIG.default_user_preferences.preload property autoplay : Bool = CONFIG.default_user_preferences.autoplay property automatic_instance_redirect : Bool = CONFIG.default_user_preferences.automatic_instance_redirect + property include_youtube_links : Bool = CONFIG.default_user_preferences.include_youtube_links @[JSON::Field(converter: Preferences::StringToArray)] @[YAML::Field(converter: Preferences::StringToArray)] diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr index d2a305d3..a34f3647 100644 --- a/src/invidious/views/community.ecr +++ b/src/invidious/views/community.ecr @@ -27,7 +27,7 @@ <% else %>
- <%= IV::Frontend::Comments.template_youtube(items.not_nil!, locale, thin_mode) %> + <%= IV::Frontend::Comments.template_youtube(items.not_nil!, locale, thin_mode, include_youtube_links) %>
<% end %> diff --git a/src/invidious/views/components/channel_info.ecr b/src/invidious/views/components/channel_info.ecr index f4164f31..94690ab4 100644 --- a/src/invidious/views/components/channel_info.ecr +++ b/src/invidious/views/components/channel_info.ecr @@ -36,9 +36,12 @@
- + <% if env.get("preferences").as(Preferences).include_youtube_links%> + + <% end %> + diff --git a/src/invidious/views/components/video-context-buttons.ecr b/src/invidious/views/components/video-context-buttons.ecr index 22458a03..74d90f61 100644 --- a/src/invidious/views/components/video-context-buttons.ecr +++ b/src/invidious/views/components/video-context-buttons.ecr @@ -1,8 +1,11 @@
- " rel="noreferrer noopener" href="https://www.youtube.com/watch<%=endpoint_params%>"> - - + <% if env.get("preferences").as(Preferences).include_youtube_links%> + " rel="noreferrer noopener" href="https://www.youtube.com/watch<%=endpoint_params%>"> + + + <% end %> + " href="/watch<%=endpoint_params%>&listen=1"> diff --git a/src/invidious/views/playlist.ecr b/src/invidious/views/playlist.ecr index c27ddba6..209ef015 100644 --- a/src/invidious/views/playlist.ecr +++ b/src/invidious/views/playlist.ecr @@ -83,20 +83,22 @@ <% if !playlist.is_a? InvidiousPlaylist %>
+ <% if env.get("preferences").as(Preferences).include_youtube_links%> <%= translate(locale, "View playlist on YouTube") %> | + <% end %> - <% if env.get("preferences").as(Preferences).automatic_instance_redirect%> - "> - <%= translate(locale, "Switch Invidious Instance") %> - - <% else %> - - <%= translate(locale, "Switch Invidious Instance") %> - - <% end %> + <% if env.get("preferences").as(Preferences).automatic_instance_redirect%> + "> + <%= translate(locale, "Switch Invidious Instance") %> + + <% else %> + + <%= translate(locale, "Switch Invidious Instance") %> + + <% end %>
<% end %>
diff --git a/src/invidious/views/post.ecr b/src/invidious/views/post.ecr index fb03a44c..60408a61 100644 --- a/src/invidious/views/post.ecr +++ b/src/invidious/views/post.ecr @@ -4,7 +4,7 @@
- <%= IV::Frontend::Comments.template_youtube(post_response.not_nil!, locale, thin_mode) %> + <%= IV::Frontend::Comments.template_youtube(post_response.not_nil!, locale, thin_mode, include_youtube_links) %>
<% if nojs %> diff --git a/src/invidious/views/privacy.ecr b/src/invidious/views/privacy.ecr index bc5ff40b..dd7c71c1 100644 --- a/src/invidious/views/privacy.ecr +++ b/src/invidious/views/privacy.ecr @@ -37,7 +37,7 @@ 2019-01-19 16:37:53 +00:00 200 GET /vi/r5P-f5arPXE/maxres.jpg 1085.41ms 2019-01-19 16:37:54 +00:00 200 GET /watch 7.04ms

This website does not store the visitor's user-agent or IP address and does not use fingerprinting, advertisements, or tracking of any form.

-

This website provides links to googlevideo.com to provide audio and video playback. googlevideo.com is owned by Google and is subject to their privacy policy.

+

This website provides links to googlevideo.com to provide audio and video playback. googlevideo.com is owned by Google and is subject to their privacy policy.

Data stored in your browser

This website uses browser cookies to authenticate registered users. This data consists of:

diff --git a/src/invidious/views/user/data_control.ecr b/src/invidious/views/user/data_control.ecr index 9ce42c99..e57926f5 100644 --- a/src/invidious/views/user/data_control.ecr +++ b/src/invidious/views/user/data_control.ecr @@ -14,7 +14,7 @@
diff --git a/src/invidious/views/user/preferences.ecr b/src/invidious/views/user/preferences.ecr index cf8b5593..6205c202 100644 --- a/src/invidious/views/user/preferences.ecr +++ b/src/invidious/views/user/preferences.ecr @@ -208,6 +208,11 @@ checked<% end %>>
+
+ + checked<% end %>> +
+ <% if env.get? "user" %> <%= translate(locale, "preferences_category_subscription") %> diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 6f9ced6f..8d6aaa97 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -112,20 +112,22 @@ we're going to need to do it here in order to allow for translations.
- - <%- - link_yt_watch = URI.new(scheme: "https", host: "www.youtube.com", path: "/watch", query: "v=#{video.id}") - link_yt_embed = URI.new(scheme: "https", host: "www.youtube.com", path: "/embed/#{video.id}") + <%- if env.get("preferences").as(Preferences).include_youtube_links -%> + + <%- + link_yt_watch = URI.new(scheme: "https", host: "www.youtube.com", path: "/watch", query: "v=#{video.id}") + link_yt_embed = URI.new(scheme: "https", host: "www.youtube.com", path: "/embed/#{video.id}") - if !plid.nil? && !continuation.nil? - link_yt_param = URI::Params{"list" => [plid], "index" => [continuation.to_s]} - link_yt_watch = IV::HttpServer::Utils.add_params_to_url(link_yt_watch, link_yt_param) - link_yt_embed = IV::HttpServer::Utils.add_params_to_url(link_yt_embed, link_yt_param) - end - -%> - <%= translate(locale, "videoinfo_watch_on_youTube") %> - (<%= translate(locale, "videoinfo_youTube_embed_link") %>) - + if !plid.nil? && !continuation.nil? + link_yt_param = URI::Params{"list" => [plid], "index" => [continuation.to_s]} + link_yt_watch = IV::HttpServer::Utils.add_params_to_url(link_yt_watch, link_yt_param) + link_yt_embed = IV::HttpServer::Utils.add_params_to_url(link_yt_embed, link_yt_param) + end + -%> + <%= translate(locale, "videoinfo_watch_on_youTube") %> + (<%= translate(locale, "videoinfo_youTube_embed_link") %>) + + <%- end -%>

<%- link_iv_other = IV::Frontend::Misc.redirect_url(env) -%>