diff options
| -rw-r--r-- | .ameba.yml | 92 | ||||
| -rw-r--r-- | .github/FUNDING.yml | 1 | ||||
| -rw-r--r-- | config/config.example.yml | 4 | ||||
| -rw-r--r-- | config/sql/playlist_videos.sql | 2 | ||||
| -rw-r--r-- | docker/Dockerfile | 2 | ||||
| -rw-r--r-- | docker/Dockerfile.arm64 | 2 | ||||
| -rw-r--r-- | locales/es.json | 9 | ||||
| -rw-r--r-- | locales/fr.json | 9 | ||||
| -rw-r--r-- | locales/hr.json | 52 | ||||
| -rw-r--r-- | locales/hu-HU.json | 9 | ||||
| -rw-r--r-- | locales/ja.json | 14 | ||||
| -rw-r--r-- | locales/pl.json | 101 | ||||
| -rw-r--r-- | locales/pt-BR.json | 56 | ||||
| -rw-r--r-- | locales/tr.json | 9 | ||||
| -rw-r--r-- | locales/zh-CN.json | 38 | ||||
| -rw-r--r-- | locales/zh-TW.json | 9 | ||||
| -rw-r--r-- | shard.lock | 3 | ||||
| -rw-r--r-- | shard.yml | 3 | ||||
| -rw-r--r-- | src/invidious/comments.cr | 19 | ||||
| -rw-r--r-- | src/invidious/routes/api/v1/videos.cr | 10 |
20 files changed, 408 insertions, 36 deletions
diff --git a/.ameba.yml b/.ameba.yml new file mode 100644 index 00000000..247705e8 --- /dev/null +++ b/.ameba.yml @@ -0,0 +1,92 @@ +# +# Lint +# + +# Exclude assigns for ECR files +Lint/UselessAssign: + Excluded: + - src/invidious.cr + - src/invidious/helpers/errors.cr + - src/invidious/routes/**/*.cr + +# Ignore false negative (if !db.query_one?...) +Lint/UnreachableCode: + Excluded: + - src/invidious/database/base.cr + +# Ignore shadowed variable `key` (it works for now, and that's +# a sensitive part of the code) +Lint/ShadowingOuterLocalVar: + Excluded: + - src/invidious/helpers/tokens.cr + + +# +# Style +# + +Style/RedundantBegin: + Enabled: false + +Style/RedundantReturn: + Enabled: false + + +# +# Metrics +# + +# Ignore function complexity (number of if/else & case/when branches) +# For some functions that can hardly be simplified for now +Metrics/CyclomaticComplexity: + Excluded: + # get_about_info(ucid, locale) => [17/10] + - src/invidious/channels/about.cr + + # fetch_channel_community(ucid, continuation, ...) => [34/10] + - src/invidious/channels/community.cr + + # create_notification_stream(env, topics, connection_channel) => [14/10] + - src/invidious/helpers/helpers.cr:84:5 + + # get_index(plural_form, count) => [25/10] + - src/invidious/helpers/i18next.cr + + # call(context) => [18/10] + - src/invidious/helpers/static_file_handler.cr + + # show(env) => [38/10] + - src/invidious/routes/embed.cr + + # get_video_playback(env) => [45/10] + - src/invidious/routes/video_playback.cr + + # handle(env) => [40/10] + - src/invidious/routes/watch.cr + + # playlist_ajax(env) => [24/10] + - src/invidious/routes/playlists.cr + + # fetch_youtube_comments(id, cursor, ....) => [40/10] + # template_youtube_comments(comments, locale, ...) => [16/10] + # content_to_comment_html(content) => [14/10] + - src/invidious/comments.cr + + # to_json(locale, json) => [21/10] + # extract_video_info(video_id, ...) => [44/10] + # process_video_params(query, preferences) => [20/10] + - src/invidious/videos.cr + + # produce_search_params(page, sort, ...) => [29/10] + # process_search_query(query, page, ...) => [14/10] + - src/invidious/search.cr + + + +#src/invidious/playlists.cr:327:5 +#[C] Metrics/CyclomaticComplexity: Cyclomatic complexity too high [19/10] +# fetch_playlist(plid : String) + +#src/invidious/playlists.cr:436:5 +#[C] Metrics/CyclomaticComplexity: Cyclomatic complexity too high [11/10] +# extract_playlist_videos(initial_data : Hash(String, JSON::Any)) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..3f28c2b7 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: https://invidious.io/donate/ diff --git a/config/config.example.yml b/config/config.example.yml index c3d52d32..d1c1f300 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -157,10 +157,6 @@ https_only: false ## Note 2: Using QUIC prevents some captcha challenges from appearing. ## See: https://github.com/iv-org/invidious/issues/957#issuecomment-576424042 ## -## Note 3: As of 2021-11-12, Google seems to have disabled QUIC on -## their servers. The default has been changed to 'false'.Read more -## at: https://github.com/iv-org/invidious/issues/2577 -## ## Accepted values: true, false ## Default: false ## diff --git a/config/sql/playlist_videos.sql b/config/sql/playlist_videos.sql index eedccbad..4b48b46a 100644 --- a/config/sql/playlist_videos.sql +++ b/config/sql/playlist_videos.sql @@ -2,7 +2,7 @@ -- DROP TABLE public.playlist_videos; -CREATE TABLE IF NOT EXISTS playlist_videos +CREATE TABLE IF NOT EXISTS public.playlist_videos ( title text, id text, diff --git a/docker/Dockerfile b/docker/Dockerfile index c73821da..58f8628d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,7 +6,7 @@ ARG release WORKDIR /invidious COPY ./shard.yml ./shard.yml COPY ./shard.lock ./shard.lock -RUN shards install +RUN shards install --production COPY --from=quay.io/invidious/lsquic-compiled /root/liblsquic.a ./lib/lsquic/src/lsquic/ext/liblsquic.a diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 index d2955c7c..0da7c603 100644 --- a/docker/Dockerfile.arm64 +++ b/docker/Dockerfile.arm64 @@ -6,7 +6,7 @@ ARG release WORKDIR /invidious COPY ./shard.yml ./shard.yml COPY ./shard.lock ./shard.lock -RUN shards install +RUN shards install --production COPY --from=quay.io/invidious/lsquic-compiled /root/liblsquic.a ./lib/lsquic/src/lsquic/ext/liblsquic.a diff --git a/locales/es.json b/locales/es.json index f03ee945..d89b5c08 100644 --- a/locales/es.json +++ b/locales/es.json @@ -428,5 +428,12 @@ "generic_count_minutes": "{{count}} minuto", "generic_count_minutes_plural": "{{count}} minutos", "generic_count_seconds": "{{count}} segundo", - "generic_count_seconds_plural": "{{count}} segundos" + "generic_count_seconds_plural": "{{count}} segundos", + "crash_page_before_reporting": "Antes de notificar un error asegúrate de que has:", + "crash_page_switch_instance": "probado a <a href=\"`x`\">usar otra instancia</a>", + "crash_page_read_the_faq": "leído las <a href=\"`x`\">Preguntas Frecuentes</a>", + "crash_page_search_issue": "buscado <a href=\"`x`\">problemas existentes en Github</a>", + "crash_page_you_found_a_bug": "¡Parece que has encontrado un error en Invidious!", + "crash_page_refresh": "probado a <a href=\"`x`\">recargar la página</a>", + "crash_page_report_issue": "Si nada de lo anterior ha sido de ayuda, por favor, <a href=\"`x`\">abre una nueva incidencia en GitHub</a> (preferiblemente en inglés) e incluye el siguiente texto en tu mensaje (NO traduzcas este texto):" } diff --git a/locales/fr.json b/locales/fr.json index 16f5e8eb..8593feb1 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -430,5 +430,12 @@ "preferences_quality_dash_option_1440p": "1440p", "preferences_quality_dash_option_1080p": "1080p", "user_created_playlists": "`x` listes de lecture créées", - "preferences_save_player_pos_label": "Sauvegarder la position du lecteur : " + "preferences_save_player_pos_label": "Sauvegarder la position du lecteur : ", + "crash_page_you_found_a_bug": "Il semblerait que vous ayez trouvé un bug dans Invidious !", + "crash_page_refresh": "tenté de <a href=\"`x`\">rafraîchir la page</a>", + "crash_page_switch_instance": "essayé d'<a href=\"`x`\">utiliser une autre instance</a>", + "crash_page_read_the_faq": "lu la <a href=\"`x`\">Foire Aux Questions (FAQ)</a>", + "crash_page_search_issue": "<a href=\"`x`\">cherché ce bug sur Github</a>", + "crash_page_before_reporting": "Avant de signaler un bug, veuillez vous assurez que vous avez :", + "crash_page_report_issue": "Si aucune des solutions proposées ci-dessus ne vous a aidé, veuillez <a href=\"`x`\">ouvrir une \"issue\" sur GitHub</a> (de préférence en anglais) et d'y inclure le message suivant (ne PAS traduire le texte) :" } diff --git a/locales/hr.json b/locales/hr.json index 9cdc219c..5770041e 100644 --- a/locales/hr.json +++ b/locales/hr.json @@ -389,7 +389,7 @@ "user_created_playlists": "`x` stvorene zbirke", "user_saved_playlists": "`x` spremljene zbirke", "Video unavailable": "Video nedostupan", - "preferences_save_player_pos_label": "Spremi trenutačno vrijeme videa: ", + "preferences_save_player_pos_label": "Spremi mjesto reprodukcije: ", "videoinfo_watch_on_youTube": "Gledaj na YouTubeu", "download_subtitles": "Podnaslovi - `x` (.vtt)", "preferences_quality_dash_option_auto": "Automatska", @@ -398,5 +398,53 @@ "preferences_quality_dash_option_720p": "720 p", "preferences_quality_dash_option_480p": "480 p", "videoinfo_started_streaming_x_ago": "Započet prijenos prije `x`", - "videoinfo_invidious_embed_link": "Ugradi poveznicu" + "videoinfo_invidious_embed_link": "Ugradi poveznicu", + "generic_count_hours_0": "{{count}} sat", + "generic_count_hours_1": "{{count}} sata", + "generic_count_hours_2": "{{count}} sati", + "generic_subscribers_count_0": "{{count}} pretplatnik", + "generic_subscribers_count_1": "{{count}} pretplatnika", + "generic_subscribers_count_2": "{{count}} pretplatnika", + "tokens_count_0": "{{count}} token", + "tokens_count_1": "{{count}} tokena", + "tokens_count_2": "{{count}} tokena", + "subscriptions_unseen_notifs_count_0": "{{count}} neviđena obavijest", + "subscriptions_unseen_notifs_count_1": "{{count}} neviđene obavijesti", + "subscriptions_unseen_notifs_count_2": "{{count}} neviđenih obavijesti", + "generic_count_years_0": "{{count}} godina", + "generic_count_years_1": "{{count}} godine", + "generic_count_years_2": "{{count}} godina", + "generic_count_months_0": "{{count}} mjesec", + "generic_count_months_1": "{{count}} mjeseca", + "generic_count_months_2": "{{count}} mjeseci", + "generic_count_weeks_0": "{{count}} tjedan", + "generic_count_weeks_1": "{{count}} tjedna", + "generic_count_weeks_2": "{{count}} tjedana", + "generic_count_minutes_0": "{{count}} minuta", + "generic_count_minutes_1": "{{count}} minute", + "generic_count_minutes_2": "{{count}} minuta", + "generic_count_seconds_0": "{{count}} sekunda", + "generic_count_seconds_1": "{{count}} sekunde", + "generic_count_seconds_2": "{{count}} sekundi", + "comments_points_count_0": "{{count}} točka", + "comments_points_count_1": "{{count}} točke", + "comments_points_count_2": "{{count}} točaka", + "generic_subscriptions_count_0": "{{count}} pretplata", + "generic_subscriptions_count_1": "{{count}} pretplate", + "generic_subscriptions_count_2": "{{count}} pretplata", + "generic_playlists_count_0": "{{count}} zbirka", + "generic_playlists_count_1": "{{count}} zbirke", + "generic_playlists_count_2": "{{count}} zbirka", + "generic_videos_count_0": "{{count}} video", + "generic_videos_count_1": "{{count}} videa", + "generic_videos_count_2": "{{count}} videa", + "generic_count_days_0": "{{count}} dan", + "generic_count_days_1": "{{count}} dana", + "generic_count_days_2": "{{count}} dana", + "generic_views_count_0": "{{count}} prikaz", + "generic_views_count_1": "{{count}} prikaza", + "generic_views_count_2": "{{count}} prikaza", + "comments_view_x_replies_0": "Prikaži {{count}} odgovor", + "comments_view_x_replies_1": "Prikaži {{count}} odgovora", + "comments_view_x_replies_2": "Prikaži {{count}} odgovora" } diff --git a/locales/hu-HU.json b/locales/hu-HU.json index 263e361e..60285d94 100644 --- a/locales/hu-HU.json +++ b/locales/hu-HU.json @@ -430,5 +430,12 @@ "short": "Rövid (4 percnél nem több)", "month": "Ebben a hónapban", "subtitles": "Felirattal", - "location": "Közelben" + "location": "Közelben", + "crash_page_you_found_a_bug": "Úgy néz ki, találtál egy hibát az Invidiousban.", + "crash_page_before_reporting": "Mielőtt jelentenéd a hibát:", + "crash_page_read_the_faq": "olvasd el a <a href=\"`x`\">Gyakran Ismételt Kérdéseket (GYIK)</a>", + "crash_page_search_issue": "járj utána a <a href=\"`x`\">már meglévő issue-knak a GitHubon</a>", + "crash_page_switch_instance": "válts át <a href=\"`x`\">másik Invidious-oldalra</a>", + "crash_page_refresh": "<a href=\"`x`\">töltsd újra</a> az oldalt", + "crash_page_report_issue": "Ha a fentiek után nem jutottál eredményre, akkor <a href=\"`x`\">nyiss egy új issue-t a GitHubon</a> (lehetőleg angol nyelven írj) és másold be pontosan a lenti szöveget (ezt nem kell lefordítani):" } diff --git a/locales/ja.json b/locales/ja.json index 5cb1244d..e3014152 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -80,7 +80,7 @@ "light": "ライト", "preferences_thin_mode_label": "最小モード: ", "preferences_category_misc": "雑設定", - "preferences_automatic_instance_redirect_label": "自動インスタンスの移転(redirect.invidious.ioにフォールバック): ", + "preferences_automatic_instance_redirect_label": "自動的なインスタンスの移転(redirect.invidious.ioにフォールバック): ", "preferences_category_subscription": "登録チャンネル設定", "preferences_annotations_subscribed_label": "デフォルトで登録チャンネルのアノテーションを表示しますか? ", "Redirect homepage to feed: ": "ホームからフィードにリダイレクト: ", @@ -401,5 +401,15 @@ "preferences_quality_dash_option_1440p": "1440p", "preferences_quality_dash_option_480p": "480p", "videoinfo_youTube_embed_link": "埋め込み", - "videoinfo_invidious_embed_link": "埋め込みリンク" + "videoinfo_invidious_embed_link": "埋め込みリンク", + "none": "なし", + "download_subtitles": "字幕 - `x` (.vtt)", + "purchased": "購入済み", + "preferences_quality_option_dash": "DASH (適切な品質)", + "preferences_quality_dash_option_worst": "最悪", + "preferences_quality_dash_option_best": "最高", + "videoinfo_started_streaming_x_ago": "`x`分前に配信を開始", + "videoinfo_watch_on_youTube": "YouTube上で見る", + "user_created_playlists": "`x`が作成したプレイリスト", + "Video unavailable": "ビデオは利用できません" } diff --git a/locales/pl.json b/locales/pl.json index 5e4c1283..5c4667f0 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -60,7 +60,7 @@ "preferences_volume_label": "Głośność odtwarzacza: ", "preferences_comments_label": "Domyślne komentarze: ", "youtube": "YouTube", - "reddit": "reddit", + "reddit": "Reddit", "preferences_captions_label": "Domyślne napisy: ", "Fallback captions: ": "Zastępcze napisy: ", "preferences_related_videos_label": "Pokaż powiązane filmy? ", @@ -75,7 +75,7 @@ "light": "jasny", "preferences_thin_mode_label": "Tryb minimalny: ", "preferences_category_misc": "Różne preferencje", - "preferences_automatic_instance_redirect_label": "Automatyczne przekierowanie instancji (powrót do redirect.invidious.io): ", + "preferences_automatic_instance_redirect_label": "Automatycznie przekierowanie instancji (powrót do redirect.invidious.io): ", "preferences_category_subscription": "Preferencje subskrybcji", "preferences_annotations_subscribed_label": "Domyślnie wyświetlaj adnotacje dla subskrybowanych kanałów: ", "Redirect homepage to feed: ": "Przekieruj stronę główną do subskrybcji: ", @@ -358,5 +358,100 @@ "Current version: ": "Aktualna wersja: ", "next_steps_error_message": "Po czym powinien*ś spróbować: ", "next_steps_error_message_refresh": "Odśwież", - "next_steps_error_message_go_to_youtube": "Przejdź do YouTube" + "next_steps_error_message_go_to_youtube": "Przejdź do YouTube", + "invidious": "Invidious", + "tokens_count_0": "{{count}} token", + "tokens_count_1": "{{count}} tokeny", + "tokens_count_2": "{{count}} tokenów", + "generic_videos_count_0": "{{count}} film", + "generic_videos_count_1": "{{count}} filmy", + "generic_videos_count_2": "{{count}} filmów", + "generic_views_count_0": "{{count}} wyświetlenie", + "generic_views_count_1": "{{count}} wyświetlenia", + "generic_views_count_2": "{{count}} wyświetleń", + "generic_playlists_count_0": "{{count}} playlista", + "generic_playlists_count_1": "{{count}} playlisty", + "generic_playlists_count_2": "{{count}} playlist", + "generic_subscribers_count_0": "{{count}} subskrybent", + "generic_subscribers_count_1": "{{count}} subskrybentów", + "generic_subscribers_count_2": "{{count}} subskrybentów", + "generic_subscriptions_count_0": "{{count}} subskrypcja", + "generic_subscriptions_count_1": "{{count}} subskrypcje", + "generic_subscriptions_count_2": "{{count}} subskrypcji", + "comments_view_x_replies_0": "Pokaż {{count}} odpowiedź", + "comments_view_x_replies_1": "Pokaż {{count}} odpowiedzi", + "comments_view_x_replies_2": "Pokaż {{count}} odpowiedzi", + "comments_points_count_0": "{{count}} punkt", + "comments_points_count_1": "{{count}} punkty", + "comments_points_count_2": "{{count}} punktów", + "generic_count_months_0": "{{count}} miesiąc", + "generic_count_months_1": "{{count}} miesiące", + "generic_count_months_2": "{{count}} miesięcy", + "generic_count_weeks_0": "{{count}} tydzień", + "generic_count_weeks_1": "{{count}} tygodnie", + "generic_count_weeks_2": "{{count}} tygodni", + "generic_count_days_0": "{{count}} dzień", + "generic_count_days_1": "{{count}} dni", + "generic_count_days_2": "{{count}} dni", + "generic_count_hours_0": "{{count}} godzina", + "generic_count_hours_1": "{{count}} godziny", + "generic_count_hours_2": "{{count}} godzin", + "generic_count_seconds_0": "{{count}} sekunda", + "generic_count_seconds_1": "{{count}} sekundy", + "generic_count_seconds_2": "{{count}} sekund", + "crash_page_you_found_a_bug": "Wygląda na to że udało ci się znaleźć błąd w Invidious!", + "crash_page_refresh": "próbowano <a href=\"`x`\">odświeżyć stronę</a>", + "crash_page_switch_instance": "spróbowano <a href=\"`x`\"> użyć innej instancji</a>", + "crash_page_read_the_faq": "przeczytaj <a href=\"`x`\"> Często Zadawane Pytania (FAQ)</a>", + "crash_page_search_issue": "próbowano poszukać <a href=\"`x`\"> istniejących zgłoszeń na GitHub'ie</a>", + "preferences_quality_dash_option_1440p": "1440p", + "preferences_quality_dash_option_720p": "720p", + "preferences_quality_dash_option_144p": "144p", + "preferences_quality_dash_option_1080p": "1080p", + "preferences_quality_dash_option_480p": "480p", + "preferences_quality_dash_option_360p": "360p", + "preferences_quality_dash_option_240p": "240p", + "subscriptions_unseen_notifs_count_0": "{{count}} nieodczytane powiadomienie", + "subscriptions_unseen_notifs_count_1": "{{count}} nieodczytane powiadomienia", + "subscriptions_unseen_notifs_count_2": "{{count}} nieodczytanych powiadomień", + "generic_count_minutes_0": "{{count}} minuta", + "generic_count_minutes_1": "{{count}} minuty", + "generic_count_minutes_2": "{{count}} minut", + "generic_count_years_0": "{{count}} rok", + "generic_count_years_1": "{{count}} lata", + "generic_count_years_2": "{{count}} lat", + "crash_page_before_reporting": "Przed zgłoszeniem błędu, upewnij się że masz:", + "crash_page_report_issue": "Jeżeli nic z powyższych opcji nie pomogło, proszę <a href=\"`x`\"> otworzyć nowe zgłoszenie na GitHub'ie</a> (najlepiej po Angielsku) i dodać poniższy tekst w twojej wiadomości (NIE tłumacz tego tekstu):", + "preferences_quality_dash_option_auto": "Automatyczna", + "preferences_quality_dash_option_best": "Najlepsza", + "preferences_quality_dash_option_worst": "Najgorsza", + "preferences_quality_option_dash": "DASH (jakość adaptywna)", + "preferences_quality_option_hd720": "HD720", + "preferences_quality_option_medium": "Średnia", + "preferences_quality_option_small": "Mała", + "preferences_quality_dash_label": "Preferowana jakość filmu DASH: ", + "preferences_quality_dash_option_4320p": "4320p", + "preferences_quality_dash_option_2160p": "2160p", + "purchased": "Zakupione", + "360": "360°", + "footer_donate_page": "Dotacja", + "none": "żadne", + "videoinfo_started_streaming_x_ago": "Transmisja rozpoczęta `x` temu", + "videoinfo_watch_on_youTube": "Obejrzyj na YouTube", + "videoinfo_youTube_embed_link": "Odtwarzacz typu Embed", + "videoinfo_invidious_embed_link": "Link do Embed", + "download_subtitles": "Napisy - `x` (.vtt)", + "user_created_playlists": "`x` utworzonych playlist", + "user_saved_playlists": "`x` zapisanych playlist", + "Video unavailable": "Film niedostępny", + "preferences_save_player_pos_label": "Zapisz pozycję odtwarzania: ", + "preferences_region_label": "Region zawartości: ", + "Released under the AGPLv3 on Github.": "Wydane na licencji AGPLv3 na Github'ie.", + "short": "Krótkie (< 4 minutes)", + "long": "Długie (> 20 minutes)", + "footer_documentation": "Dokumentacja", + "footer_source_code": "Kod źródłowy", + "footer_modfied_source_code": "Zmodyfikowany Kod źródłowy", + "footer_original_source_code": "Oryginalny kod źródłowy", + "adminprefs_modified_source_code_url_label": "Adres URL do repozytorium z zmodyfikowanym kodem źródłowym" } diff --git a/locales/pt-BR.json b/locales/pt-BR.json index d619edaa..71a232c7 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -313,7 +313,7 @@ "generic_count_weeks": "{{count}} semana", "generic_count_weeks_plural": "{{count}} semanas", "generic_count_days": "{{count}} dia", - "generic_count_days_plural": "{{count}} dia", + "generic_count_days_plural": "{{count}} dias", "generic_count_hours": "{{count}} hora", "generic_count_hours_plural": "{{count}} horas", "generic_count_minutes": "{{count}} minuto", @@ -385,5 +385,57 @@ "footer_original_source_code": "Código fonte original", "footer_modfied_source_code": "Código Fonte Modificado", "preferences_quality_dash_label": "Qualidade de vídeo do painel preferida: ", - "preferences_region_label": "País do conteúdo: " + "preferences_region_label": "País do conteúdo: ", + "preferences_quality_dash_option_4320p": "4320p", + "generic_videos_count": "{{count}} vídeo", + "generic_videos_count_plural": "{{count}} vídeos", + "generic_playlists_count": "{{count}} lista de reprodução", + "generic_playlists_count_plural": "{{count}} listas de reprodução", + "generic_subscribers_count": "{{count}} inscrito", + "generic_subscribers_count_plural": "{{count}} inscritos", + "generic_subscriptions_count": "{{count}} inscrição", + "generic_subscriptions_count_plural": "{{count}} inscrições", + "subscriptions_unseen_notifs_count": "{{count}} notificação não vista", + "subscriptions_unseen_notifs_count_plural": "{{count}} notificações não vistas", + "comments_view_x_replies": "Ver {{count}} resposta", + "comments_view_x_replies_plural": "Ver {{count}} respostas", + "comments_points_count": "{{count}} ponto", + "comments_points_count_plural": "{{count}} pontos", + "crash_page_you_found_a_bug": "Parece que você encontrou um erro no Invidious!", + "crash_page_before_reporting": "Antes de reportar um erro, verifique se você:", + "preferences_save_player_pos_label": "Salvar a posição de reprodução: ", + "purchased": "Comprado", + "crash_page_refresh": "tentou <a href=\"`x`\">recarregar a página</a>", + "crash_page_switch_instance": "tentou <a href=\"`x`\">usar outra instância</a>", + "crash_page_search_issue": "procurou por um <a href=\"`x`\">erro existente no Github</a>", + "crash_page_report_issue": "Se nenhuma opção acima ajudou, por favor <a href=\"`x`\">abra um novo problema no Github</a> (preferencialmente em inglês) e inclua o seguinte texto (NÃO traduza):", + "crash_page_read_the_faq": "leu as <a href=\"`x`\">Perguntas Frequentes (FAQ)</a>", + "generic_views_count": "{{count}} visualização", + "generic_views_count_plural": "{{count}} visualizações", + "preferences_quality_option_dash": "DASH (qualidade adaptiva)", + "preferences_quality_option_hd720": "HD720", + "preferences_quality_option_small": "Pequeno", + "preferences_quality_dash_option_auto": "Auto", + "preferences_quality_dash_option_best": "Melhor", + "preferences_quality_dash_option_worst": "Pior", + "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", + "preferences_quality_option_medium": "Médio", + "360": "360°", + "none": "none", + "videoinfo_watch_on_youTube": "Assistir no YouTube", + "videoinfo_youTube_embed_link": "Embutir", + "videoinfo_invidious_embed_link": "Link Embutido", + "download_subtitles": "Legendas - `x` (.vtt)", + "user_created_playlists": "`x` listas de reprodução criadas", + "user_saved_playlists": "`x` listas de reprodução salvas", + "Video unavailable": "Vídeo indisponível", + "videoinfo_started_streaming_x_ago": "Iniciou a transmissão a `x`" } diff --git a/locales/tr.json b/locales/tr.json index 46a1bd51..5c3102c5 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -430,5 +430,12 @@ "generic_videos_count": "{{count}} video", "generic_videos_count_plural": "{{count}} video", "generic_count_weeks": "{{count}} hafta", - "generic_count_weeks_plural": "{{count}} hafta" + "generic_count_weeks_plural": "{{count}} hafta", + "crash_page_you_found_a_bug": "Görünüşe göre Invidious'ta bir hata buldunuz!", + "crash_page_before_reporting": "Bir hatayı bildirmeden önce, şunları yaptığınızdan emin olun:", + "crash_page_refresh": "<a href=\"`x`\">sayfayı yenilemeye</a> çalıştınız", + "crash_page_switch_instance": "<a href=\"`x`\">başka bir örnek kullanmaya</a> çalıştınız", + "crash_page_read_the_faq": "<a href=\"`x`\">Sık Sorulan Soruları (SSS)</a> okudunuz", + "crash_page_search_issue": "<a href=\"`x`\">Github'daki sorunlarda</a> aradınız", + "crash_page_report_issue": "Yukarıdakilerin hiçbiri yardımcı olmadıysa, lütfen <a href=\"`x`\">GitHub'da yeni bir sorun açın</a> (tercihen İngilizce) ve mesajınıza aşağıdaki metni ekleyin (bu metni ÇEVİRMEYİN):" } diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 10b767d9..521545bc 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -385,5 +385,41 @@ "footer_original_source_code": "原始源代码", "footer_donate_page": "捐赠", "preferences_region_label": "内容国家: ", - "preferences_quality_dash_label": "首选 DASH 视频分辨率: " + "preferences_quality_dash_label": "首选 DASH 视频分辨率: ", + "crash_page_you_found_a_bug": "你似乎找到了 Invidious 的一个 bug!", + "crash_page_before_reporting": "报告 bug 之前,请确保你已经:", + "crash_page_refresh": "试着 <a href=\"`x`\">刷新页面</a>", + "crash_page_switch_instance": "试着<a href=\"`x`\">使用另一个实例</a>", + "crash_page_read_the_faq": "阅读<a href=\"`x`\">常见问题</a>", + "crash_page_search_issue": "搜索过 <a href=\"`x`\">Github 上的现有 issue</a>", + "crash_page_report_issue": "如果以上这些都没用的话,请<a href=\"`x`\">在 Github 上新开一个 issue</a>(最好用英语撰写),并在你的消息中包含以下文本(不要翻译该文本):", + "videoinfo_invidious_embed_link": "嵌入链接", + "download_subtitles": "字幕 - `x` (.vtt)", + "preferences_quality_dash_option_360p": "360p", + "videoinfo_watch_on_youTube": "在 YouTube 上观看", + "videoinfo_youTube_embed_link": "嵌入的", + "preferences_quality_dash_option_1080p": "1080p", + "preferences_quality_option_hd720": "HD720", + "preferences_quality_dash_option_240p": "240p", + "preferences_quality_dash_option_worst": "最差", + "preferences_quality_dash_option_720p": "720p", + "preferences_quality_dash_option_480p": "480p", + "preferences_quality_dash_option_144p": "144p", + "preferences_quality_option_medium": "中等", + "preferences_quality_option_small": "小", + "preferences_quality_dash_option_auto": "自动", + "preferences_quality_option_dash": "DASH (自适应画质)", + "preferences_quality_dash_option_best": "最佳", + "preferences_quality_dash_option_4320p": "4320p", + "preferences_quality_dash_option_2160p": "2160p", + "preferences_quality_dash_option_1440p": "1440p", + "invidious": "Invidious", + "videoinfo_started_streaming_x_ago": "`x` 前开始播放", + "user_created_playlists": "`x` 创建了播放列表", + "user_saved_playlists": "`x` 保存了播放列表", + "Video unavailable": "视频不可用", + "purchased": "已购买", + "360": "360°", + "none": "无", + "preferences_save_player_pos_label": "保存播放位置: " } diff --git a/locales/zh-TW.json b/locales/zh-TW.json index 1e847395..8c9133c6 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -414,5 +414,12 @@ "preferences_quality_option_medium": "中等", "preferences_quality_dash_option_auto": "自動", "preferences_quality_dash_option_best": "最佳", - "preferences_save_player_pos_label": "儲存播放位置: " + "preferences_save_player_pos_label": "儲存播放位置: ", + "crash_page_you_found_a_bug": "看來您在 Invidious 中發現了一隻臭蟲!", + "crash_page_refresh": "嘗試過<a href=\"`x`\">重新整理頁面</a>", + "crash_page_switch_instance": "嘗試<a href=\"`x`\">使用其他站台</a>", + "crash_page_read_the_faq": "閱讀<a href=\"`x`\">常見問題解答 (FAQ)</a>", + "crash_page_search_issue": "搜尋 <a href=\"`x`\">GitHub 上既有的問題</a>", + "crash_page_report_issue": "若以上的動作都沒有幫到忙,請<a href=\"`x`\">在 GitHub 上開啟新的議題</a>(請盡量使用英文)並在您的訊息中包含以下文字(不要翻譯文字):", + "crash_page_before_reporting": "在回報臭蟲之前,請確保您有:" } @@ -48,3 +48,6 @@ shards: git: https://github.com/crystal-lang/crystal-sqlite3.git version: 0.18.0 + ameba: + git: https://github.com/crystal-ameba/ameba.git + version: 0.14.3 @@ -33,6 +33,9 @@ development_dependencies: spectator: github: icy-arctic-fox/spectator version: ~> 0.10.4 + ameba: + github: crystal-ameba/ameba + version: ~> 0.14.3 crystal: ">= 1.0.0, < 2.0.0" diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 256a294e..dda92440 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -268,18 +268,20 @@ def fetch_reddit_comments(id, sort_by = "confidence") headers = HTTP::Headers{"User-Agent" => "web:invidious:v#{CURRENT_VERSION} (by github.com/iv-org/invidious)"} # TODO: Use something like #479 for a static list of instances to use here - query = "(url:3D#{id}%20OR%20url:#{id})%20(site:invidio.us%20OR%20site:youtube.com%20OR%20site:youtu.be)" - search_results = client.get("/search.json?q=#{query}", headers) + query = URI::Params.encode({q: "(url:3D#{id} OR url:#{id}) AND (site:invidio.us OR site:youtube.com OR site:youtu.be)"}) + search_results = client.get("/search.json?#{query}", headers) if search_results.status_code == 200 search_results = RedditThing.from_json(search_results.body) # For videos that have more than one thread, choose the one with the highest score - thread = search_results.data.as(RedditListing).children.sort_by { |child| child.data.as(RedditLink).score }[-1] - thread = thread.data.as(RedditLink) - - result = client.get("/r/#{thread.subreddit}/comments/#{thread.id}.json?limit=100&sort=#{sort_by}", headers).body - result = Array(RedditThing).from_json(result) + threads = search_results.data.as(RedditListing).children + thread = threads.max_by?(&.data.as(RedditLink).score).try(&.data.as(RedditLink)) + result = thread.try do |t| + body = client.get("/r/#{t.subreddit}/comments/#{t.id}.json?limit=100&sort=#{sort_by}", headers).body + Array(RedditThing).from_json(body) + end + result ||= [] of RedditThing elsif search_results.status_code == 302 # Previously, if there was only one result then the API would redirect to that result. # Now, it appears it will still return a listing so this section is likely unnecessary. @@ -294,7 +296,8 @@ def fetch_reddit_comments(id, sort_by = "confidence") client.close - comments = result[1].data.as(RedditListing).children + comments = result[1]?.try(&.data.as(RedditListing).children) + comments ||= [] of RedditThing return comments, thread end diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr index 4d244e7f..3a013ba0 100644 --- a/src/invidious/routes/api/v1/videos.cr +++ b/src/invidious/routes/api/v1/videos.cr @@ -330,18 +330,13 @@ module Invidious::Routes::API::V1::Videos begin comments, reddit_thread = fetch_reddit_comments(id, sort_by: sort_by) - content_html = template_reddit_comments(comments, locale) - - content_html = fill_links(content_html, "https", "www.reddit.com") - content_html = replace_links(content_html) rescue ex comments = nil reddit_thread = nil - content_html = "" end if !reddit_thread || !comments - haltf env, 404 + return error_json(404, "No reddit threads found") end if format == "json" @@ -350,6 +345,9 @@ module Invidious::Routes::API::V1::Videos return reddit_thread.to_json else + content_html = template_reddit_comments(comments, locale) + content_html = fill_links(content_html, "https", "www.reddit.com") + content_html = replace_links(content_html) response = { "title" => reddit_thread.title, "permalink" => reddit_thread.permalink, |
