From 7f2ec183721c55ea5718119e76c3fc6ce6cd72bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Devos?= Date: Tue, 9 Aug 2022 10:05:13 +0200 Subject: [PATCH 01/73] Add param 8AEB for getting youtube stories --- src/invidious/videos.cr | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index f87c6b47..e9526c18 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -893,7 +893,8 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_ end # Fetch data from the player endpoint - player_response = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config) + # 8AEB param for fetching YouTube stories + player_response = YoutubeAPI.player(video_id: video_id, params: "8AEB", client_config: client_config) playability_status = player_response.dig?("playabilityStatus", "status").try &.as_s @@ -931,7 +932,8 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_ else client_config.client_type = YoutubeAPI::ClientType::Android end - android_player = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config) + # 8AEB param for fetching YouTube stories + android_player = YoutubeAPI.player(video_id: video_id, params: "8AEB", client_config: client_config) # Sometime, the video is available from the web client, but not on Android, so check # that here, and fallback to the streaming data from the web client if needed. From 6250039405a0a9762a228066df16dd2e8579f4f3 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 23 Aug 2022 18:23:53 +0200 Subject: [PATCH 02/73] videos: move regions list to a dedicated file --- src/invidious/videos.cr | 2 -- src/invidious/videos/regions.cr | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/invidious/videos/regions.cr diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index c0ed6e85..97b4f4b8 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -131,8 +131,6 @@ CAPTION_LANGUAGES = { "Zulu", } -REGIONS = {"AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW"} - # See https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/youtube.py#L380-#L476 VIDEO_FORMATS = { "5" => {"ext" => "flv", "width" => 400, "height" => 240, "acodec" => "mp3", "abr" => 64, "vcodec" => "h263"}, diff --git a/src/invidious/videos/regions.cr b/src/invidious/videos/regions.cr new file mode 100644 index 00000000..575f8c25 --- /dev/null +++ b/src/invidious/videos/regions.cr @@ -0,0 +1,27 @@ +# List of geographical regions that Youtube recognizes. +# This is used to determine if a video is either restricted to a list +# of allowed regions (= whitelisted) or if it can't be watched in +# a set of regions (= blacklisted). +REGIONS = { + "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ", "AR", "AS", "AT", + "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", + "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", + "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", + "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", + "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK", + "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", + "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", + "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", + "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", + "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", + "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", + "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", + "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", + "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", + "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", + "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", + "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TC", "TD", "TF", + "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", + "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", + "VN", "VU", "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW", +} From 88141c459c553bcca053643c0b1a2ae3338f75b9 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Mon, 23 May 2022 21:54:48 +0200 Subject: [PATCH 03/73] videos: move formats structure to a separate file/module --- src/invidious.cr | 1 + src/invidious/frontend/watch_page.cr | 2 +- src/invidious/videos.cr | 119 +-------------------------- src/invidious/videos/formats.cr | 116 ++++++++++++++++++++++++++ 4 files changed, 120 insertions(+), 118 deletions(-) create mode 100644 src/invidious/videos/formats.cr diff --git a/src/invidious.cr b/src/invidious.cr index 58adaa35..8df0c0cd 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -37,6 +37,7 @@ require "./invidious/database/migrations/*" require "./invidious/helpers/*" require "./invidious/yt_backend/*" require "./invidious/frontend/*" +require "./invidious/videos/*" require "./invidious/*" require "./invidious/channels/*" diff --git a/src/invidious/frontend/watch_page.cr b/src/invidious/frontend/watch_page.cr index 80b67641..9212eb2f 100644 --- a/src/invidious/frontend/watch_page.cr +++ b/src/invidious/frontend/watch_page.cr @@ -50,7 +50,7 @@ module Invidious::Frontend::WatchPage video_assets.full_videos.each do |option| mimetype = option["mimeType"].as_s.split(";")[0] - height = itag_to_metadata?(option["itag"]).try &.["height"]? + height = Invidious::Videos::Formats.itag_to_metadata?(option["itag"]).try &.["height"]? value = {"itag": option["itag"], "ext": mimetype.split("/")[1]}.to_json diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 97b4f4b8..3a71f163 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -131,117 +131,6 @@ CAPTION_LANGUAGES = { "Zulu", } -# See https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/youtube.py#L380-#L476 -VIDEO_FORMATS = { - "5" => {"ext" => "flv", "width" => 400, "height" => 240, "acodec" => "mp3", "abr" => 64, "vcodec" => "h263"}, - "6" => {"ext" => "flv", "width" => 450, "height" => 270, "acodec" => "mp3", "abr" => 64, "vcodec" => "h263"}, - "13" => {"ext" => "3gp", "acodec" => "aac", "vcodec" => "mp4v"}, - "17" => {"ext" => "3gp", "width" => 176, "height" => 144, "acodec" => "aac", "abr" => 24, "vcodec" => "mp4v"}, - "18" => {"ext" => "mp4", "width" => 640, "height" => 360, "acodec" => "aac", "abr" => 96, "vcodec" => "h264"}, - "22" => {"ext" => "mp4", "width" => 1280, "height" => 720, "acodec" => "aac", "abr" => 192, "vcodec" => "h264"}, - "34" => {"ext" => "flv", "width" => 640, "height" => 360, "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, - "35" => {"ext" => "flv", "width" => 854, "height" => 480, "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, - - "36" => {"ext" => "3gp", "width" => 320, "acodec" => "aac", "vcodec" => "mp4v"}, - "37" => {"ext" => "mp4", "width" => 1920, "height" => 1080, "acodec" => "aac", "abr" => 192, "vcodec" => "h264"}, - "38" => {"ext" => "mp4", "width" => 4096, "height" => 3072, "acodec" => "aac", "abr" => 192, "vcodec" => "h264"}, - "43" => {"ext" => "webm", "width" => 640, "height" => 360, "acodec" => "vorbis", "abr" => 128, "vcodec" => "vp8"}, - "44" => {"ext" => "webm", "width" => 854, "height" => 480, "acodec" => "vorbis", "abr" => 128, "vcodec" => "vp8"}, - "45" => {"ext" => "webm", "width" => 1280, "height" => 720, "acodec" => "vorbis", "abr" => 192, "vcodec" => "vp8"}, - "46" => {"ext" => "webm", "width" => 1920, "height" => 1080, "acodec" => "vorbis", "abr" => 192, "vcodec" => "vp8"}, - "59" => {"ext" => "mp4", "width" => 854, "height" => 480, "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, - "78" => {"ext" => "mp4", "width" => 854, "height" => 480, "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, - - # 3D videos - "82" => {"ext" => "mp4", "height" => 360, "format" => "3D", "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, - "83" => {"ext" => "mp4", "height" => 480, "format" => "3D", "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, - "84" => {"ext" => "mp4", "height" => 720, "format" => "3D", "acodec" => "aac", "abr" => 192, "vcodec" => "h264"}, - "85" => {"ext" => "mp4", "height" => 1080, "format" => "3D", "acodec" => "aac", "abr" => 192, "vcodec" => "h264"}, - "100" => {"ext" => "webm", "height" => 360, "format" => "3D", "acodec" => "vorbis", "abr" => 128, "vcodec" => "vp8"}, - "101" => {"ext" => "webm", "height" => 480, "format" => "3D", "acodec" => "vorbis", "abr" => 192, "vcodec" => "vp8"}, - "102" => {"ext" => "webm", "height" => 720, "format" => "3D", "acodec" => "vorbis", "abr" => 192, "vcodec" => "vp8"}, - - # Apple HTTP Live Streaming - "91" => {"ext" => "mp4", "height" => 144, "format" => "HLS", "acodec" => "aac", "abr" => 48, "vcodec" => "h264"}, - "92" => {"ext" => "mp4", "height" => 240, "format" => "HLS", "acodec" => "aac", "abr" => 48, "vcodec" => "h264"}, - "93" => {"ext" => "mp4", "height" => 360, "format" => "HLS", "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, - "94" => {"ext" => "mp4", "height" => 480, "format" => "HLS", "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, - "95" => {"ext" => "mp4", "height" => 720, "format" => "HLS", "acodec" => "aac", "abr" => 256, "vcodec" => "h264"}, - "96" => {"ext" => "mp4", "height" => 1080, "format" => "HLS", "acodec" => "aac", "abr" => 256, "vcodec" => "h264"}, - "132" => {"ext" => "mp4", "height" => 240, "format" => "HLS", "acodec" => "aac", "abr" => 48, "vcodec" => "h264"}, - "151" => {"ext" => "mp4", "height" => 72, "format" => "HLS", "acodec" => "aac", "abr" => 24, "vcodec" => "h264"}, - - # DASH mp4 video - "133" => {"ext" => "mp4", "height" => 240, "format" => "DASH video", "vcodec" => "h264"}, - "134" => {"ext" => "mp4", "height" => 360, "format" => "DASH video", "vcodec" => "h264"}, - "135" => {"ext" => "mp4", "height" => 480, "format" => "DASH video", "vcodec" => "h264"}, - "136" => {"ext" => "mp4", "height" => 720, "format" => "DASH video", "vcodec" => "h264"}, - "137" => {"ext" => "mp4", "height" => 1080, "format" => "DASH video", "vcodec" => "h264"}, - "138" => {"ext" => "mp4", "format" => "DASH video", "vcodec" => "h264"}, # Height can vary (https://github.com/ytdl-org/youtube-dl/issues/4559) - "160" => {"ext" => "mp4", "height" => 144, "format" => "DASH video", "vcodec" => "h264"}, - "212" => {"ext" => "mp4", "height" => 480, "format" => "DASH video", "vcodec" => "h264"}, - "264" => {"ext" => "mp4", "height" => 1440, "format" => "DASH video", "vcodec" => "h264"}, - "298" => {"ext" => "mp4", "height" => 720, "format" => "DASH video", "vcodec" => "h264", "fps" => 60}, - "299" => {"ext" => "mp4", "height" => 1080, "format" => "DASH video", "vcodec" => "h264", "fps" => 60}, - "266" => {"ext" => "mp4", "height" => 2160, "format" => "DASH video", "vcodec" => "h264"}, - - # Dash mp4 audio - "139" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "aac", "abr" => 48, "container" => "m4a_dash"}, - "140" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "aac", "abr" => 128, "container" => "m4a_dash"}, - "141" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "aac", "abr" => 256, "container" => "m4a_dash"}, - "256" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "aac", "container" => "m4a_dash"}, - "258" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "aac", "container" => "m4a_dash"}, - "325" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "dtse", "container" => "m4a_dash"}, - "328" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "ec-3", "container" => "m4a_dash"}, - - # Dash webm - "167" => {"ext" => "webm", "height" => 360, "width" => 640, "format" => "DASH video", "container" => "webm", "vcodec" => "vp8"}, - "168" => {"ext" => "webm", "height" => 480, "width" => 854, "format" => "DASH video", "container" => "webm", "vcodec" => "vp8"}, - "169" => {"ext" => "webm", "height" => 720, "width" => 1280, "format" => "DASH video", "container" => "webm", "vcodec" => "vp8"}, - "170" => {"ext" => "webm", "height" => 1080, "width" => 1920, "format" => "DASH video", "container" => "webm", "vcodec" => "vp8"}, - "218" => {"ext" => "webm", "height" => 480, "width" => 854, "format" => "DASH video", "container" => "webm", "vcodec" => "vp8"}, - "219" => {"ext" => "webm", "height" => 480, "width" => 854, "format" => "DASH video", "container" => "webm", "vcodec" => "vp8"}, - "278" => {"ext" => "webm", "height" => 144, "format" => "DASH video", "container" => "webm", "vcodec" => "vp9"}, - "242" => {"ext" => "webm", "height" => 240, "format" => "DASH video", "vcodec" => "vp9"}, - "243" => {"ext" => "webm", "height" => 360, "format" => "DASH video", "vcodec" => "vp9"}, - "244" => {"ext" => "webm", "height" => 480, "format" => "DASH video", "vcodec" => "vp9"}, - "245" => {"ext" => "webm", "height" => 480, "format" => "DASH video", "vcodec" => "vp9"}, - "246" => {"ext" => "webm", "height" => 480, "format" => "DASH video", "vcodec" => "vp9"}, - "247" => {"ext" => "webm", "height" => 720, "format" => "DASH video", "vcodec" => "vp9"}, - "248" => {"ext" => "webm", "height" => 1080, "format" => "DASH video", "vcodec" => "vp9"}, - "271" => {"ext" => "webm", "height" => 1440, "format" => "DASH video", "vcodec" => "vp9"}, - # itag 272 videos are either 3840x2160 (e.g. RtoitU2A-3E) or 7680x4320 (sLprVF6d7Ug) - "272" => {"ext" => "webm", "height" => 2160, "format" => "DASH video", "vcodec" => "vp9"}, - "302" => {"ext" => "webm", "height" => 720, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, - "303" => {"ext" => "webm", "height" => 1080, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, - "308" => {"ext" => "webm", "height" => 1440, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, - "313" => {"ext" => "webm", "height" => 2160, "format" => "DASH video", "vcodec" => "vp9"}, - "315" => {"ext" => "webm", "height" => 2160, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, - "330" => {"ext" => "webm", "height" => 144, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, - "331" => {"ext" => "webm", "height" => 240, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, - "332" => {"ext" => "webm", "height" => 360, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, - "333" => {"ext" => "webm", "height" => 480, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, - "334" => {"ext" => "webm", "height" => 720, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, - "335" => {"ext" => "webm", "height" => 1080, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, - "336" => {"ext" => "webm", "height" => 1440, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, - "337" => {"ext" => "webm", "height" => 2160, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, - - # Dash webm audio - "171" => {"ext" => "webm", "acodec" => "vorbis", "format" => "DASH audio", "abr" => 128}, - "172" => {"ext" => "webm", "acodec" => "vorbis", "format" => "DASH audio", "abr" => 256}, - - # Dash webm audio with opus inside - "249" => {"ext" => "webm", "format" => "DASH audio", "acodec" => "opus", "abr" => 50}, - "250" => {"ext" => "webm", "format" => "DASH audio", "acodec" => "opus", "abr" => 70}, - "251" => {"ext" => "webm", "format" => "DASH audio", "acodec" => "opus", "abr" => 160}, - - # av01 video only formats sometimes served with "unknown" codecs - "394" => {"ext" => "mp4", "height" => 144, "vcodec" => "av01.0.05M.08"}, - "395" => {"ext" => "mp4", "height" => 240, "vcodec" => "av01.0.05M.08"}, - "396" => {"ext" => "mp4", "height" => 360, "vcodec" => "av01.0.05M.08"}, - "397" => {"ext" => "mp4", "height" => 480, "vcodec" => "av01.0.05M.08"}, -} - struct VideoPreferences include JSON::Serializable @@ -390,7 +279,7 @@ struct Video json.field "lmt", fmt["lastModified"] json.field "projectionType", fmt["projectionType"] - if fmt_info = itag_to_metadata?(fmt["itag"]) + if fmt_info = Invidious::Videos::Formats.itag_to_metadata?(fmt["itag"]) fps = fmt_info["fps"]?.try &.to_i || fmt["fps"]?.try &.as_i || 30 json.field "fps", fps json.field "container", fmt_info["ext"] @@ -437,7 +326,7 @@ struct Video json.field "type", fmt["mimeType"] json.field "quality", fmt["quality"] - fmt_info = itag_to_metadata?(fmt["itag"]) + fmt_info = Invidious::Videos::Formats.itag_to_metadata?(fmt["itag"]) if fmt_info fps = fmt_info["fps"]?.try &.to_i || fmt["fps"]?.try &.as_i || 30 json.field "fps", fps @@ -1164,10 +1053,6 @@ def fetch_video(id, region) return video end -def itag_to_metadata?(itag : JSON::Any) - return VIDEO_FORMATS[itag.to_s]? -end - def process_continuation(query, plid, id) continuation = nil if plid diff --git a/src/invidious/videos/formats.cr b/src/invidious/videos/formats.cr new file mode 100644 index 00000000..e98e7257 --- /dev/null +++ b/src/invidious/videos/formats.cr @@ -0,0 +1,116 @@ +module Invidious::Videos::Formats + def self.itag_to_metadata?(itag : JSON::Any) + return FORMATS[itag.to_s]? + end + + # See https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/youtube.py#L380-#L476 + private FORMATS = { + "5" => {"ext" => "flv", "width" => 400, "height" => 240, "acodec" => "mp3", "abr" => 64, "vcodec" => "h263"}, + "6" => {"ext" => "flv", "width" => 450, "height" => 270, "acodec" => "mp3", "abr" => 64, "vcodec" => "h263"}, + "13" => {"ext" => "3gp", "acodec" => "aac", "vcodec" => "mp4v"}, + "17" => {"ext" => "3gp", "width" => 176, "height" => 144, "acodec" => "aac", "abr" => 24, "vcodec" => "mp4v"}, + "18" => {"ext" => "mp4", "width" => 640, "height" => 360, "acodec" => "aac", "abr" => 96, "vcodec" => "h264"}, + "22" => {"ext" => "mp4", "width" => 1280, "height" => 720, "acodec" => "aac", "abr" => 192, "vcodec" => "h264"}, + "34" => {"ext" => "flv", "width" => 640, "height" => 360, "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, + "35" => {"ext" => "flv", "width" => 854, "height" => 480, "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, + + "36" => {"ext" => "3gp", "width" => 320, "acodec" => "aac", "vcodec" => "mp4v"}, + "37" => {"ext" => "mp4", "width" => 1920, "height" => 1080, "acodec" => "aac", "abr" => 192, "vcodec" => "h264"}, + "38" => {"ext" => "mp4", "width" => 4096, "height" => 3072, "acodec" => "aac", "abr" => 192, "vcodec" => "h264"}, + "43" => {"ext" => "webm", "width" => 640, "height" => 360, "acodec" => "vorbis", "abr" => 128, "vcodec" => "vp8"}, + "44" => {"ext" => "webm", "width" => 854, "height" => 480, "acodec" => "vorbis", "abr" => 128, "vcodec" => "vp8"}, + "45" => {"ext" => "webm", "width" => 1280, "height" => 720, "acodec" => "vorbis", "abr" => 192, "vcodec" => "vp8"}, + "46" => {"ext" => "webm", "width" => 1920, "height" => 1080, "acodec" => "vorbis", "abr" => 192, "vcodec" => "vp8"}, + "59" => {"ext" => "mp4", "width" => 854, "height" => 480, "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, + "78" => {"ext" => "mp4", "width" => 854, "height" => 480, "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, + + # 3D videos + "82" => {"ext" => "mp4", "height" => 360, "format" => "3D", "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, + "83" => {"ext" => "mp4", "height" => 480, "format" => "3D", "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, + "84" => {"ext" => "mp4", "height" => 720, "format" => "3D", "acodec" => "aac", "abr" => 192, "vcodec" => "h264"}, + "85" => {"ext" => "mp4", "height" => 1080, "format" => "3D", "acodec" => "aac", "abr" => 192, "vcodec" => "h264"}, + "100" => {"ext" => "webm", "height" => 360, "format" => "3D", "acodec" => "vorbis", "abr" => 128, "vcodec" => "vp8"}, + "101" => {"ext" => "webm", "height" => 480, "format" => "3D", "acodec" => "vorbis", "abr" => 192, "vcodec" => "vp8"}, + "102" => {"ext" => "webm", "height" => 720, "format" => "3D", "acodec" => "vorbis", "abr" => 192, "vcodec" => "vp8"}, + + # Apple HTTP Live Streaming + "91" => {"ext" => "mp4", "height" => 144, "format" => "HLS", "acodec" => "aac", "abr" => 48, "vcodec" => "h264"}, + "92" => {"ext" => "mp4", "height" => 240, "format" => "HLS", "acodec" => "aac", "abr" => 48, "vcodec" => "h264"}, + "93" => {"ext" => "mp4", "height" => 360, "format" => "HLS", "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, + "94" => {"ext" => "mp4", "height" => 480, "format" => "HLS", "acodec" => "aac", "abr" => 128, "vcodec" => "h264"}, + "95" => {"ext" => "mp4", "height" => 720, "format" => "HLS", "acodec" => "aac", "abr" => 256, "vcodec" => "h264"}, + "96" => {"ext" => "mp4", "height" => 1080, "format" => "HLS", "acodec" => "aac", "abr" => 256, "vcodec" => "h264"}, + "132" => {"ext" => "mp4", "height" => 240, "format" => "HLS", "acodec" => "aac", "abr" => 48, "vcodec" => "h264"}, + "151" => {"ext" => "mp4", "height" => 72, "format" => "HLS", "acodec" => "aac", "abr" => 24, "vcodec" => "h264"}, + + # DASH mp4 video + "133" => {"ext" => "mp4", "height" => 240, "format" => "DASH video", "vcodec" => "h264"}, + "134" => {"ext" => "mp4", "height" => 360, "format" => "DASH video", "vcodec" => "h264"}, + "135" => {"ext" => "mp4", "height" => 480, "format" => "DASH video", "vcodec" => "h264"}, + "136" => {"ext" => "mp4", "height" => 720, "format" => "DASH video", "vcodec" => "h264"}, + "137" => {"ext" => "mp4", "height" => 1080, "format" => "DASH video", "vcodec" => "h264"}, + "138" => {"ext" => "mp4", "format" => "DASH video", "vcodec" => "h264"}, # Height can vary (https://github.com/ytdl-org/youtube-dl/issues/4559) + "160" => {"ext" => "mp4", "height" => 144, "format" => "DASH video", "vcodec" => "h264"}, + "212" => {"ext" => "mp4", "height" => 480, "format" => "DASH video", "vcodec" => "h264"}, + "264" => {"ext" => "mp4", "height" => 1440, "format" => "DASH video", "vcodec" => "h264"}, + "298" => {"ext" => "mp4", "height" => 720, "format" => "DASH video", "vcodec" => "h264", "fps" => 60}, + "299" => {"ext" => "mp4", "height" => 1080, "format" => "DASH video", "vcodec" => "h264", "fps" => 60}, + "266" => {"ext" => "mp4", "height" => 2160, "format" => "DASH video", "vcodec" => "h264"}, + + # Dash mp4 audio + "139" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "aac", "abr" => 48, "container" => "m4a_dash"}, + "140" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "aac", "abr" => 128, "container" => "m4a_dash"}, + "141" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "aac", "abr" => 256, "container" => "m4a_dash"}, + "256" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "aac", "container" => "m4a_dash"}, + "258" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "aac", "container" => "m4a_dash"}, + "325" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "dtse", "container" => "m4a_dash"}, + "328" => {"ext" => "m4a", "format" => "DASH audio", "acodec" => "ec-3", "container" => "m4a_dash"}, + + # Dash webm + "167" => {"ext" => "webm", "height" => 360, "width" => 640, "format" => "DASH video", "container" => "webm", "vcodec" => "vp8"}, + "168" => {"ext" => "webm", "height" => 480, "width" => 854, "format" => "DASH video", "container" => "webm", "vcodec" => "vp8"}, + "169" => {"ext" => "webm", "height" => 720, "width" => 1280, "format" => "DASH video", "container" => "webm", "vcodec" => "vp8"}, + "170" => {"ext" => "webm", "height" => 1080, "width" => 1920, "format" => "DASH video", "container" => "webm", "vcodec" => "vp8"}, + "218" => {"ext" => "webm", "height" => 480, "width" => 854, "format" => "DASH video", "container" => "webm", "vcodec" => "vp8"}, + "219" => {"ext" => "webm", "height" => 480, "width" => 854, "format" => "DASH video", "container" => "webm", "vcodec" => "vp8"}, + "278" => {"ext" => "webm", "height" => 144, "format" => "DASH video", "container" => "webm", "vcodec" => "vp9"}, + "242" => {"ext" => "webm", "height" => 240, "format" => "DASH video", "vcodec" => "vp9"}, + "243" => {"ext" => "webm", "height" => 360, "format" => "DASH video", "vcodec" => "vp9"}, + "244" => {"ext" => "webm", "height" => 480, "format" => "DASH video", "vcodec" => "vp9"}, + "245" => {"ext" => "webm", "height" => 480, "format" => "DASH video", "vcodec" => "vp9"}, + "246" => {"ext" => "webm", "height" => 480, "format" => "DASH video", "vcodec" => "vp9"}, + "247" => {"ext" => "webm", "height" => 720, "format" => "DASH video", "vcodec" => "vp9"}, + "248" => {"ext" => "webm", "height" => 1080, "format" => "DASH video", "vcodec" => "vp9"}, + "271" => {"ext" => "webm", "height" => 1440, "format" => "DASH video", "vcodec" => "vp9"}, + # itag 272 videos are either 3840x2160 (e.g. RtoitU2A-3E) or 7680x4320 (sLprVF6d7Ug) + "272" => {"ext" => "webm", "height" => 2160, "format" => "DASH video", "vcodec" => "vp9"}, + "302" => {"ext" => "webm", "height" => 720, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, + "303" => {"ext" => "webm", "height" => 1080, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, + "308" => {"ext" => "webm", "height" => 1440, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, + "313" => {"ext" => "webm", "height" => 2160, "format" => "DASH video", "vcodec" => "vp9"}, + "315" => {"ext" => "webm", "height" => 2160, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, + "330" => {"ext" => "webm", "height" => 144, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, + "331" => {"ext" => "webm", "height" => 240, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, + "332" => {"ext" => "webm", "height" => 360, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, + "333" => {"ext" => "webm", "height" => 480, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, + "334" => {"ext" => "webm", "height" => 720, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, + "335" => {"ext" => "webm", "height" => 1080, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, + "336" => {"ext" => "webm", "height" => 1440, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, + "337" => {"ext" => "webm", "height" => 2160, "format" => "DASH video", "vcodec" => "vp9", "fps" => 60}, + + # Dash webm audio + "171" => {"ext" => "webm", "acodec" => "vorbis", "format" => "DASH audio", "abr" => 128}, + "172" => {"ext" => "webm", "acodec" => "vorbis", "format" => "DASH audio", "abr" => 256}, + + # Dash webm audio with opus inside + "249" => {"ext" => "webm", "format" => "DASH audio", "acodec" => "opus", "abr" => 50}, + "250" => {"ext" => "webm", "format" => "DASH audio", "acodec" => "opus", "abr" => 70}, + "251" => {"ext" => "webm", "format" => "DASH audio", "acodec" => "opus", "abr" => 160}, + + # av01 video only formats sometimes served with "unknown" codecs + "394" => {"ext" => "mp4", "height" => 144, "vcodec" => "av01.0.05M.08"}, + "395" => {"ext" => "mp4", "height" => 240, "vcodec" => "av01.0.05M.08"}, + "396" => {"ext" => "mp4", "height" => 360, "vcodec" => "av01.0.05M.08"}, + "397" => {"ext" => "mp4", "height" => 480, "vcodec" => "av01.0.05M.08"}, + } +end From 9baaef412fe1615eac4fd1508ef879de6b7a8805 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Mon, 23 May 2022 22:29:10 +0200 Subject: [PATCH 04/73] videos: move 'VideoPreferences' and its associated function to a separate file This will require some rework later. --- src/invidious/videos.cr | 157 ---------------------- src/invidious/videos/video_preferences.cr | 156 +++++++++++++++++++++ 2 files changed, 156 insertions(+), 157 deletions(-) create mode 100644 src/invidious/videos/video_preferences.cr diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 3a71f163..f4012666 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -131,34 +131,6 @@ CAPTION_LANGUAGES = { "Zulu", } -struct VideoPreferences - include JSON::Serializable - - property annotations : Bool - property autoplay : Bool - property comments : Array(String) - property continue : Bool - property continue_autoplay : Bool - property controls : Bool - property listen : Bool - property local : Bool - property preferred_captions : Array(String) - property player_style : String - property quality : String - property quality_dash : String - property raw : Bool - property region : String? - property related_videos : Bool - property speed : Float32 | Float64 - property video_end : Float64 | Int32 - property video_loop : Bool - property extend_desc : Bool - property video_start : Float64 | Int32 - property volume : Int32 - property vr_mode : Bool - property save_player_pos : Bool -end - struct Video include DB::Serializable @@ -1067,135 +1039,6 @@ def process_continuation(query, plid, id) continuation end -def process_video_params(query, preferences) - annotations = query["iv_load_policy"]?.try &.to_i? - autoplay = query["autoplay"]?.try { |q| (q == "true" || q == "1").to_unsafe } - comments = query["comments"]?.try &.split(",").map(&.downcase) - continue = query["continue"]?.try { |q| (q == "true" || q == "1").to_unsafe } - continue_autoplay = query["continue_autoplay"]?.try { |q| (q == "true" || q == "1").to_unsafe } - listen = query["listen"]?.try { |q| (q == "true" || q == "1").to_unsafe } - local = query["local"]?.try { |q| (q == "true" || q == "1").to_unsafe } - player_style = query["player_style"]? - preferred_captions = query["subtitles"]?.try &.split(",").map(&.downcase) - quality = query["quality"]? - quality_dash = query["quality_dash"]? - region = query["region"]? - related_videos = query["related_videos"]?.try { |q| (q == "true" || q == "1").to_unsafe } - speed = query["speed"]?.try &.rchop("x").to_f? - video_loop = query["loop"]?.try { |q| (q == "true" || q == "1").to_unsafe } - 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 - annotations ||= preferences.annotations.to_unsafe - autoplay ||= preferences.autoplay.to_unsafe - comments ||= preferences.comments - continue ||= preferences.continue.to_unsafe - continue_autoplay ||= preferences.continue_autoplay.to_unsafe - listen ||= preferences.listen.to_unsafe - local ||= preferences.local.to_unsafe - player_style ||= preferences.player_style - preferred_captions ||= preferences.captions - quality ||= preferences.quality - quality_dash ||= preferences.quality_dash - related_videos ||= preferences.related_videos.to_unsafe - speed ||= preferences.speed - video_loop ||= preferences.video_loop.to_unsafe - 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 - autoplay ||= CONFIG.default_user_preferences.autoplay.to_unsafe - comments ||= CONFIG.default_user_preferences.comments - continue ||= CONFIG.default_user_preferences.continue.to_unsafe - continue_autoplay ||= CONFIG.default_user_preferences.continue_autoplay.to_unsafe - listen ||= CONFIG.default_user_preferences.listen.to_unsafe - local ||= CONFIG.default_user_preferences.local.to_unsafe - player_style ||= CONFIG.default_user_preferences.player_style - preferred_captions ||= CONFIG.default_user_preferences.captions - quality ||= CONFIG.default_user_preferences.quality - quality_dash ||= CONFIG.default_user_preferences.quality_dash - related_videos ||= CONFIG.default_user_preferences.related_videos.to_unsafe - speed ||= CONFIG.default_user_preferences.speed - video_loop ||= CONFIG.default_user_preferences.video_loop.to_unsafe - 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 - continue = continue == 1 - continue_autoplay = continue_autoplay == 1 - listen = listen == 1 - local = local == 1 - related_videos = related_videos == 1 - 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" - end - - if CONFIG.disabled?("local") && local - local = false - end - - if start = query["t"]? || query["time_continue"]? || query["start"]? - video_start = decode_time(start) - end - video_start ||= 0 - - if query["end"]? - video_end = decode_time(query["end"]) - end - video_end ||= -1 - - raw = query["raw"]?.try &.to_i? - raw ||= 0 - raw = raw == 1 - - controls = query["controls"]?.try &.to_i? - controls ||= 1 - controls = controls >= 1 - - params = VideoPreferences.new({ - annotations: annotations, - autoplay: autoplay, - comments: comments, - continue: continue, - continue_autoplay: continue_autoplay, - controls: controls, - listen: listen, - local: local, - player_style: player_style, - preferred_captions: preferred_captions, - quality: quality, - quality_dash: quality_dash, - raw: raw, - region: region, - related_videos: related_videos, - speed: speed, - video_end: video_end, - video_loop: video_loop, - extend_desc: extend_desc, - video_start: video_start, - volume: volume, - vr_mode: vr_mode, - save_player_pos: save_player_pos, - }) - - return params -end - def build_thumbnails(id) return { {host: HOST_URL, height: 720, width: 1280, name: "maxres", url: "maxres"}, diff --git a/src/invidious/videos/video_preferences.cr b/src/invidious/videos/video_preferences.cr new file mode 100644 index 00000000..34cf7ff0 --- /dev/null +++ b/src/invidious/videos/video_preferences.cr @@ -0,0 +1,156 @@ +struct VideoPreferences + include JSON::Serializable + + property annotations : Bool + property autoplay : Bool + property comments : Array(String) + property continue : Bool + property continue_autoplay : Bool + property controls : Bool + property listen : Bool + property local : Bool + property preferred_captions : Array(String) + property player_style : String + property quality : String + property quality_dash : String + property raw : Bool + property region : String? + property related_videos : Bool + property speed : Float32 | Float64 + property video_end : Float64 | Int32 + property video_loop : Bool + property extend_desc : Bool + property video_start : Float64 | Int32 + property volume : Int32 + property vr_mode : Bool + property save_player_pos : Bool +end + +def process_video_params(query, preferences) + annotations = query["iv_load_policy"]?.try &.to_i? + autoplay = query["autoplay"]?.try { |q| (q == "true" || q == "1").to_unsafe } + comments = query["comments"]?.try &.split(",").map(&.downcase) + continue = query["continue"]?.try { |q| (q == "true" || q == "1").to_unsafe } + continue_autoplay = query["continue_autoplay"]?.try { |q| (q == "true" || q == "1").to_unsafe } + listen = query["listen"]?.try { |q| (q == "true" || q == "1").to_unsafe } + local = query["local"]?.try { |q| (q == "true" || q == "1").to_unsafe } + player_style = query["player_style"]? + preferred_captions = query["subtitles"]?.try &.split(",").map(&.downcase) + quality = query["quality"]? + quality_dash = query["quality_dash"]? + region = query["region"]? + related_videos = query["related_videos"]?.try { |q| (q == "true" || q == "1").to_unsafe } + speed = query["speed"]?.try &.rchop("x").to_f? + video_loop = query["loop"]?.try { |q| (q == "true" || q == "1").to_unsafe } + 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 + annotations ||= preferences.annotations.to_unsafe + autoplay ||= preferences.autoplay.to_unsafe + comments ||= preferences.comments + continue ||= preferences.continue.to_unsafe + continue_autoplay ||= preferences.continue_autoplay.to_unsafe + listen ||= preferences.listen.to_unsafe + local ||= preferences.local.to_unsafe + player_style ||= preferences.player_style + preferred_captions ||= preferences.captions + quality ||= preferences.quality + quality_dash ||= preferences.quality_dash + related_videos ||= preferences.related_videos.to_unsafe + speed ||= preferences.speed + video_loop ||= preferences.video_loop.to_unsafe + 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 + autoplay ||= CONFIG.default_user_preferences.autoplay.to_unsafe + comments ||= CONFIG.default_user_preferences.comments + continue ||= CONFIG.default_user_preferences.continue.to_unsafe + continue_autoplay ||= CONFIG.default_user_preferences.continue_autoplay.to_unsafe + listen ||= CONFIG.default_user_preferences.listen.to_unsafe + local ||= CONFIG.default_user_preferences.local.to_unsafe + player_style ||= CONFIG.default_user_preferences.player_style + preferred_captions ||= CONFIG.default_user_preferences.captions + quality ||= CONFIG.default_user_preferences.quality + quality_dash ||= CONFIG.default_user_preferences.quality_dash + related_videos ||= CONFIG.default_user_preferences.related_videos.to_unsafe + speed ||= CONFIG.default_user_preferences.speed + video_loop ||= CONFIG.default_user_preferences.video_loop.to_unsafe + 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 + continue = continue == 1 + continue_autoplay = continue_autoplay == 1 + listen = listen == 1 + local = local == 1 + related_videos = related_videos == 1 + 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" + end + + if CONFIG.disabled?("local") && local + local = false + end + + if start = query["t"]? || query["time_continue"]? || query["start"]? + video_start = decode_time(start) + end + video_start ||= 0 + + if query["end"]? + video_end = decode_time(query["end"]) + end + video_end ||= -1 + + raw = query["raw"]?.try &.to_i? + raw ||= 0 + raw = raw == 1 + + controls = query["controls"]?.try &.to_i? + controls ||= 1 + controls = controls >= 1 + + params = VideoPreferences.new({ + annotations: annotations, + autoplay: autoplay, + comments: comments, + continue: continue, + continue_autoplay: continue_autoplay, + controls: controls, + listen: listen, + local: local, + player_style: player_style, + preferred_captions: preferred_captions, + quality: quality, + quality_dash: quality_dash, + raw: raw, + region: region, + related_videos: related_videos, + speed: speed, + video_end: video_end, + video_loop: video_loop, + extend_desc: extend_desc, + video_start: video_start, + volume: volume, + vr_mode: vr_mode, + save_player_pos: save_player_pos, + }) + + return params +end From cd03fa06aee7596446c0bbe9b77c3832419e8146 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Mon, 23 May 2022 22:37:58 +0200 Subject: [PATCH 05/73] videos: move 'Caption' and associated global/functions to a separate file --- spec/spec_helper.cr | 1 + src/invidious/frontend/watch_page.cr | 2 +- src/invidious/videos.cr | 168 +---------------------- src/invidious/videos/caption.cr | 168 +++++++++++++++++++++++ src/invidious/views/user/preferences.ecr | 2 +- 5 files changed, 177 insertions(+), 164 deletions(-) create mode 100644 src/invidious/videos/caption.cr diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr index 6c492e2f..f8bfa718 100644 --- a/spec/spec_helper.cr +++ b/spec/spec_helper.cr @@ -5,6 +5,7 @@ require "protodec/utils" require "yaml" require "../src/invidious/helpers/*" require "../src/invidious/channels/*" +require "../src/invidious/videos/caption" require "../src/invidious/videos" require "../src/invidious/comments" require "../src/invidious/playlists" diff --git a/src/invidious/frontend/watch_page.cr b/src/invidious/frontend/watch_page.cr index 9212eb2f..a9b00860 100644 --- a/src/invidious/frontend/watch_page.cr +++ b/src/invidious/frontend/watch_page.cr @@ -7,7 +7,7 @@ module Invidious::Frontend::WatchPage getter full_videos : Array(Hash(String, JSON::Any)) getter video_streams : Array(Hash(String, JSON::Any)) getter audio_streams : Array(Hash(String, JSON::Any)) - getter captions : Array(Caption) + getter captions : Array(Invidious::Videos::Caption) def initialize( @full_videos, diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index f4012666..45a44c29 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -1,136 +1,3 @@ -CAPTION_LANGUAGES = { - "", - "English", - "English (auto-generated)", - "English (United Kingdom)", - "English (United States)", - "Afrikaans", - "Albanian", - "Amharic", - "Arabic", - "Armenian", - "Azerbaijani", - "Bangla", - "Basque", - "Belarusian", - "Bosnian", - "Bulgarian", - "Burmese", - "Cantonese (Hong Kong)", - "Catalan", - "Cebuano", - "Chinese", - "Chinese (China)", - "Chinese (Hong Kong)", - "Chinese (Simplified)", - "Chinese (Taiwan)", - "Chinese (Traditional)", - "Corsican", - "Croatian", - "Czech", - "Danish", - "Dutch", - "Dutch (auto-generated)", - "Esperanto", - "Estonian", - "Filipino", - "Finnish", - "French", - "French (auto-generated)", - "Galician", - "Georgian", - "German", - "German (auto-generated)", - "Greek", - "Gujarati", - "Haitian Creole", - "Hausa", - "Hawaiian", - "Hebrew", - "Hindi", - "Hmong", - "Hungarian", - "Icelandic", - "Igbo", - "Indonesian", - "Indonesian (auto-generated)", - "Interlingue", - "Irish", - "Italian", - "Italian (auto-generated)", - "Japanese", - "Japanese (auto-generated)", - "Javanese", - "Kannada", - "Kazakh", - "Khmer", - "Korean", - "Korean (auto-generated)", - "Kurdish", - "Kyrgyz", - "Lao", - "Latin", - "Latvian", - "Lithuanian", - "Luxembourgish", - "Macedonian", - "Malagasy", - "Malay", - "Malayalam", - "Maltese", - "Maori", - "Marathi", - "Mongolian", - "Nepali", - "Norwegian Bokmål", - "Nyanja", - "Pashto", - "Persian", - "Polish", - "Portuguese", - "Portuguese (auto-generated)", - "Portuguese (Brazil)", - "Punjabi", - "Romanian", - "Russian", - "Russian (auto-generated)", - "Samoan", - "Scottish Gaelic", - "Serbian", - "Shona", - "Sindhi", - "Sinhala", - "Slovak", - "Slovenian", - "Somali", - "Southern Sotho", - "Spanish", - "Spanish (auto-generated)", - "Spanish (Latin America)", - "Spanish (Mexico)", - "Spanish (Spain)", - "Sundanese", - "Swahili", - "Swedish", - "Tajik", - "Tamil", - "Telugu", - "Thai", - "Turkish", - "Turkish (auto-generated)", - "Ukrainian", - "Urdu", - "Uzbek", - "Vietnamese", - "Vietnamese (auto-generated)", - "Welsh", - "Western Frisian", - "Xhosa", - "Yiddish", - "Yoruba", - "Zulu", -} - struct Video include DB::Serializable @@ -141,7 +8,7 @@ struct Video property updated : Time @[DB::Field(ignore: true)] - property captions : Array(Caption)? + @captions = [] of Invidious::Videos::Caption @[DB::Field(ignore: true)] property adaptive_fmts : Array(Hash(String, JSON::Any))? @@ -595,20 +462,12 @@ struct Video keywords.includes? "YouTube Red" end - def captions : Array(Caption) - return @captions.as(Array(Caption)) if @captions - captions = info["captions"]?.try &.["playerCaptionsTracklistRenderer"]?.try &.["captionTracks"]?.try &.as_a.map do |caption| - name = caption["name"]["simpleText"]? || caption["name"]["runs"][0]["text"] - language_code = caption["languageCode"].to_s - base_url = caption["baseUrl"].to_s - - caption = Caption.new(name.to_s, language_code, base_url) - caption.name = caption.name.split(" - ")[0] - caption + def captions : Array(Invidious::Videos::Caption) + if @captions.empty? && @info.has_key?("captions") + @captions = Invidious::Videos::Caption.from_yt_json(info["captions"]) end - captions ||= [] of Caption - @captions = captions - return @captions.as(Array(Caption)) + + return @captions end def description @@ -672,21 +531,6 @@ struct Video end end -struct Caption - property name - property language_code - property base_url - - getter name : String - getter language_code : String - getter base_url : String - - setter name - - def initialize(@name, @language_code, @base_url) - end -end - class VideoRedirect < Exception property video_id : String diff --git a/src/invidious/videos/caption.cr b/src/invidious/videos/caption.cr new file mode 100644 index 00000000..4642c1a7 --- /dev/null +++ b/src/invidious/videos/caption.cr @@ -0,0 +1,168 @@ +require "json" + +module Invidious::Videos + struct Caption + property name : String + property language_code : String + property base_url : String + + def initialize(@name, @language_code, @base_url) + end + + # Parse the JSON structure from Youtube + def self.from_yt_json(container : JSON::Any) : Array(Caption) + caption_tracks = container + .dig?("playerCaptionsTracklistRenderer", "captionTracks") + .try &.as_a + + captions_list = [] of Caption + return captions_list if caption_tracks.nil? + + caption_tracks.each do |caption| + name = caption["name"]["simpleText"]? || caption["name"]["runs"][0]["text"] + name = name.to_s.split(" - ")[0] + + language_code = caption["languageCode"].to_s + base_url = caption["baseUrl"].to_s + + captions_list << Caption.new(name, language_code, base_url) + end + + return captions_list + end + + # List of all caption languages available on Youtube. + LANGUAGES = { + "", + "English", + "English (auto-generated)", + "English (United Kingdom)", + "English (United States)", + "Afrikaans", + "Albanian", + "Amharic", + "Arabic", + "Armenian", + "Azerbaijani", + "Bangla", + "Basque", + "Belarusian", + "Bosnian", + "Bulgarian", + "Burmese", + "Cantonese (Hong Kong)", + "Catalan", + "Cebuano", + "Chinese", + "Chinese (China)", + "Chinese (Hong Kong)", + "Chinese (Simplified)", + "Chinese (Taiwan)", + "Chinese (Traditional)", + "Corsican", + "Croatian", + "Czech", + "Danish", + "Dutch", + "Dutch (auto-generated)", + "Esperanto", + "Estonian", + "Filipino", + "Finnish", + "French", + "French (auto-generated)", + "Galician", + "Georgian", + "German", + "German (auto-generated)", + "Greek", + "Gujarati", + "Haitian Creole", + "Hausa", + "Hawaiian", + "Hebrew", + "Hindi", + "Hmong", + "Hungarian", + "Icelandic", + "Igbo", + "Indonesian", + "Indonesian (auto-generated)", + "Interlingue", + "Irish", + "Italian", + "Italian (auto-generated)", + "Japanese", + "Japanese (auto-generated)", + "Javanese", + "Kannada", + "Kazakh", + "Khmer", + "Korean", + "Korean (auto-generated)", + "Kurdish", + "Kyrgyz", + "Lao", + "Latin", + "Latvian", + "Lithuanian", + "Luxembourgish", + "Macedonian", + "Malagasy", + "Malay", + "Malayalam", + "Maltese", + "Maori", + "Marathi", + "Mongolian", + "Nepali", + "Norwegian Bokmål", + "Nyanja", + "Pashto", + "Persian", + "Polish", + "Portuguese", + "Portuguese (auto-generated)", + "Portuguese (Brazil)", + "Punjabi", + "Romanian", + "Russian", + "Russian (auto-generated)", + "Samoan", + "Scottish Gaelic", + "Serbian", + "Shona", + "Sindhi", + "Sinhala", + "Slovak", + "Slovenian", + "Somali", + "Southern Sotho", + "Spanish", + "Spanish (auto-generated)", + "Spanish (Latin America)", + "Spanish (Mexico)", + "Spanish (Spain)", + "Sundanese", + "Swahili", + "Swedish", + "Tajik", + "Tamil", + "Telugu", + "Thai", + "Turkish", + "Turkish (auto-generated)", + "Ukrainian", + "Urdu", + "Uzbek", + "Vietnamese", + "Vietnamese (auto-generated)", + "Welsh", + "Western Frisian", + "Xhosa", + "Yiddish", + "Yoruba", + "Zulu", + } + end +end diff --git a/src/invidious/views/user/preferences.ecr b/src/invidious/views/user/preferences.ecr index dbb5e9db..d841982c 100644 --- a/src/invidious/views/user/preferences.ecr +++ b/src/invidious/views/user/preferences.ecr @@ -89,7 +89,7 @@ <% preferences.captions.each_with_index do |caption, index| %> From 6aaea7fafa72aecc224089a6b52cad6e6d6daa0f Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sun, 24 Jul 2022 23:30:58 +0200 Subject: [PATCH 06/73] Videos: parse data during first fetching There will be less data to be stores in the DB cache --- .../videos/scheduled_live_extract_spec.cr | 2 - src/invidious/videos.cr | 300 +++++++++++------- 2 files changed, 182 insertions(+), 120 deletions(-) diff --git a/spec/invidious/videos/scheduled_live_extract_spec.cr b/spec/invidious/videos/scheduled_live_extract_spec.cr index 6e531bbd..b80aec0c 100644 --- a/spec/invidious/videos/scheduled_live_extract_spec.cr +++ b/spec/invidious/videos/scheduled_live_extract_spec.cr @@ -22,7 +22,6 @@ Spectator.describe Invidious::Hashtag do expect(info["likes"].as_i).to eq(2_283) expect(info["genre"].as_s).to eq("Gaming") - expect(info["genreUrl"].raw).to be_nil expect(info["genreUcid"].as_s).to be_empty expect(info["license"].as_s).to be_empty @@ -81,7 +80,6 @@ Spectator.describe Invidious::Hashtag do expect(info["likes"].as_i).to eq(22) expect(info["genre"].as_s).to eq("Entertainment") - expect(info["genreUrl"].raw).to be_nil expect(info["genreUcid"].as_s).to be_empty expect(info["license"].as_s).to be_empty diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 45a44c29..6211bcd7 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -1,3 +1,9 @@ +enum VideoType + Video + Livestream + Scheduled +end + struct Video include DB::Serializable @@ -27,7 +33,7 @@ struct Video def to_json(locale : String?, json : JSON::Builder) json.object do - json.field "type", "video" + json.field "type", self.video_type json.field "title", self.title json.field "videoId", self.id @@ -253,61 +259,22 @@ struct Video to_json(nil, json) end - def title - info["videoDetails"]["title"]?.try &.as_s || "" - end - - def ucid - info["videoDetails"]["channelId"]?.try &.as_s || "" - end - - def author - info["videoDetails"]["author"]?.try &.as_s || "" - end - - def length_seconds : Int32 - info.dig?("microformat", "playerMicroformatRenderer", "lengthSeconds").try &.as_s.to_i || - info["videoDetails"]["lengthSeconds"]?.try &.as_s.to_i || 0 - end - - def views : Int64 - info["videoDetails"]["viewCount"]?.try &.as_s.to_i64 || 0_i64 - end - - def likes : Int64 - info["likes"]?.try &.as_i64 || 0_i64 - end - - def dislikes : Int64 - info["dislikes"]?.try &.as_i64 || 0_i64 + def video_type : VideoType + video_type = info["videoType"]?.try &.as_s || "video" + return VideoType.parse?(video_type) || VideoType::Video end def published : Time - info - .dig?("microformat", "playerMicroformatRenderer", "publishDate") + return info["published"]? .try { |t| Time.parse(t.as_s, "%Y-%m-%d", Time::Location::UTC) } || Time.utc end def published=(other : Time) - info["microformat"].as_h["playerMicroformatRenderer"].as_h["publishDate"] = JSON::Any.new(other.to_s("%Y-%m-%d")) - end - - def allow_ratings - r = info["videoDetails"]["allowRatings"]?.try &.as_bool - r.nil? ? false : r + info["published"] = JSON::Any.new(other.to_s("%Y-%m-%d")) end def live_now - info["microformat"]?.try &.["playerMicroformatRenderer"]? - .try &.["liveBroadcastDetails"]?.try &.["isLiveNow"]?.try &.as_bool || false - end - - def is_listed - info["videoDetails"]["isCrawlable"]?.try &.as_bool || false - end - - def is_upcoming - info["videoDetails"]["isUpcoming"]?.try &.as_bool || false + return (self.video_type == VideoType::Livestream) end def premiere_timestamp : Time? @@ -316,31 +283,11 @@ struct Video .try { |t| Time.parse_rfc3339(t.as_s) } end - def keywords - info["videoDetails"]["keywords"]?.try &.as_a.map &.as_s || [] of String - end - def related_videos info["relatedVideos"]?.try &.as_a.map { |h| h.as_h.transform_values &.as_s } || [] of Hash(String, String) end - def allowed_regions - info - .dig?("microformat", "playerMicroformatRenderer", "availableCountries") - .try &.as_a.map &.as_s || [] of String - end - - def author_thumbnail : String - info["authorThumbnail"]?.try &.as_s || "" - end - - def author_verified : Bool - info["authorVerified"]?.try &.as_bool || false - end - - def sub_count_text : String - info["subCountText"]?.try &.as_s || "-" - end + # Methods for parsing streaming data def fmt_stream return @fmt_stream.as(Array(Hash(String, JSON::Any))) if @fmt_stream @@ -391,6 +338,8 @@ struct Video adaptive_fmts.select &.["mimeType"]?.try &.as_s.starts_with?("audio") end + # Misc. methods + def storyboards storyboards = info.dig?("storyboards", "playerStoryboardSpecRenderer", "spec") .try &.as_s.split("|") @@ -454,8 +403,7 @@ struct Video end def paid - reason = info.dig?("playabilityStatus", "reason").try &.as_s || "" - return reason.includes? "requires payment" + return (self.reason || "").includes? "requires payment" end def premium @@ -470,29 +418,6 @@ struct Video return @captions end - def description - description = info - .dig?("microformat", "playerMicroformatRenderer", "description", "simpleText") - .try &.as_s || "" - end - - # TODO - def description=(value : String) - @description = value - end - - def description_html - info["descriptionHtml"]?.try &.as_s || "

" - end - - def description_html=(value : String) - info["descriptionHtml"] = JSON::Any.new(value) - end - - def short_description - info["shortDescription"]?.try &.as_s? || "" - end - def hls_manifest_url : String? info.dig?("streamingData", "hlsManifestUrl").try &.as_s end @@ -501,25 +426,12 @@ struct Video info.dig?("streamingData", "dashManifestUrl").try &.as_s end - def genre : String - info["genre"]?.try &.as_s || "" - end - def genre_url : String? info["genreUcid"]? ? "/channel/#{info["genreUcid"]}" : nil end - def license : String? - info["license"]?.try &.as_s - end - - def is_family_friendly : Bool - info.dig?("microformat", "playerMicroformatRenderer", "isFamilySafe").try &.as_bool || false - end - def is_vr : Bool? - projection_type = info.dig?("streamingData", "adaptiveFormats", 0, "projectionType").try &.as_s - return {"EQUIRECTANGULAR", "MESH"}.includes? projection_type + return {"EQUIRECTANGULAR", "MESH"}.includes? self.projection_type end def projection_type : String? @@ -529,6 +441,91 @@ struct Video def reason : String? info["reason"]?.try &.as_s end + + # Macros defining getters/setters for various types of data + + private macro getset_string(name) + # Return {{name.stringify}} from `info` + def {{name.id.underscore}} : String + return info[{{name.stringify}}]?.try &.as_s || "" + end + + # Update {{name.stringify}} into `info` + def {{name.id.underscore}}=(value : String) + info[{{name.stringify}}] = JSON::Any.new(value) + end + + {% if flag?(:debug_macros) %} {{debug}} {% end %} + end + + private macro getset_string_array(name) + # Return {{name.stringify}} from `info` + def {{name.id.underscore}} : Array(String) + return info[{{name.stringify}}]?.try &.as_a.map &.as_s || [] of String + end + + # Update {{name.stringify}} into `info` + def {{name.id.underscore}}=(value : Array(String)) + info[{{name.stringify}}] = JSON::Any.new(value) + end + + {% if flag?(:debug_macros) %} {{debug}} {% end %} + end + + {% for op, type in {i32: Int32, i64: Int64} %} + private macro getset_{{op}}(name) + def \{{name.id.underscore}} : {{type}} + return info[\{{name.stringify}}]?.try &.as_i.to_{{op}} || 0_{{op}} + end + + def \{{name.id.underscore}}=(value : Int) + info[\{{name.stringify}}] = JSON::Any.new(value.to_i64) + end + + \{% if flag?(:debug_macros) %} \{{debug}} \{% end %} + end + {% end %} + + private macro getset_bool(name) + # Return {{name.stringify}} from `info` + def {{name.id.underscore}} : Bool + return info[{{name.stringify}}]?.try &.as_bool || false + end + + # Update {{name.stringify}} into `info` + def {{name.id.underscore}}=(value : Bool) + info[{{name.stringify}}] = JSON::Any.new(value) + end + + {% if flag?(:debug_macros) %} {{debug}} {% end %} + end + + # Method definitions, using the macros above + + getset_string author + getset_string authorThumbnail + getset_string description + getset_string descriptionHtml + getset_string genre + getset_string genreUcid + getset_string license + getset_string shortDescription + getset_string subCountText + getset_string title + getset_string ucid + + getset_string_array allowedRegions + getset_string_array keywords + + getset_i32 lengthSeconds + getset_i64 likes + getset_i64 views + + getset_bool allowRatings + getset_bool authorVerified + getset_bool isFamilyFriendly + getset_bool isListed + getset_bool isUpcoming end class VideoRedirect < Exception @@ -684,6 +681,42 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any raise BrokenTubeException.new("videoPrimaryInfoRenderer") if !video_primary_renderer raise BrokenTubeException.new("videoSecondaryInfoRenderer") if !video_secondary_renderer + video_details = player_response.dig?("videoDetails") + microformat = player_response.dig?("microformat", "playerMicroformatRenderer") + + raise BrokenTubeException.new("videoDetails") if !video_details + raise BrokenTubeException.new("microformat") if !microformat + + # Basic video infos + + title = video_details["title"]?.try &.as_s + views = video_details["viewCount"]?.try &.as_s.to_i64 + + length_txt = (microformat["lengthSeconds"]? || video_details["lengthSeconds"]) + .try &.as_s.to_i64 + + published = microformat["publishDate"]? + .try { |t| Time.parse(t.as_s, "%Y-%m-%d", Time::Location::UTC) } || Time.utc + + premiere_timestamp = microformat.dig?("liveBroadcastDetails", "startTimestamp") + .try { |t| Time.parse_rfc3339(t.as_s) } + + live_now = microformat.dig?("liveBroadcastDetails", "isLiveNow") + .try &.as_bool || false + + # Extra video infos + + allowed_regions = microformat["availableCountries"]? + .try &.as_a.map &.as_s || [] of String + + allow_ratings = video_details["allowRatings"]?.try &.as_bool + family_friendly = microformat["isFamilySafe"].try &.as_bool + is_listed = video_details["isCrawlable"]?.try &.as_bool + is_upcoming = video_details["isUpcoming"]?.try &.as_bool + + keywords = video_details["keywords"]? + .try &.as_a.map &.as_s || [] of String + # Related videos LOGGER.debug("extract_video_info: parsing related videos...") @@ -738,6 +771,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any # Description + description = microformat.dig?("description", "simpleText").try &.as_s || "" short_description = player_response.dig?("videoDetails", "shortDescription") description_html = video_secondary_renderer.try &.dig?("description", "runs") @@ -749,7 +783,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any .try &.dig?("metadataRowContainer", "metadataRowContainerRenderer", "rows") .try &.as_a - genre = player_response.dig?("microformat", "playerMicroformatRenderer", "category") + genre = microformat["category"]? genre_ucid = nil license = nil @@ -771,6 +805,9 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any # Author infos + author = video_details["author"]?.try &.as_s + ucid = video_details["channelId"]?.try &.as_s + if author_info = video_secondary_renderer.try &.dig?("owner", "videoOwnerRenderer") author_thumbnail = author_info.dig?("thumbnail", "thumbnails", 0, "url") author_verified = has_verified_badge?(author_info["badges"]?) @@ -782,19 +819,46 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any # Return data + if live_now + video_type = VideoType::Livestream + elsif premiere_timestamp.not_nil! + video_type = VideoType::Scheduled + published = premiere_timestamp || Time.utc + else + video_type = VideoType::Video + end + params = { - "shortDescription" => JSON::Any.new(short_description.try &.as_s || nil), - "relatedVideos" => JSON::Any.new(related), - "likes" => JSON::Any.new(likes || 0_i64), - "dislikes" => JSON::Any.new(0_i64), + "videoType" => JSON::Any.new(video_type.to_s), + # Basic video infos + "title" => JSON::Any.new(title || ""), + "views" => JSON::Any.new(views || 0_i64), + "likes" => JSON::Any.new(likes || 0_i64), + "lengthSeconds" => JSON::Any.new(length_txt || 0_i64), + "published" => JSON::Any.new(published.to_rfc3339), + # Extra video infos + "allowedRegions" => JSON::Any.new(allowed_regions.map { |v| JSON::Any.new(v) }), + "allowRatings" => JSON::Any.new(allow_ratings || false), + "isFamilyFriendly" => JSON::Any.new(family_friendly || false), + "isListed" => JSON::Any.new(is_listed || false), + "isUpcoming" => JSON::Any.new(is_upcoming || false), + "keywords" => JSON::Any.new(keywords.map { |v| JSON::Any.new(v) }), + # Related videos + "relatedVideos" => JSON::Any.new(related), + # Description + "description" => JSON::Any.new(description || ""), "descriptionHtml" => JSON::Any.new(description_html || "

"), - "genre" => JSON::Any.new(genre.try &.as_s || ""), - "genreUrl" => JSON::Any.new(nil), - "genreUcid" => JSON::Any.new(genre_ucid.try &.as_s || ""), - "license" => JSON::Any.new(license.try &.as_s || ""), - "authorThumbnail" => JSON::Any.new(author_thumbnail.try &.as_s || ""), - "authorVerified" => JSON::Any.new(author_verified), - "subCountText" => JSON::Any.new(subs_text || "-"), + "shortDescription" => JSON::Any.new(short_description.try &.as_s || nil), + # Video metadata + "genre" => JSON::Any.new(genre.try &.as_s || ""), + "genreUcid" => JSON::Any.new(genre_ucid.try &.as_s || ""), + "license" => JSON::Any.new(license.try &.as_s || ""), + # Author infos + "author" => JSON::Any.new(author || ""), + "ucid" => JSON::Any.new(ucid || ""), + "authorThumbnail" => JSON::Any.new(author_thumbnail.try &.as_s || ""), + "authorVerified" => JSON::Any.new(author_verified), + "subCountText" => JSON::Any.new(subs_text || "-"), } return params From 907ddfa06a08ace8e7f6806e4e8567a18903a790 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 2 Aug 2022 18:45:43 +0200 Subject: [PATCH 07/73] spec: Add tests for recent changes --- .../videos/scheduled_live_extract_spec.cr | 185 ++++++++++++++---- 1 file changed, 151 insertions(+), 34 deletions(-) diff --git a/spec/invidious/videos/scheduled_live_extract_spec.cr b/spec/invidious/videos/scheduled_live_extract_spec.cr index b80aec0c..ff5aacd5 100644 --- a/spec/invidious/videos/scheduled_live_extract_spec.cr +++ b/spec/invidious/videos/scheduled_live_extract_spec.cr @@ -1,6 +1,6 @@ require "../../parsers_helper.cr" -Spectator.describe Invidious::Hashtag do +Spectator.describe "parse_video_info" do it "parses scheduled livestreams data (test 1)" do # Enable mock _player = load_mock("video/scheduled_live_nintendo.player") @@ -12,25 +12,50 @@ Spectator.describe Invidious::Hashtag do # Some basic verifications expect(typeof(info)).to eq(Hash(String, JSON::Any)) - expect(info["shortDescription"].as_s).to eq( - "Tune in on 6/22 at 7 a.m. PT for a livestreamed Xenoblade Chronicles 3 Direct presentation featuring roughly 20 minutes of information about the upcoming RPG adventure for Nintendo Switch." - ) - expect(info["descriptionHtml"].as_s).to eq( - "Tune in on 6/22 at 7 a.m. PT for a livestreamed Xenoblade Chronicles 3 Direct presentation featuring roughly 20 minutes of information about the upcoming RPG adventure for Nintendo Switch." - ) + expect(info["videoType"].as_s).to eq("Scheduled") + # Basic video infos + + expect(info["title"].as_s).to eq("Xenoblade Chronicles 3 Nintendo Direct") + expect(info["views"].as_i).to eq(160) expect(info["likes"].as_i).to eq(2_283) + expect(info["lengthSeconds"].as_i).to eq(0_i64) + expect(info["published"].as_s).to eq("2022-06-22T14:00:00Z") # Unix 1655906400 - expect(info["genre"].as_s).to eq("Gaming") - expect(info["genreUcid"].as_s).to be_empty - expect(info["license"].as_s).to be_empty + # Extra video infos - expect(info["authorThumbnail"].as_s).to eq( - "https://yt3.ggpht.com/ytc/AKedOLTt4vtjREUUNdHlyu9c4gtJjG90M9jQheRlLKy44A=s48-c-k-c0x00ffffff-no-rj" + expect(info["allowedRegions"].as_a).to_not be_empty + expect(info["allowedRegions"].as_a.size).to eq(249) + + expect(info["allowedRegions"].as_a).to contain( + "AD", "BA", "BB", "BW", "BY", "EG", "GG", "HN", "NP", "NR", "TR", + "TT", "TV", "TW", "TZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", + "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW" ) - expect(info["authorVerified"].as_bool).to be_true - expect(info["subCountText"].as_s).to eq("8.5M") + expect(info["keywords"].as_a).to_not be_empty + expect(info["keywords"].as_a.size).to eq(11) + + expect(info["keywords"].as_a).to contain_exactly( + "nintendo", + "game", + "gameplay", + "fun", + "video game", + "action", + "adventure", + "rpg", + "play", + "switch", + "nintendo switch" + ).in_any_order + + expect(info["allowRatings"].as_bool).to be_true + expect(info["isFamilyFriendly"].as_bool).to be_true + expect(info["isListed"].as_bool).to be_true + expect(info["isUpcoming"].as_bool).to be_true + + # Related videos expect(info["relatedVideos"].as_a.size).to eq(20) @@ -49,6 +74,32 @@ Spectator.describe Invidious::Hashtag do expect(info["relatedVideos"][16]["view_count"].as_s).to eq("53510") expect(info["relatedVideos"][16]["short_view_count"].as_s).to eq("53K") expect(info["relatedVideos"][16]["author_verified"].as_s).to eq("true") + + # Description + + description = "Tune in on 6/22 at 7 a.m. PT for a livestreamed Xenoblade Chronicles 3 Direct presentation featuring roughly 20 minutes of information about the upcoming RPG adventure for Nintendo Switch." + + expect(info["description"].as_s).to eq(description) + expect(info["shortDescription"].as_s).to eq(description) + expect(info["descriptionHtml"].as_s).to eq(description) + + # Video metadata + + expect(info["genre"].as_s).to eq("Gaming") + expect(info["genreUcid"].as_s).to be_empty + expect(info["license"].as_s).to be_empty + + # Author infos + + expect(info["author"].as_s).to eq("Nintendo") + expect(info["ucid"].as_s).to eq("UCGIY_O-8vW4rfX98KlMkvRg") + + expect(info["authorThumbnail"].as_s).to eq( + "https://yt3.ggpht.com/ytc/AKedOLTt4vtjREUUNdHlyu9c4gtJjG90M9jQheRlLKy44A=s48-c-k-c0x00ffffff-no-rj" + ) + + expect(info["authorVerified"].as_bool).to be_true + expect(info["subCountText"].as_s).to eq("8.5M") end it "parses scheduled livestreams data (test 2)" do @@ -62,33 +113,63 @@ Spectator.describe Invidious::Hashtag do # Some basic verifications expect(typeof(info)).to eq(Hash(String, JSON::Any)) - expect(info["shortDescription"].as_s).to start_with( - <<-TXT - PBD Podcast Episode 171. In this episode, Patrick Bet-David is joined by Dr. Patrick Moore and Adam Sosnick. + expect(info["videoType"].as_s).to eq("Scheduled") - Join the channel to get exclusive access to perks: https://bit.ly/3Q9rSQL - TXT - ) - expect(info["descriptionHtml"].as_s).to start_with( - <<-TXT - PBD Podcast Episode 171. In this episode, Patrick Bet-David is joined by Dr. Patrick Moore and Adam Sosnick. - - Join the channel to get exclusive access to perks: bit.ly/3Q9rSQL - TXT - ) + # Basic video infos + expect(info["title"].as_s).to eq("The Truth About Greenpeace w/ Dr. Patrick Moore | PBD Podcast | Ep. 171") + expect(info["views"].as_i).to eq(24) expect(info["likes"].as_i).to eq(22) + expect(info["lengthSeconds"].as_i).to eq(0_i64) + expect(info["published"].as_s).to eq("2022-07-14T13:00:00Z") # Unix 1657803600 - expect(info["genre"].as_s).to eq("Entertainment") - expect(info["genreUcid"].as_s).to be_empty - expect(info["license"].as_s).to be_empty + # Extra video infos - expect(info["authorThumbnail"].as_s).to eq( - "https://yt3.ggpht.com/61ArDiQshJrvSXcGLhpFfIO3hlMabe2fksitcf6oGob0Mdr5gztdkXxRljICUodL4iuTSrtxW4A=s48-c-k-c0x00ffffff-no-rj" + expect(info["allowedRegions"].as_a).to_not be_empty + expect(info["allowedRegions"].as_a.size).to eq(249) + + expect(info["allowedRegions"].as_a).to contain( + "AD", "AR", "BA", "BT", "CZ", "FO", "GL", "IO", "KE", "KH", "LS", + "LT", "MP", "NO", "PR", "RO", "SE", "SK", "SS", "SX", "SZ", "ZW" ) - expect(info["authorVerified"].as_bool).to be_false - expect(info["subCountText"].as_s).to eq("227K") + expect(info["keywords"].as_a).to_not be_empty + expect(info["keywords"].as_a.size).to eq(25) + + expect(info["keywords"].as_a).to contain_exactly( + "Patrick Bet-David", + "Valeutainment", + "The BetDavid Podcast", + "The BetDavid Show", + "Betdavid", + "PBD", + "BetDavid show", + "Betdavid podcast", + "podcast betdavid", + "podcast patrick", + "patrick bet david podcast", + "Valuetainment podcast", + "Entrepreneurs", + "Entrepreneurship", + "Entrepreneur Motivation", + "Entrepreneur Advice", + "Startup Entrepreneurs", + "valuetainment", + "patrick bet david", + "PBD podcast", + "Betdavid show", + "Betdavid Podcast", + "Podcast Betdavid", + "Show Betdavid", + "PBDPodcast" + ).in_any_order + + expect(info["allowRatings"].as_bool).to be_true + expect(info["isFamilyFriendly"].as_bool).to be_true + expect(info["isListed"].as_bool).to be_true + expect(info["isUpcoming"].as_bool).to be_true + + # Related videos expect(info["relatedVideos"].as_a.size).to eq(20) @@ -107,5 +188,41 @@ Spectator.describe Invidious::Hashtag do expect(info["relatedVideos"][9]["view_count"]).to eq("26432") expect(info["relatedVideos"][9]["short_view_count"]).to eq("26K") expect(info["relatedVideos"][9]["author_verified"]).to eq("true") + + # Description + + description_start_text = <<-TXT + PBD Podcast Episode 171. In this episode, Patrick Bet-David is joined by Dr. Patrick Moore and Adam Sosnick. + + Join the channel to get exclusive access to perks: https://bit.ly/3Q9rSQL + TXT + + expect(info["description"].as_s).to start_with(description_start_text) + expect(info["shortDescription"].as_s).to start_with(description_start_text) + + expect(info["descriptionHtml"].as_s).to start_with( + <<-TXT + PBD Podcast Episode 171. In this episode, Patrick Bet-David is joined by Dr. Patrick Moore and Adam Sosnick. + + Join the channel to get exclusive access to perks: bit.ly/3Q9rSQL + TXT + ) + + # Video metadata + + expect(info["genre"].as_s).to eq("Entertainment") + expect(info["genreUcid"].as_s).to be_empty + expect(info["license"].as_s).to be_empty + + # Author infos + + expect(info["author"].as_s).to eq("PBD Podcast") + expect(info["ucid"].as_s).to eq("UCGX7nGXpz-CmO_Arg-cgJ7A") + + expect(info["authorThumbnail"].as_s).to eq( + "https://yt3.ggpht.com/61ArDiQshJrvSXcGLhpFfIO3hlMabe2fksitcf6oGob0Mdr5gztdkXxRljICUodL4iuTSrtxW4A=s48-c-k-c0x00ffffff-no-rj" + ) + expect(info["authorVerified"].as_bool).to be_false + expect(info["subCountText"].as_s).to eq("227K") end end From 7df0cfcbed6100f16b1ccc2bd93aba42cff2b669 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Wed, 3 Aug 2022 21:31:46 +0200 Subject: [PATCH 08/73] Videos: fix 'views' parsing for livestreams --- src/invidious/videos.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 6211bcd7..b76da8f9 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -690,7 +690,11 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any # Basic video infos title = video_details["title"]?.try &.as_s - views = video_details["viewCount"]?.try &.as_s.to_i64 + + views = video_primary_renderer + .dig?("viewCount", "videoViewCountRenderer", "viewCount", "runs", 0, "text") + .try &.as_s.to_i64 + views ||= video_details["viewCount"]?.try &.as_s.to_i64 length_txt = (microformat["lengthSeconds"]? || video_details["lengthSeconds"]) .try &.as_s.to_i64 From 33150f5de388e34cc776a517db099dea39aab392 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sun, 21 Aug 2022 17:26:30 +0200 Subject: [PATCH 09/73] spec: Add test cases for regular videos extraction --- mocks | 2 +- .../videos/regular_videos_extract_spec.cr | 168 ++++++++++++++++++ 2 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 spec/invidious/videos/regular_videos_extract_spec.cr diff --git a/mocks b/mocks index c401dd92..dfd53ea6 160000 --- a/mocks +++ b/mocks @@ -1 +1 @@ -Subproject commit c401dd9203434b561022242c24b0c200d72284c0 +Subproject commit dfd53ea6ceb3cbcbbce6004f6ce60b330ad0f9b1 diff --git a/spec/invidious/videos/regular_videos_extract_spec.cr b/spec/invidious/videos/regular_videos_extract_spec.cr new file mode 100644 index 00000000..132b37a3 --- /dev/null +++ b/spec/invidious/videos/regular_videos_extract_spec.cr @@ -0,0 +1,168 @@ +require "../../parsers_helper.cr" + +Spectator.describe "parse_video_info" do + it "parses a regular video" do + # Enable mock + _player = load_mock("video/regular_mrbeast.player") + _next = load_mock("video/regular_mrbeast.next") + + raw_data = _player.merge!(_next) + info = parse_video_info("2isYuQZMbdU", raw_data) + + # Some basic verifications + expect(typeof(info)).to eq(Hash(String, JSON::Any)) + + expect(info["videoType"].as_s).to eq("Video") + + # Basic video infos + + expect(info["title"].as_s).to eq("I Gave My 100,000,000th Subscriber An Island") + expect(info["views"].as_i).to eq(32_846_329) + expect(info["likes"].as_i).to eq(2_611_650) + + # For some reason the video length from VideoDetails and the + # one from microformat differs by 1s... + expect(info["lengthSeconds"].as_i).to be_between(930_i64, 931_i64) + + expect(info["published"].as_s).to eq("2022-08-04T00:00:00Z") + + # Extra video infos + + expect(info["allowedRegions"].as_a).to_not be_empty + expect(info["allowedRegions"].as_a.size).to eq(249) + + expect(info["allowedRegions"].as_a).to contain( + "AD", "BA", "BB", "BW", "BY", "EG", "GG", "HN", "NP", "NR", "TR", + "TT", "TV", "TW", "TZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", + "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW" + ) + + expect(info["keywords"].as_a).to be_empty + + expect(info["allowRatings"].as_bool).to be_true + expect(info["isFamilyFriendly"].as_bool).to be_true + expect(info["isListed"].as_bool).to be_true + expect(info["isUpcoming"].as_bool).to be_false + + # Related videos + + expect(info["relatedVideos"].as_a.size).to eq(19) + + expect(info["relatedVideos"][0]["id"]).to eq("tVWWp1PqDus") + expect(info["relatedVideos"][0]["title"]).to eq("100 Girls Vs 100 Boys For $500,000") + expect(info["relatedVideos"][0]["author"]).to eq("MrBeast") + expect(info["relatedVideos"][0]["ucid"]).to eq("UCX6OQ3DkcsbYNE6H8uQQuVA") + expect(info["relatedVideos"][0]["view_count"]).to eq("49702799") + expect(info["relatedVideos"][0]["short_view_count"]).to eq("49M") + expect(info["relatedVideos"][0]["author_verified"]).to eq("true") + + # Description + + description = "🚀Launch a store on Shopify, I’ll buy from 100 random stores that do ▸ " + + expect(info["description"].as_s).to start_with(description) + expect(info["shortDescription"].as_s).to start_with(description) + expect(info["descriptionHtml"].as_s).to start_with(description) + + # Video metadata + + expect(info["genre"].as_s).to eq("Entertainment") + expect(info["genreUcid"].as_s).to be_empty + expect(info["license"].as_s).to be_empty + + # Author infos + + expect(info["author"].as_s).to eq("MrBeast") + expect(info["ucid"].as_s).to eq("UCX6OQ3DkcsbYNE6H8uQQuVA") + + expect(info["authorThumbnail"].as_s).to eq( + "https://yt3.ggpht.com/ytc/AMLnZu84dsnlYtuUFBMC8imQs0IUcTKA9khWAmUOgQZltw=s48-c-k-c0x00ffffff-no-rj" + ) + + expect(info["authorVerified"].as_bool).to be_true + expect(info["subCountText"].as_s).to eq("101M") + end + + it "parses a regular video with no descrition/comments" do + # Enable mock + _player = load_mock("video/regular_no-description.player") + _next = load_mock("video/regular_no-description.next") + + raw_data = _player.merge!(_next) + info = parse_video_info("iuevw6218F0", raw_data) + + # Some basic verifications + expect(typeof(info)).to eq(Hash(String, JSON::Any)) + + expect(info["videoType"].as_s).to eq("Video") + + # Basic video infos + + expect(info["title"].as_s).to eq("Chris Rea - Auberge") + expect(info["views"].as_i).to eq(10_356_197) + expect(info["likes"].as_i).to eq(0) + expect(info["lengthSeconds"].as_i).to eq(283_i64) + expect(info["published"].as_s).to eq("2012-05-21T00:00:00Z") + + # Extra video infos + + expect(info["allowedRegions"].as_a).to_not be_empty + expect(info["allowedRegions"].as_a.size).to eq(249) + + expect(info["allowedRegions"].as_a).to contain( + "AD", "BA", "BB", "BW", "BY", "EG", "GG", "HN", "NP", "NR", "TR", + "TT", "TV", "TW", "TZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", + "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW" + ) + + expect(info["keywords"].as_a).to_not be_empty + expect(info["keywords"].as_a.size).to eq(4) + + expect(info["keywords"].as_a).to contain_exactly( + "Chris", + "Rea", + "Auberge", + "1991" + ).in_any_order + + expect(info["allowRatings"].as_bool).to be_true + expect(info["isFamilyFriendly"].as_bool).to be_true + expect(info["isListed"].as_bool).to be_true + expect(info["isUpcoming"].as_bool).to be_false + + # Related videos + + expect(info["relatedVideos"].as_a.size).to eq(19) + + expect(info["relatedVideos"][0]["id"]).to eq("0bkrY_V0yZg") + expect(info["relatedVideos"][0]["title"]).to eq( + "Chris Rea Best Songs Collection - Chris Rea Greatest Hits Full Album 2022" + ) + expect(info["relatedVideos"][0]["author"]).to eq("Rock Ultimate") + expect(info["relatedVideos"][0]["ucid"]).to eq("UCekSc2A19di9koUIpj8gxlQ") + expect(info["relatedVideos"][0]["view_count"]).to eq("1992412") + expect(info["relatedVideos"][0]["short_view_count"]).to eq("1.9M") + expect(info["relatedVideos"][0]["author_verified"]).to eq("false") + + # Description + + expect(info["description"].as_s).to eq(" ") + expect(info["shortDescription"].as_s).to be_empty + expect(info["descriptionHtml"].as_s).to eq("

") + + # Video metadata + + expect(info["genre"].as_s).to eq("Music") + expect(info["genreUcid"].as_s).to be_empty + expect(info["license"].as_s).to be_empty + + # Author infos + + expect(info["author"].as_s).to eq("ChrisReaOfficial") + expect(info["ucid"].as_s).to eq("UC_5q6nWPbD30-y6oiWF_oNA") + + expect(info["authorThumbnail"].as_s).to be_empty + expect(info["authorVerified"].as_bool).to be_false + expect(info["subCountText"].as_s).to eq("-") + end +end From e23ceb6ae92b685152a284f840fa9aee0f1853ab Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sun, 21 Aug 2022 17:28:27 +0200 Subject: [PATCH 10/73] videos: Fix extraction code according to tests --- src/invidious/videos.cr | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index b76da8f9..a01a18b7 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -666,20 +666,20 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any raise BrokenTubeException.new("twoColumnWatchNextResults") if !main_results - primary_results = main_results.dig?("results", "results", "contents") + # Primary results are not available on Music videos + # See: https://github.com/iv-org/invidious/pull/3238#issuecomment-1207193725 + if primary_results = main_results.dig?("results", "results", "contents") + video_primary_renderer = primary_results + .as_a.find(&.["videoPrimaryInfoRenderer"]?) + .try &.["videoPrimaryInfoRenderer"] - raise BrokenTubeException.new("results") if !primary_results + video_secondary_renderer = primary_results + .as_a.find(&.["videoSecondaryInfoRenderer"]?) + .try &.["videoSecondaryInfoRenderer"] - video_primary_renderer = primary_results - .as_a.find(&.["videoPrimaryInfoRenderer"]?) - .try &.["videoPrimaryInfoRenderer"] - - video_secondary_renderer = primary_results - .as_a.find(&.["videoSecondaryInfoRenderer"]?) - .try &.["videoSecondaryInfoRenderer"] - - raise BrokenTubeException.new("videoPrimaryInfoRenderer") if !video_primary_renderer - raise BrokenTubeException.new("videoSecondaryInfoRenderer") if !video_secondary_renderer + raise BrokenTubeException.new("videoPrimaryInfoRenderer") if !video_primary_renderer + raise BrokenTubeException.new("videoSecondaryInfoRenderer") if !video_secondary_renderer + end video_details = player_response.dig?("videoDetails") microformat = player_response.dig?("microformat", "playerMicroformatRenderer") @@ -691,9 +691,12 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any title = video_details["title"]?.try &.as_s + # We have to try to extract viewCount from videoPrimaryInfoRenderer first, + # then from videoDetails, as the latter is "0" for livestreams (we want + # to get the amount of viewers watching). views = video_primary_renderer - .dig?("viewCount", "videoViewCountRenderer", "viewCount", "runs", 0, "text") - .try &.as_s.to_i64 + .try &.dig?("viewCount", "videoViewCountRenderer", "viewCount", "runs", 0, "text") + .try &.as_s.to_i64 views ||= video_details["viewCount"]?.try &.as_s.to_i64 length_txt = (microformat["lengthSeconds"]? || video_details["lengthSeconds"]) @@ -825,7 +828,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any if live_now video_type = VideoType::Livestream - elsif premiere_timestamp.not_nil! + elsif !premiere_timestamp.nil? video_type = VideoType::Scheduled published = premiere_timestamp || Time.utc else @@ -861,7 +864,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any "author" => JSON::Any.new(author || ""), "ucid" => JSON::Any.new(ucid || ""), "authorThumbnail" => JSON::Any.new(author_thumbnail.try &.as_s || ""), - "authorVerified" => JSON::Any.new(author_verified), + "authorVerified" => JSON::Any.new(author_verified || false), "subCountText" => JSON::Any.new(subs_text || "-"), } From ae03ed7bf7faeefa3d8e8bf5b6382f56ef154fe8 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 23 Aug 2022 17:56:09 +0200 Subject: [PATCH 11/73] videos: move player/next parsing code to a dedicated file --- spec/parsers_helper.cr | 1 + src/invidious/videos.cr | 336 -------------------------------- src/invidious/videos/parser.cr | 337 +++++++++++++++++++++++++++++++++ 3 files changed, 338 insertions(+), 336 deletions(-) create mode 100644 src/invidious/videos/parser.cr diff --git a/spec/parsers_helper.cr b/spec/parsers_helper.cr index e9154875..bf05f9ec 100644 --- a/spec/parsers_helper.cr +++ b/spec/parsers_helper.cr @@ -12,6 +12,7 @@ require "../src/invidious/helpers/logger" require "../src/invidious/helpers/utils" require "../src/invidious/videos" +require "../src/invidious/videos/*" require "../src/invidious/comments" require "../src/invidious/helpers/serialized_yt_data" diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index a01a18b7..9b19bc2a 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -535,342 +535,6 @@ class VideoRedirect < Exception end end -# Use to parse both "compactVideoRenderer" and "endScreenVideoRenderer". -# The former is preferred as it has more videos in it. The second has -# the same 11 first entries as the compact rendered. -# -# TODO: "compactRadioRenderer" (Mix) and -# TODO: Use a proper struct/class instead of a hacky JSON object -def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)? - return nil if !related["videoId"]? - - # The compact renderer has video length in seconds, where the end - # screen rendered has a full text version ("42:40") - length = related["lengthInSeconds"]?.try &.as_i.to_s - length ||= related.dig?("lengthText", "simpleText").try do |box| - decode_length_seconds(box.as_s).to_s - end - - # Both have "short", so the "long" option shouldn't be required - channel_info = (related["shortBylineText"]? || related["longBylineText"]?) - .try &.dig?("runs", 0) - - author = channel_info.try &.dig?("text") - author_verified = has_verified_badge?(related["ownerBadges"]?).to_s - - ucid = channel_info.try { |ci| HelperExtractors.get_browse_id(ci) } - - # "4,088,033 views", only available on compact renderer - # and when video is not a livestream - view_count = related.dig?("viewCountText", "simpleText") - .try &.as_s.gsub(/\D/, "") - - short_view_count = related.try do |r| - HelperExtractors.get_short_view_count(r).to_s - end - - LOGGER.trace("parse_related_video: Found \"watchNextEndScreenRenderer\" container") - - # TODO: when refactoring video types, make a struct for related videos - # or reuse an existing type, if that fits. - return { - "id" => related["videoId"], - "title" => related["title"]["simpleText"], - "author" => author || JSON::Any.new(""), - "ucid" => JSON::Any.new(ucid || ""), - "length_seconds" => JSON::Any.new(length || "0"), - "view_count" => JSON::Any.new(view_count || "0"), - "short_view_count" => JSON::Any.new(short_view_count || "0"), - "author_verified" => JSON::Any.new(author_verified), - } -end - -def extract_video_info(video_id : String, proxy_region : String? = nil, context_screen : String? = nil) - # Init client config for the API - client_config = YoutubeAPI::ClientConfig.new(proxy_region: proxy_region) - if context_screen == "embed" - client_config.client_type = YoutubeAPI::ClientType::TvHtml5ScreenEmbed - end - - # Fetch data from the player endpoint - player_response = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config) - - playability_status = player_response.dig?("playabilityStatus", "status").try &.as_s - - if playability_status != "OK" - subreason = player_response.dig?("playabilityStatus", "errorScreen", "playerErrorMessageRenderer", "subreason") - reason = subreason.try &.[]?("simpleText").try &.as_s - reason ||= subreason.try &.[]("runs").as_a.map(&.[]("text")).join("") - reason ||= player_response.dig("playabilityStatus", "reason").as_s - - # Stop here if video is not a scheduled livestream - if playability_status != "LIVE_STREAM_OFFLINE" - return { - "reason" => JSON::Any.new(reason), - } - end - elsif video_id != player_response.dig("videoDetails", "videoId") - # YouTube may return a different video player response than expected. - # See: https://github.com/TeamNewPipe/NewPipe/issues/8713 - raise VideoNotAvailableException.new("The video returned by YouTube isn't the requested one. (WEB client)") - else - reason = nil - end - - # Don't fetch the next endpoint if the video is unavailable. - if {"OK", "LIVE_STREAM_OFFLINE"}.any?(playability_status) - next_response = YoutubeAPI.next({"videoId": video_id, "params": ""}) - player_response = player_response.merge(next_response) - end - - params = parse_video_info(video_id, player_response) - params["reason"] = JSON::Any.new(reason) if reason - - # Fetch the video streams using an Android client in order to get the decrypted URLs and - # maybe fix throttling issues (#2194).See for the explanation about the decrypted URLs: - # https://github.com/TeamNewPipe/NewPipeExtractor/issues/562 - if reason.nil? - if context_screen == "embed" - client_config.client_type = YoutubeAPI::ClientType::AndroidScreenEmbed - else - client_config.client_type = YoutubeAPI::ClientType::Android - end - android_player = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config) - - # Sometimes, the video is available from the web client, but not on Android, so check - # that here, and fallback to the streaming data from the web client if needed. - # See: https://github.com/iv-org/invidious/issues/2549 - if video_id != android_player.dig("videoDetails", "videoId") - # YouTube may return a different video player response than expected. - # See: https://github.com/TeamNewPipe/NewPipe/issues/8713 - raise VideoNotAvailableException.new("The video returned by YouTube isn't the requested one. (ANDROID client)") - elsif android_player["playabilityStatus"]["status"] == "OK" - params["streamingData"] = android_player["streamingData"]? || JSON::Any.new("") - else - params["streamingData"] = player_response["streamingData"]? || JSON::Any.new("") - end - end - - # TODO: clean that up - {"captions", "microformat", "playabilityStatus", "storyboards", "videoDetails"}.each do |f| - params[f] = player_response[f] if player_response[f]? - end - - return params -end - -def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any)) : Hash(String, JSON::Any) - # Top level elements - - main_results = player_response.dig?("contents", "twoColumnWatchNextResults") - - raise BrokenTubeException.new("twoColumnWatchNextResults") if !main_results - - # Primary results are not available on Music videos - # See: https://github.com/iv-org/invidious/pull/3238#issuecomment-1207193725 - if primary_results = main_results.dig?("results", "results", "contents") - video_primary_renderer = primary_results - .as_a.find(&.["videoPrimaryInfoRenderer"]?) - .try &.["videoPrimaryInfoRenderer"] - - video_secondary_renderer = primary_results - .as_a.find(&.["videoSecondaryInfoRenderer"]?) - .try &.["videoSecondaryInfoRenderer"] - - raise BrokenTubeException.new("videoPrimaryInfoRenderer") if !video_primary_renderer - raise BrokenTubeException.new("videoSecondaryInfoRenderer") if !video_secondary_renderer - end - - video_details = player_response.dig?("videoDetails") - microformat = player_response.dig?("microformat", "playerMicroformatRenderer") - - raise BrokenTubeException.new("videoDetails") if !video_details - raise BrokenTubeException.new("microformat") if !microformat - - # Basic video infos - - title = video_details["title"]?.try &.as_s - - # We have to try to extract viewCount from videoPrimaryInfoRenderer first, - # then from videoDetails, as the latter is "0" for livestreams (we want - # to get the amount of viewers watching). - views = video_primary_renderer - .try &.dig?("viewCount", "videoViewCountRenderer", "viewCount", "runs", 0, "text") - .try &.as_s.to_i64 - views ||= video_details["viewCount"]?.try &.as_s.to_i64 - - length_txt = (microformat["lengthSeconds"]? || video_details["lengthSeconds"]) - .try &.as_s.to_i64 - - published = microformat["publishDate"]? - .try { |t| Time.parse(t.as_s, "%Y-%m-%d", Time::Location::UTC) } || Time.utc - - premiere_timestamp = microformat.dig?("liveBroadcastDetails", "startTimestamp") - .try { |t| Time.parse_rfc3339(t.as_s) } - - live_now = microformat.dig?("liveBroadcastDetails", "isLiveNow") - .try &.as_bool || false - - # Extra video infos - - allowed_regions = microformat["availableCountries"]? - .try &.as_a.map &.as_s || [] of String - - allow_ratings = video_details["allowRatings"]?.try &.as_bool - family_friendly = microformat["isFamilySafe"].try &.as_bool - is_listed = video_details["isCrawlable"]?.try &.as_bool - is_upcoming = video_details["isUpcoming"]?.try &.as_bool - - keywords = video_details["keywords"]? - .try &.as_a.map &.as_s || [] of String - - # Related videos - - LOGGER.debug("extract_video_info: parsing related videos...") - - related = [] of JSON::Any - - # Parse "compactVideoRenderer" items (under secondary results) - secondary_results = main_results - .dig?("secondaryResults", "secondaryResults", "results") - secondary_results.try &.as_a.each do |element| - if item = element["compactVideoRenderer"]? - related_video = parse_related_video(item) - related << JSON::Any.new(related_video) if related_video - end - end - - # If nothing was found previously, fall back to end screen renderer - if related.empty? - # Container for "endScreenVideoRenderer" items - player_overlays = player_response.dig?( - "playerOverlays", "playerOverlayRenderer", - "endScreen", "watchNextEndScreenRenderer", "results" - ) - - player_overlays.try &.as_a.each do |element| - if item = element["endScreenVideoRenderer"]? - related_video = parse_related_video(item) - related << JSON::Any.new(related_video) if related_video - end - end - end - - # Likes - - toplevel_buttons = video_primary_renderer - .try &.dig?("videoActions", "menuRenderer", "topLevelButtons") - - if toplevel_buttons - likes_button = toplevel_buttons.as_a - .find(&.dig?("toggleButtonRenderer", "defaultIcon", "iconType").=== "LIKE") - .try &.["toggleButtonRenderer"] - - if likes_button - likes_txt = (likes_button["defaultText"]? || likes_button["toggledText"]?) - .try &.dig?("accessibility", "accessibilityData", "label") - likes = likes_txt.as_s.gsub(/\D/, "").to_i64? if likes_txt - - LOGGER.trace("extract_video_info: Found \"likes\" button. Button text is \"#{likes_txt}\"") - LOGGER.debug("extract_video_info: Likes count is #{likes}") if likes - end - end - - # Description - - description = microformat.dig?("description", "simpleText").try &.as_s || "" - short_description = player_response.dig?("videoDetails", "shortDescription") - - description_html = video_secondary_renderer.try &.dig?("description", "runs") - .try &.as_a.try { |t| content_to_comment_html(t, video_id) } - - # Video metadata - - metadata = video_secondary_renderer - .try &.dig?("metadataRowContainer", "metadataRowContainerRenderer", "rows") - .try &.as_a - - genre = microformat["category"]? - genre_ucid = nil - license = nil - - metadata.try &.each do |row| - metadata_title = row.dig?("metadataRowRenderer", "title", "simpleText").try &.as_s - contents = row.dig?("metadataRowRenderer", "contents", 0) - - if metadata_title == "Category" - contents = contents.try &.dig?("runs", 0) - - genre = contents.try &.["text"]? - genre_ucid = contents.try &.dig?("navigationEndpoint", "browseEndpoint", "browseId") - elsif metadata_title == "License" - license = contents.try &.dig?("runs", 0, "text") - elsif metadata_title == "Licensed to YouTube by" - license = contents.try &.["simpleText"]? - end - end - - # Author infos - - author = video_details["author"]?.try &.as_s - ucid = video_details["channelId"]?.try &.as_s - - if author_info = video_secondary_renderer.try &.dig?("owner", "videoOwnerRenderer") - author_thumbnail = author_info.dig?("thumbnail", "thumbnails", 0, "url") - author_verified = has_verified_badge?(author_info["badges"]?) - - subs_text = author_info["subscriberCountText"]? - .try { |t| t["simpleText"]? || t.dig?("runs", 0, "text") } - .try &.as_s.split(" ", 2)[0] - end - - # Return data - - if live_now - video_type = VideoType::Livestream - elsif !premiere_timestamp.nil? - video_type = VideoType::Scheduled - published = premiere_timestamp || Time.utc - else - video_type = VideoType::Video - end - - params = { - "videoType" => JSON::Any.new(video_type.to_s), - # Basic video infos - "title" => JSON::Any.new(title || ""), - "views" => JSON::Any.new(views || 0_i64), - "likes" => JSON::Any.new(likes || 0_i64), - "lengthSeconds" => JSON::Any.new(length_txt || 0_i64), - "published" => JSON::Any.new(published.to_rfc3339), - # Extra video infos - "allowedRegions" => JSON::Any.new(allowed_regions.map { |v| JSON::Any.new(v) }), - "allowRatings" => JSON::Any.new(allow_ratings || false), - "isFamilyFriendly" => JSON::Any.new(family_friendly || false), - "isListed" => JSON::Any.new(is_listed || false), - "isUpcoming" => JSON::Any.new(is_upcoming || false), - "keywords" => JSON::Any.new(keywords.map { |v| JSON::Any.new(v) }), - # Related videos - "relatedVideos" => JSON::Any.new(related), - # Description - "description" => JSON::Any.new(description || ""), - "descriptionHtml" => JSON::Any.new(description_html || "

"), - "shortDescription" => JSON::Any.new(short_description.try &.as_s || nil), - # Video metadata - "genre" => JSON::Any.new(genre.try &.as_s || ""), - "genreUcid" => JSON::Any.new(genre_ucid.try &.as_s || ""), - "license" => JSON::Any.new(license.try &.as_s || ""), - # Author infos - "author" => JSON::Any.new(author || ""), - "ucid" => JSON::Any.new(ucid || ""), - "authorThumbnail" => JSON::Any.new(author_thumbnail.try &.as_s || ""), - "authorVerified" => JSON::Any.new(author_verified || false), - "subCountText" => JSON::Any.new(subs_text || "-"), - } - - return params -end - def get_video(id, refresh = true, region = nil, force_refresh = false) if (video = Invidious::Database::Videos.select(id)) && !region # If record was last updated over 10 minutes ago, or video has since premiered, diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr new file mode 100644 index 00000000..ff5d15de --- /dev/null +++ b/src/invidious/videos/parser.cr @@ -0,0 +1,337 @@ +require "json" + +# Use to parse both "compactVideoRenderer" and "endScreenVideoRenderer". +# The former is preferred as it has more videos in it. The second has +# the same 11 first entries as the compact rendered. +# +# TODO: "compactRadioRenderer" (Mix) and +# TODO: Use a proper struct/class instead of a hacky JSON object +def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)? + return nil if !related["videoId"]? + + # The compact renderer has video length in seconds, where the end + # screen rendered has a full text version ("42:40") + length = related["lengthInSeconds"]?.try &.as_i.to_s + length ||= related.dig?("lengthText", "simpleText").try do |box| + decode_length_seconds(box.as_s).to_s + end + + # Both have "short", so the "long" option shouldn't be required + channel_info = (related["shortBylineText"]? || related["longBylineText"]?) + .try &.dig?("runs", 0) + + author = channel_info.try &.dig?("text") + author_verified = has_verified_badge?(related["ownerBadges"]?).to_s + + ucid = channel_info.try { |ci| HelperExtractors.get_browse_id(ci) } + + # "4,088,033 views", only available on compact renderer + # and when video is not a livestream + view_count = related.dig?("viewCountText", "simpleText") + .try &.as_s.gsub(/\D/, "") + + short_view_count = related.try do |r| + HelperExtractors.get_short_view_count(r).to_s + end + + LOGGER.trace("parse_related_video: Found \"watchNextEndScreenRenderer\" container") + + # TODO: when refactoring video types, make a struct for related videos + # or reuse an existing type, if that fits. + return { + "id" => related["videoId"], + "title" => related["title"]["simpleText"], + "author" => author || JSON::Any.new(""), + "ucid" => JSON::Any.new(ucid || ""), + "length_seconds" => JSON::Any.new(length || "0"), + "view_count" => JSON::Any.new(view_count || "0"), + "short_view_count" => JSON::Any.new(short_view_count || "0"), + "author_verified" => JSON::Any.new(author_verified), + } +end + +def extract_video_info(video_id : String, proxy_region : String? = nil, context_screen : String? = nil) + # Init client config for the API + client_config = YoutubeAPI::ClientConfig.new(proxy_region: proxy_region) + if context_screen == "embed" + client_config.client_type = YoutubeAPI::ClientType::TvHtml5ScreenEmbed + end + + # Fetch data from the player endpoint + player_response = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config) + + playability_status = player_response.dig?("playabilityStatus", "status").try &.as_s + + if playability_status != "OK" + subreason = player_response.dig?("playabilityStatus", "errorScreen", "playerErrorMessageRenderer", "subreason") + reason = subreason.try &.[]?("simpleText").try &.as_s + reason ||= subreason.try &.[]("runs").as_a.map(&.[]("text")).join("") + reason ||= player_response.dig("playabilityStatus", "reason").as_s + + # Stop here if video is not a scheduled livestream + if playability_status != "LIVE_STREAM_OFFLINE" + return { + "reason" => JSON::Any.new(reason), + } + end + elsif video_id != player_response.dig("videoDetails", "videoId") + # YouTube may return a different video player response than expected. + # See: https://github.com/TeamNewPipe/NewPipe/issues/8713 + raise VideoNotAvailableException.new("The video returned by YouTube isn't the requested one. (WEB client)") + else + reason = nil + end + + # Don't fetch the next endpoint if the video is unavailable. + if {"OK", "LIVE_STREAM_OFFLINE"}.any?(playability_status) + next_response = YoutubeAPI.next({"videoId": video_id, "params": ""}) + player_response = player_response.merge(next_response) + end + + params = parse_video_info(video_id, player_response) + params["reason"] = JSON::Any.new(reason) if reason + + # Fetch the video streams using an Android client in order to get the decrypted URLs and + # maybe fix throttling issues (#2194).See for the explanation about the decrypted URLs: + # https://github.com/TeamNewPipe/NewPipeExtractor/issues/562 + if reason.nil? + if context_screen == "embed" + client_config.client_type = YoutubeAPI::ClientType::AndroidScreenEmbed + else + client_config.client_type = YoutubeAPI::ClientType::Android + end + android_player = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config) + + # Sometimes, the video is available from the web client, but not on Android, so check + # that here, and fallback to the streaming data from the web client if needed. + # See: https://github.com/iv-org/invidious/issues/2549 + if video_id != android_player.dig("videoDetails", "videoId") + # YouTube may return a different video player response than expected. + # See: https://github.com/TeamNewPipe/NewPipe/issues/8713 + raise VideoNotAvailableException.new("The video returned by YouTube isn't the requested one. (ANDROID client)") + elsif android_player["playabilityStatus"]["status"] == "OK" + params["streamingData"] = android_player["streamingData"]? || JSON::Any.new("") + else + params["streamingData"] = player_response["streamingData"]? || JSON::Any.new("") + end + end + + # TODO: clean that up + {"captions", "microformat", "playabilityStatus", "storyboards", "videoDetails"}.each do |f| + params[f] = player_response[f] if player_response[f]? + end + + return params +end + +def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any)) : Hash(String, JSON::Any) + # Top level elements + + main_results = player_response.dig?("contents", "twoColumnWatchNextResults") + + raise BrokenTubeException.new("twoColumnWatchNextResults") if !main_results + + # Primary results are not available on Music videos + # See: https://github.com/iv-org/invidious/pull/3238#issuecomment-1207193725 + if primary_results = main_results.dig?("results", "results", "contents") + video_primary_renderer = primary_results + .as_a.find(&.["videoPrimaryInfoRenderer"]?) + .try &.["videoPrimaryInfoRenderer"] + + video_secondary_renderer = primary_results + .as_a.find(&.["videoSecondaryInfoRenderer"]?) + .try &.["videoSecondaryInfoRenderer"] + + raise BrokenTubeException.new("videoPrimaryInfoRenderer") if !video_primary_renderer + raise BrokenTubeException.new("videoSecondaryInfoRenderer") if !video_secondary_renderer + end + + video_details = player_response.dig?("videoDetails") + microformat = player_response.dig?("microformat", "playerMicroformatRenderer") + + raise BrokenTubeException.new("videoDetails") if !video_details + raise BrokenTubeException.new("microformat") if !microformat + + # Basic video infos + + title = video_details["title"]?.try &.as_s + + # We have to try to extract viewCount from videoPrimaryInfoRenderer first, + # then from videoDetails, as the latter is "0" for livestreams (we want + # to get the amount of viewers watching). + views = video_primary_renderer + .try &.dig?("viewCount", "videoViewCountRenderer", "viewCount", "runs", 0, "text") + .try &.as_s.to_i64 + views ||= video_details["viewCount"]?.try &.as_s.to_i64 + + length_txt = (microformat["lengthSeconds"]? || video_details["lengthSeconds"]) + .try &.as_s.to_i64 + + published = microformat["publishDate"]? + .try { |t| Time.parse(t.as_s, "%Y-%m-%d", Time::Location::UTC) } || Time.utc + + premiere_timestamp = microformat.dig?("liveBroadcastDetails", "startTimestamp") + .try { |t| Time.parse_rfc3339(t.as_s) } + + live_now = microformat.dig?("liveBroadcastDetails", "isLiveNow") + .try &.as_bool || false + + # Extra video infos + + allowed_regions = microformat["availableCountries"]? + .try &.as_a.map &.as_s || [] of String + + allow_ratings = video_details["allowRatings"]?.try &.as_bool + family_friendly = microformat["isFamilySafe"].try &.as_bool + is_listed = video_details["isCrawlable"]?.try &.as_bool + is_upcoming = video_details["isUpcoming"]?.try &.as_bool + + keywords = video_details["keywords"]? + .try &.as_a.map &.as_s || [] of String + + # Related videos + + LOGGER.debug("extract_video_info: parsing related videos...") + + related = [] of JSON::Any + + # Parse "compactVideoRenderer" items (under secondary results) + secondary_results = main_results + .dig?("secondaryResults", "secondaryResults", "results") + secondary_results.try &.as_a.each do |element| + if item = element["compactVideoRenderer"]? + related_video = parse_related_video(item) + related << JSON::Any.new(related_video) if related_video + end + end + + # If nothing was found previously, fall back to end screen renderer + if related.empty? + # Container for "endScreenVideoRenderer" items + player_overlays = player_response.dig?( + "playerOverlays", "playerOverlayRenderer", + "endScreen", "watchNextEndScreenRenderer", "results" + ) + + player_overlays.try &.as_a.each do |element| + if item = element["endScreenVideoRenderer"]? + related_video = parse_related_video(item) + related << JSON::Any.new(related_video) if related_video + end + end + end + + # Likes + + toplevel_buttons = video_primary_renderer + .try &.dig?("videoActions", "menuRenderer", "topLevelButtons") + + if toplevel_buttons + likes_button = toplevel_buttons.as_a + .find(&.dig?("toggleButtonRenderer", "defaultIcon", "iconType").=== "LIKE") + .try &.["toggleButtonRenderer"] + + if likes_button + likes_txt = (likes_button["defaultText"]? || likes_button["toggledText"]?) + .try &.dig?("accessibility", "accessibilityData", "label") + likes = likes_txt.as_s.gsub(/\D/, "").to_i64? if likes_txt + + LOGGER.trace("extract_video_info: Found \"likes\" button. Button text is \"#{likes_txt}\"") + LOGGER.debug("extract_video_info: Likes count is #{likes}") if likes + end + end + + # Description + + description = microformat.dig?("description", "simpleText").try &.as_s || "" + short_description = player_response.dig?("videoDetails", "shortDescription") + + description_html = video_secondary_renderer.try &.dig?("description", "runs") + .try &.as_a.try { |t| content_to_comment_html(t, video_id) } + + # Video metadata + + metadata = video_secondary_renderer + .try &.dig?("metadataRowContainer", "metadataRowContainerRenderer", "rows") + .try &.as_a + + genre = microformat["category"]? + genre_ucid = nil + license = nil + + metadata.try &.each do |row| + metadata_title = row.dig?("metadataRowRenderer", "title", "simpleText").try &.as_s + contents = row.dig?("metadataRowRenderer", "contents", 0) + + if metadata_title == "Category" + contents = contents.try &.dig?("runs", 0) + + genre = contents.try &.["text"]? + genre_ucid = contents.try &.dig?("navigationEndpoint", "browseEndpoint", "browseId") + elsif metadata_title == "License" + license = contents.try &.dig?("runs", 0, "text") + elsif metadata_title == "Licensed to YouTube by" + license = contents.try &.["simpleText"]? + end + end + + # Author infos + + author = video_details["author"]?.try &.as_s + ucid = video_details["channelId"]?.try &.as_s + + if author_info = video_secondary_renderer.try &.dig?("owner", "videoOwnerRenderer") + author_thumbnail = author_info.dig?("thumbnail", "thumbnails", 0, "url") + author_verified = has_verified_badge?(author_info["badges"]?) + + subs_text = author_info["subscriberCountText"]? + .try { |t| t["simpleText"]? || t.dig?("runs", 0, "text") } + .try &.as_s.split(" ", 2)[0] + end + + # Return data + + if live_now + video_type = VideoType::Livestream + elsif !premiere_timestamp.nil? + video_type = VideoType::Scheduled + published = premiere_timestamp || Time.utc + else + video_type = VideoType::Video + end + + params = { + "videoType" => JSON::Any.new(video_type.to_s), + # Basic video infos + "title" => JSON::Any.new(title || ""), + "views" => JSON::Any.new(views || 0_i64), + "likes" => JSON::Any.new(likes || 0_i64), + "lengthSeconds" => JSON::Any.new(length_txt || 0_i64), + "published" => JSON::Any.new(published.to_rfc3339), + # Extra video infos + "allowedRegions" => JSON::Any.new(allowed_regions.map { |v| JSON::Any.new(v) }), + "allowRatings" => JSON::Any.new(allow_ratings || false), + "isFamilyFriendly" => JSON::Any.new(family_friendly || false), + "isListed" => JSON::Any.new(is_listed || false), + "isUpcoming" => JSON::Any.new(is_upcoming || false), + "keywords" => JSON::Any.new(keywords.map { |v| JSON::Any.new(v) }), + # Related videos + "relatedVideos" => JSON::Any.new(related), + # Description + "description" => JSON::Any.new(description || ""), + "descriptionHtml" => JSON::Any.new(description_html || "

"), + "shortDescription" => JSON::Any.new(short_description.try &.as_s || nil), + # Video metadata + "genre" => JSON::Any.new(genre.try &.as_s || ""), + "genreUcid" => JSON::Any.new(genre_ucid.try &.as_s || ""), + "license" => JSON::Any.new(license.try &.as_s || ""), + # Author infos + "author" => JSON::Any.new(author || ""), + "ucid" => JSON::Any.new(ucid || ""), + "authorThumbnail" => JSON::Any.new(author_thumbnail.try &.as_s || ""), + "authorVerified" => JSON::Any.new(author_verified || false), + "subCountText" => JSON::Any.new(subs_text || "-"), + } + + return params +end From 87a5d70062b8f4b2b942d027f8c4cf0bb30907eb Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 23 Aug 2022 19:03:09 +0200 Subject: [PATCH 12/73] videos: move API's JSON structure to a dedicated module --- src/invidious.cr | 2 + src/invidious/channels/channels.cr | 2 +- src/invidious/channels/community.cr | 2 +- src/invidious/helpers/serialized_yt_data.cr | 4 +- src/invidious/jsonify/api_v1/video_json.cr | 255 +++++++++++++++++++ src/invidious/playlists.cr | 2 +- src/invidious/routes/api/v1/misc.cr | 2 +- src/invidious/routes/api/v1/videos.cr | 2 +- src/invidious/videos.cr | 256 +------------------- 9 files changed, 272 insertions(+), 255 deletions(-) create mode 100644 src/invidious/jsonify/api_v1/video_json.cr diff --git a/src/invidious.cr b/src/invidious.cr index 8df0c0cd..2874cc71 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -39,6 +39,8 @@ require "./invidious/yt_backend/*" require "./invidious/frontend/*" require "./invidious/videos/*" +require "./invidious/jsonify/**" + require "./invidious/*" require "./invidious/channels/*" require "./invidious/user/*" diff --git a/src/invidious/channels/channels.cr b/src/invidious/channels/channels.cr index e0459cc3..e3d3d9ee 100644 --- a/src/invidious/channels/channels.cr +++ b/src/invidious/channels/channels.cr @@ -29,7 +29,7 @@ struct ChannelVideo json.field "title", self.title json.field "videoId", self.id json.field "videoThumbnails" do - generate_thumbnails(json, self.id) + Invidious::JSONify::APIv1.thumbnails(json, self.id) end json.field "lengthSeconds", self.length_seconds diff --git a/src/invidious/channels/community.cr b/src/invidious/channels/community.cr index 2a2c74aa..8e300288 100644 --- a/src/invidious/channels/community.cr +++ b/src/invidious/channels/community.cr @@ -138,7 +138,7 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode) json.field "title", video_title json.field "videoId", video_id json.field "videoThumbnails" do - generate_thumbnails(json, video_id) + Invidious::JSONify::APIv1.thumbnails(json, video_id) end json.field "lengthSeconds", decode_length_seconds(attachment["lengthText"]["simpleText"].as_s) diff --git a/src/invidious/helpers/serialized_yt_data.cr b/src/invidious/helpers/serialized_yt_data.cr index 3918bd13..c52e2a0d 100644 --- a/src/invidious/helpers/serialized_yt_data.cr +++ b/src/invidious/helpers/serialized_yt_data.cr @@ -76,7 +76,7 @@ struct SearchVideo json.field "authorUrl", "/channel/#{self.ucid}" json.field "videoThumbnails" do - generate_thumbnails(json, self.id) + Invidious::JSONify::APIv1.thumbnails(json, self.id) end json.field "description", html_to_content(self.description_html) @@ -155,7 +155,7 @@ struct SearchPlaylist json.field "lengthSeconds", video.length_seconds json.field "videoThumbnails" do - generate_thumbnails(json, video.id) + Invidious::JSONify::APIv1.thumbnails(json, video.id) end end end diff --git a/src/invidious/jsonify/api_v1/video_json.cr b/src/invidious/jsonify/api_v1/video_json.cr new file mode 100644 index 00000000..1082f6d3 --- /dev/null +++ b/src/invidious/jsonify/api_v1/video_json.cr @@ -0,0 +1,255 @@ +require "json" + +module Invidious::JSONify::APIv1 + extend self + + def video(video : Video, json : JSON::Builder, *, locale : String?) + json.object do + json.field "type", video.video_type + + json.field "title", video.title + json.field "videoId", video.id + + json.field "error", video.info["reason"] if video.info["reason"]? + + json.field "videoThumbnails" do + self.thumbnails(json, video.id) + end + json.field "storyboards" do + self.storyboards(json, video.id, video.storyboards) + end + + json.field "description", video.description + json.field "descriptionHtml", video.description_html + json.field "published", video.published.to_unix + json.field "publishedText", translate(locale, "`x` ago", recode_date(video.published, locale)) + json.field "keywords", video.keywords + + json.field "viewCount", video.views + json.field "likeCount", video.likes + json.field "dislikeCount", 0_i64 + + json.field "paid", video.paid + json.field "premium", video.premium + json.field "isFamilyFriendly", video.is_family_friendly + json.field "allowedRegions", video.allowed_regions + json.field "genre", video.genre + json.field "genreUrl", video.genre_url + + json.field "author", video.author + json.field "authorId", video.ucid + json.field "authorUrl", "/channel/#{video.ucid}" + + json.field "authorThumbnails" do + json.array do + qualities = {32, 48, 76, 100, 176, 512} + + qualities.each do |quality| + json.object do + json.field "url", video.author_thumbnail.gsub(/=s\d+/, "=s#{quality}") + json.field "width", quality + json.field "height", quality + end + end + end + end + + json.field "subCountText", video.sub_count_text + + json.field "lengthSeconds", video.length_seconds + json.field "allowRatings", video.allow_ratings + json.field "rating", 0_i64 + json.field "isListed", video.is_listed + json.field "liveNow", video.live_now + json.field "isUpcoming", video.is_upcoming + + if video.premiere_timestamp + json.field "premiereTimestamp", video.premiere_timestamp.try &.to_unix + end + + if hlsvp = video.hls_manifest_url + hlsvp = hlsvp.gsub("https://manifest.googlevideo.com", HOST_URL) + json.field "hlsUrl", hlsvp + end + + json.field "dashUrl", "#{HOST_URL}/api/manifest/dash/id/#{video.id}" + + json.field "adaptiveFormats" do + json.array do + video.adaptive_fmts.each do |fmt| + json.object do + # Only available on regular videos, not livestreams/OTF streams + if init_range = fmt["initRange"]? + json.field "init", "#{init_range["start"]}-#{init_range["end"]}" + end + if index_range = fmt["indexRange"]? + json.field "index", "#{index_range["start"]}-#{index_range["end"]}" + end + + # Not available on MPEG-4 Timed Text (`text/mp4`) streams (livestreams only) + json.field "bitrate", fmt["bitrate"].as_i.to_s if fmt["bitrate"]? + + json.field "url", fmt["url"] + json.field "itag", fmt["itag"].as_i.to_s + json.field "type", fmt["mimeType"] + json.field "clen", fmt["contentLength"]? || "-1" + json.field "lmt", fmt["lastModified"] + json.field "projectionType", fmt["projectionType"] + + if fmt_info = Invidious::Videos::Formats.itag_to_metadata?(fmt["itag"]) + fps = fmt_info["fps"]?.try &.to_i || fmt["fps"]?.try &.as_i || 30 + json.field "fps", fps + json.field "container", fmt_info["ext"] + json.field "encoding", fmt_info["vcodec"]? || fmt_info["acodec"] + + if fmt_info["height"]? + json.field "resolution", "#{fmt_info["height"]}p" + + quality_label = "#{fmt_info["height"]}p" + if fps > 30 + quality_label += "60" + end + json.field "qualityLabel", quality_label + + if fmt_info["width"]? + json.field "size", "#{fmt_info["width"]}x#{fmt_info["height"]}" + end + end + end + + # Livestream chunk infos + json.field "targetDurationSec", fmt["targetDurationSec"].as_i if fmt.has_key?("targetDurationSec") + json.field "maxDvrDurationSec", fmt["maxDvrDurationSec"].as_i if fmt.has_key?("maxDvrDurationSec") + + # Audio-related data + json.field "audioQuality", fmt["audioQuality"] if fmt.has_key?("audioQuality") + json.field "audioSampleRate", fmt["audioSampleRate"].as_s.to_i if fmt.has_key?("audioSampleRate") + json.field "audioChannels", fmt["audioChannels"] if fmt.has_key?("audioChannels") + + # Extra misc stuff + json.field "colorInfo", fmt["colorInfo"] if fmt.has_key?("colorInfo") + json.field "captionTrack", fmt["captionTrack"] if fmt.has_key?("captionTrack") + end + end + end + end + + json.field "formatStreams" do + json.array do + video.fmt_stream.each do |fmt| + json.object do + json.field "url", fmt["url"] + json.field "itag", fmt["itag"].as_i.to_s + json.field "type", fmt["mimeType"] + json.field "quality", fmt["quality"] + + fmt_info = Invidious::Videos::Formats.itag_to_metadata?(fmt["itag"]) + if fmt_info + fps = fmt_info["fps"]?.try &.to_i || fmt["fps"]?.try &.as_i || 30 + json.field "fps", fps + json.field "container", fmt_info["ext"] + json.field "encoding", fmt_info["vcodec"]? || fmt_info["acodec"] + + if fmt_info["height"]? + json.field "resolution", "#{fmt_info["height"]}p" + + quality_label = "#{fmt_info["height"]}p" + if fps > 30 + quality_label += "60" + end + json.field "qualityLabel", quality_label + + if fmt_info["width"]? + json.field "size", "#{fmt_info["width"]}x#{fmt_info["height"]}" + end + end + end + end + end + end + end + + json.field "captions" do + json.array do + video.captions.each do |caption| + json.object do + json.field "label", caption.name + json.field "language_code", caption.language_code + json.field "url", "/api/v1/captions/#{video.id}?label=#{URI.encode_www_form(caption.name)}" + end + end + end + end + + json.field "recommendedVideos" do + json.array do + video.related_videos.each do |rv| + if rv["id"]? + json.object do + json.field "videoId", rv["id"] + json.field "title", rv["title"] + json.field "videoThumbnails" do + self.thumbnails(json, rv["id"]) + end + + json.field "author", rv["author"] + json.field "authorUrl", "/channel/#{rv["ucid"]?}" + json.field "authorId", rv["ucid"]? + if rv["author_thumbnail"]? + json.field "authorThumbnails" do + json.array do + qualities = {32, 48, 76, 100, 176, 512} + + qualities.each do |quality| + json.object do + json.field "url", rv["author_thumbnail"].gsub(/s\d+-/, "s#{quality}-") + json.field "width", quality + json.field "height", quality + end + end + end + end + end + + json.field "lengthSeconds", rv["length_seconds"]?.try &.to_i + json.field "viewCountText", rv["short_view_count"]? + json.field "viewCount", rv["view_count"]?.try &.empty? ? nil : rv["view_count"].to_i64 + end + end + end + end + end + end + end + + def thumbnails(json, id) + json.array do + build_thumbnails(id).each do |thumbnail| + json.object do + json.field "quality", thumbnail[:name] + json.field "url", "#{thumbnail[:host]}/vi/#{id}/#{thumbnail["url"]}.jpg" + json.field "width", thumbnail[:width] + json.field "height", thumbnail[:height] + end + end + end + end + + def storyboards(json, id, storyboards) + json.array do + storyboards.each do |storyboard| + json.object do + json.field "url", "/api/v1/storyboards/#{id}?width=#{storyboard[:width]}&height=#{storyboard[:height]}" + json.field "templateUrl", storyboard[:url] + json.field "width", storyboard[:width] + json.field "height", storyboard[:height] + json.field "count", storyboard[:count] + json.field "interval", storyboard[:interval] + json.field "storyboardWidth", storyboard[:storyboard_width] + json.field "storyboardHeight", storyboard[:storyboard_height] + json.field "storyboardCount", storyboard[:storyboard_count] + end + end + end + end +end diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index c4eb7507..57f1f53e 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -56,7 +56,7 @@ struct PlaylistVideo json.field "authorUrl", "/channel/#{self.ucid}" json.field "videoThumbnails" do - generate_thumbnails(json, self.id) + Invidious::JSONify::APIv1.thumbnails(json, self.id) end if index diff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.cr index 844fedb8..43d360e6 100644 --- a/src/invidious/routes/api/v1/misc.cr +++ b/src/invidious/routes/api/v1/misc.cr @@ -124,7 +124,7 @@ module Invidious::Routes::API::V1::Misc json.field "videoThumbnails" do json.array do - generate_thumbnails(json, video.id) + Invidious::JSONify::APIv1.thumbnails(json, video.id) end end diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr index 1b7b4fa7..6f1f5916 100644 --- a/src/invidious/routes/api/v1/videos.cr +++ b/src/invidious/routes/api/v1/videos.cr @@ -185,7 +185,7 @@ module Invidious::Routes::API::V1::Videos response = JSON.build do |json| json.object do json.field "storyboards" do - generate_storyboards(json, id, storyboards) + Invidious::JSONify::APIv1.storyboards(json, id, storyboards) end end end diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 9b19bc2a..fcc9a8a4 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -31,234 +31,25 @@ struct Video end end + # Methods for API v1 JSON + def to_json(locale : String?, json : JSON::Builder) - json.object do - json.field "type", self.video_type - - json.field "title", self.title - json.field "videoId", self.id - - json.field "error", info["reason"] if info["reason"]? - - json.field "videoThumbnails" do - generate_thumbnails(json, self.id) - end - json.field "storyboards" do - generate_storyboards(json, self.id, self.storyboards) - end - - json.field "description", self.description - json.field "descriptionHtml", self.description_html - json.field "published", self.published.to_unix - json.field "publishedText", translate(locale, "`x` ago", recode_date(self.published, locale)) - json.field "keywords", self.keywords - - json.field "viewCount", self.views - json.field "likeCount", self.likes - json.field "dislikeCount", 0_i64 - - json.field "paid", self.paid - json.field "premium", self.premium - json.field "isFamilyFriendly", self.is_family_friendly - json.field "allowedRegions", self.allowed_regions - json.field "genre", self.genre - json.field "genreUrl", self.genre_url - - json.field "author", self.author - json.field "authorId", self.ucid - json.field "authorUrl", "/channel/#{self.ucid}" - - json.field "authorThumbnails" do - json.array do - qualities = {32, 48, 76, 100, 176, 512} - - qualities.each do |quality| - json.object do - json.field "url", self.author_thumbnail.gsub(/=s\d+/, "=s#{quality}") - json.field "width", quality - json.field "height", quality - end - end - end - end - - json.field "subCountText", self.sub_count_text - - json.field "lengthSeconds", self.length_seconds - json.field "allowRatings", self.allow_ratings - json.field "rating", 0_i64 - json.field "isListed", self.is_listed - json.field "liveNow", self.live_now - json.field "isUpcoming", self.is_upcoming - - if self.premiere_timestamp - json.field "premiereTimestamp", self.premiere_timestamp.try &.to_unix - end - - if hlsvp = self.hls_manifest_url - hlsvp = hlsvp.gsub("https://manifest.googlevideo.com", HOST_URL) - json.field "hlsUrl", hlsvp - end - - json.field "dashUrl", "#{HOST_URL}/api/manifest/dash/id/#{id}" - - json.field "adaptiveFormats" do - json.array do - self.adaptive_fmts.each do |fmt| - json.object do - # Only available on regular videos, not livestreams/OTF streams - if init_range = fmt["initRange"]? - json.field "init", "#{init_range["start"]}-#{init_range["end"]}" - end - if index_range = fmt["indexRange"]? - json.field "index", "#{index_range["start"]}-#{index_range["end"]}" - end - - # Not available on MPEG-4 Timed Text (`text/mp4`) streams (livestreams only) - json.field "bitrate", fmt["bitrate"].as_i.to_s if fmt["bitrate"]? - - json.field "url", fmt["url"] - json.field "itag", fmt["itag"].as_i.to_s - json.field "type", fmt["mimeType"] - json.field "clen", fmt["contentLength"]? || "-1" - json.field "lmt", fmt["lastModified"] - json.field "projectionType", fmt["projectionType"] - - if fmt_info = Invidious::Videos::Formats.itag_to_metadata?(fmt["itag"]) - fps = fmt_info["fps"]?.try &.to_i || fmt["fps"]?.try &.as_i || 30 - json.field "fps", fps - json.field "container", fmt_info["ext"] - json.field "encoding", fmt_info["vcodec"]? || fmt_info["acodec"] - - if fmt_info["height"]? - json.field "resolution", "#{fmt_info["height"]}p" - - quality_label = "#{fmt_info["height"]}p" - if fps > 30 - quality_label += "60" - end - json.field "qualityLabel", quality_label - - if fmt_info["width"]? - json.field "size", "#{fmt_info["width"]}x#{fmt_info["height"]}" - end - end - end - - # Livestream chunk infos - json.field "targetDurationSec", fmt["targetDurationSec"].as_i if fmt.has_key?("targetDurationSec") - json.field "maxDvrDurationSec", fmt["maxDvrDurationSec"].as_i if fmt.has_key?("maxDvrDurationSec") - - # Audio-related data - json.field "audioQuality", fmt["audioQuality"] if fmt.has_key?("audioQuality") - json.field "audioSampleRate", fmt["audioSampleRate"].as_s.to_i if fmt.has_key?("audioSampleRate") - json.field "audioChannels", fmt["audioChannels"] if fmt.has_key?("audioChannels") - - # Extra misc stuff - json.field "colorInfo", fmt["colorInfo"] if fmt.has_key?("colorInfo") - json.field "captionTrack", fmt["captionTrack"] if fmt.has_key?("captionTrack") - end - end - end - end - - json.field "formatStreams" do - json.array do - self.fmt_stream.each do |fmt| - json.object do - json.field "url", fmt["url"] - json.field "itag", fmt["itag"].as_i.to_s - json.field "type", fmt["mimeType"] - json.field "quality", fmt["quality"] - - fmt_info = Invidious::Videos::Formats.itag_to_metadata?(fmt["itag"]) - if fmt_info - fps = fmt_info["fps"]?.try &.to_i || fmt["fps"]?.try &.as_i || 30 - json.field "fps", fps - json.field "container", fmt_info["ext"] - json.field "encoding", fmt_info["vcodec"]? || fmt_info["acodec"] - - if fmt_info["height"]? - json.field "resolution", "#{fmt_info["height"]}p" - - quality_label = "#{fmt_info["height"]}p" - if fps > 30 - quality_label += "60" - end - json.field "qualityLabel", quality_label - - if fmt_info["width"]? - json.field "size", "#{fmt_info["width"]}x#{fmt_info["height"]}" - end - end - end - end - end - end - end - - json.field "captions" do - json.array do - self.captions.each do |caption| - json.object do - json.field "label", caption.name - json.field "language_code", caption.language_code - json.field "url", "/api/v1/captions/#{id}?label=#{URI.encode_www_form(caption.name)}" - end - end - end - end - - json.field "recommendedVideos" do - json.array do - self.related_videos.each do |rv| - if rv["id"]? - json.object do - json.field "videoId", rv["id"] - json.field "title", rv["title"] - json.field "videoThumbnails" do - generate_thumbnails(json, rv["id"]) - end - - json.field "author", rv["author"] - json.field "authorUrl", "/channel/#{rv["ucid"]?}" - json.field "authorId", rv["ucid"]? - if rv["author_thumbnail"]? - json.field "authorThumbnails" do - json.array do - qualities = {32, 48, 76, 100, 176, 512} - - qualities.each do |quality| - json.object do - json.field "url", rv["author_thumbnail"].gsub(/s\d+-/, "s#{quality}-") - json.field "width", quality - json.field "height", quality - end - end - end - end - end - - json.field "lengthSeconds", rv["length_seconds"]?.try &.to_i - json.field "viewCountText", rv["short_view_count"]? - json.field "viewCount", rv["view_count"]?.try &.empty? ? nil : rv["view_count"].to_i64 - end - end - end - end - end - end + Invidious::JSONify::APIv1.video(self, json, locale: locale) end # TODO: remove the locale and follow the crystal convention def to_json(locale : String?, _json : Nil) - JSON.build { |json| to_json(locale, json) } + JSON.build do |json| + Invidious::JSONify::APIv1.video(self, json, locale: locale) + end end def to_json(json : JSON::Builder | Nil = nil) to_json(nil, json) end + # Misc methods + def video_type : VideoType video_type = info["videoType"]?.try &.as_s || "video" return VideoType.parse?(video_type) || VideoType::Video @@ -631,34 +422,3 @@ def build_thumbnails(id) {host: HOST_URL, height: 90, width: 120, name: "end", url: "3"}, } end - -def generate_thumbnails(json, id) - json.array do - build_thumbnails(id).each do |thumbnail| - json.object do - json.field "quality", thumbnail[:name] - json.field "url", "#{thumbnail[:host]}/vi/#{id}/#{thumbnail["url"]}.jpg" - json.field "width", thumbnail[:width] - json.field "height", thumbnail[:height] - end - end - end -end - -def generate_storyboards(json, id, storyboards) - json.array do - storyboards.each do |storyboard| - json.object do - json.field "url", "/api/v1/storyboards/#{id}?width=#{storyboard[:width]}&height=#{storyboard[:height]}" - json.field "templateUrl", storyboard[:url] - json.field "width", storyboard[:width] - json.field "height", storyboard[:height] - json.field "count", storyboard[:count] - json.field "interval", storyboard[:interval] - json.field "storyboardWidth", storyboard[:storyboard_width] - json.field "storyboardHeight", storyboard[:storyboard_height] - json.field "storyboardCount", storyboard[:storyboard_count] - end - end - end -end From d659a451d6dece62dbb091a958083c8a347da5b1 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 23 Aug 2022 19:04:08 +0200 Subject: [PATCH 13/73] videos: remove unused 'VideoRedirect' exception --- src/invidious/jsonify/api_v1/common.cr | 18 ++++++++++++++++++ src/invidious/jsonify/api_v1/video_json.cr | 13 ------------- src/invidious/routes/api/manifest.cr | 2 -- src/invidious/routes/api/v1/videos.cr | 9 --------- src/invidious/routes/embed.cr | 2 -- src/invidious/routes/watch.cr | 2 -- src/invidious/videos.cr | 7 ------- 7 files changed, 18 insertions(+), 35 deletions(-) create mode 100644 src/invidious/jsonify/api_v1/common.cr diff --git a/src/invidious/jsonify/api_v1/common.cr b/src/invidious/jsonify/api_v1/common.cr new file mode 100644 index 00000000..64b06465 --- /dev/null +++ b/src/invidious/jsonify/api_v1/common.cr @@ -0,0 +1,18 @@ +require "json" + +module Invidious::JSONify::APIv1 + extend self + + def thumbnails(json : JSON::Builder, id : String) + json.array do + build_thumbnails(id).each do |thumbnail| + json.object do + json.field "quality", thumbnail[:name] + json.field "url", "#{thumbnail[:host]}/vi/#{id}/#{thumbnail["url"]}.jpg" + json.field "width", thumbnail[:width] + json.field "height", thumbnail[:height] + end + end + end + end +end diff --git a/src/invidious/jsonify/api_v1/video_json.cr b/src/invidious/jsonify/api_v1/video_json.cr index 1082f6d3..0a5173ce 100644 --- a/src/invidious/jsonify/api_v1/video_json.cr +++ b/src/invidious/jsonify/api_v1/video_json.cr @@ -222,19 +222,6 @@ module Invidious::JSONify::APIv1 end end - def thumbnails(json, id) - json.array do - build_thumbnails(id).each do |thumbnail| - json.object do - json.field "quality", thumbnail[:name] - json.field "url", "#{thumbnail[:host]}/vi/#{id}/#{thumbnail["url"]}.jpg" - json.field "width", thumbnail[:width] - json.field "height", thumbnail[:height] - end - end - end - end - def storyboards(json, id, storyboards) json.array do storyboards.each do |storyboard| diff --git a/src/invidious/routes/api/manifest.cr b/src/invidious/routes/api/manifest.cr index bfb8a377..ae65f10d 100644 --- a/src/invidious/routes/api/manifest.cr +++ b/src/invidious/routes/api/manifest.cr @@ -14,8 +14,6 @@ module Invidious::Routes::API::Manifest begin video = get_video(id, region: region) - rescue ex : VideoRedirect - return env.redirect env.request.resource.gsub(id, ex.video_id) rescue ex : NotFoundException haltf env, status_code: 404 rescue ex diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr index 6f1f5916..a6b2eb4e 100644 --- a/src/invidious/routes/api/v1/videos.cr +++ b/src/invidious/routes/api/v1/videos.cr @@ -9,9 +9,6 @@ module Invidious::Routes::API::V1::Videos begin video = get_video(id, region: region) - rescue ex : VideoRedirect - env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id) - return error_json(302, "Video is unavailable", {"videoId" => ex.video_id}) rescue ex : NotFoundException return error_json(404, ex) rescue ex @@ -41,9 +38,6 @@ module Invidious::Routes::API::V1::Videos begin video = get_video(id, region: region) - rescue ex : VideoRedirect - env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id) - return error_json(302, "Video is unavailable", {"videoId" => ex.video_id}) rescue ex : NotFoundException haltf env, 404 rescue ex @@ -168,9 +162,6 @@ module Invidious::Routes::API::V1::Videos begin video = get_video(id, region: region) - rescue ex : VideoRedirect - env.response.headers["Location"] = env.request.resource.gsub(id, ex.video_id) - return error_json(302, "Video is unavailable", {"videoId" => ex.video_id}) rescue ex : NotFoundException haltf env, 404 rescue ex diff --git a/src/invidious/routes/embed.cr b/src/invidious/routes/embed.cr index e6486587..289d87c9 100644 --- a/src/invidious/routes/embed.cr +++ b/src/invidious/routes/embed.cr @@ -131,8 +131,6 @@ module Invidious::Routes::Embed begin video = get_video(id, region: params.region) - rescue ex : VideoRedirect - return env.redirect env.request.resource.gsub(id, ex.video_id) rescue ex : NotFoundException return error_template(404, ex) rescue ex diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr index fe1d8e54..5f481557 100644 --- a/src/invidious/routes/watch.cr +++ b/src/invidious/routes/watch.cr @@ -61,8 +61,6 @@ module Invidious::Routes::Watch begin video = get_video(id, region: params.region) - rescue ex : VideoRedirect - return env.redirect env.request.resource.gsub(id, ex.video_id) rescue ex : NotFoundException LOGGER.error("get_video not found: #{id} : #{ex.message}") return error_template(404, ex) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index fcc9a8a4..bec26de9 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -319,13 +319,6 @@ struct Video getset_bool isUpcoming end -class VideoRedirect < Exception - property video_id : String - - def initialize(@video_id) - end -end - def get_video(id, refresh = true, region = nil, force_refresh = false) if (video = Invidious::Database::Videos.select(id)) && !region # If record was last updated over 10 minutes ago, or video has since premiered, From 83795c245aace771fb73936b22d3de7ced0df9df Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Thu, 8 Sep 2022 00:06:58 +0200 Subject: [PATCH 14/73] videos: Support the new like button's structure --- src/invidious/videos/parser.cr | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr index ff5d15de..701c4e77 100644 --- a/src/invidious/videos/parser.cr +++ b/src/invidious/videos/parser.cr @@ -227,11 +227,21 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any .try &.dig?("videoActions", "menuRenderer", "topLevelButtons") if toplevel_buttons - likes_button = toplevel_buttons.as_a + likes_button = toplevel_buttons.try &.as_a .find(&.dig?("toggleButtonRenderer", "defaultIcon", "iconType").=== "LIKE") .try &.["toggleButtonRenderer"] + # New format as of september 2022 + likes_button ||= toplevel_buttons.try &.as_a + .find(&.["segmentedLikeDislikeButtonRenderer"]?) + .try &.dig?( + "segmentedLikeDislikeButtonRenderer", + "likeButton", "toggleButtonRenderer" + ) + if likes_button + # Note: The like count from `toggledText` is off by one, as it would + # represent the new like count in the event where the user clicks on "like". likes_txt = (likes_button["defaultText"]? || likes_button["toggledText"]?) .try &.dig?("accessibility", "accessibilityData", "label") likes = likes_txt.as_s.gsub(/\D/, "").to_i64? if likes_txt From db91d3af66b52e8f7127b2b3b826111126027c6d Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Wed, 14 Sep 2022 20:08:36 +0200 Subject: [PATCH 15/73] videos: Fix some bugs --- src/invidious/jsonify/api_v1/video_json.cr | 11 ++++++++++- src/invidious/videos/parser.cr | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/invidious/jsonify/api_v1/video_json.cr b/src/invidious/jsonify/api_v1/video_json.cr index 0a5173ce..642789aa 100644 --- a/src/invidious/jsonify/api_v1/video_json.cr +++ b/src/invidious/jsonify/api_v1/video_json.cr @@ -93,7 +93,16 @@ module Invidious::JSONify::APIv1 json.field "itag", fmt["itag"].as_i.to_s json.field "type", fmt["mimeType"] json.field "clen", fmt["contentLength"]? || "-1" - json.field "lmt", fmt["lastModified"] + + # Last modified is a unix timestamp with µS, with the dot omitted. + # E.g: 1638056732(.)141582 + # + # On livestreams, it's not present, so always fall back to the + # current unix timestamp (up to mS precision) for compatibility. + last_modified = fmt["lastModified"]? + last_modified ||= "#{Time.utc.to_unix_ms.to_s}000" + json.field "lmt", last_modified + json.field "projectionType", fmt["projectionType"] if fmt_info = Invidious::Videos::Formats.itag_to_metadata?(fmt["itag"]) diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr index 701c4e77..53372942 100644 --- a/src/invidious/videos/parser.cr +++ b/src/invidious/videos/parser.cr @@ -159,10 +159,10 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any # We have to try to extract viewCount from videoPrimaryInfoRenderer first, # then from videoDetails, as the latter is "0" for livestreams (we want # to get the amount of viewers watching). - views = video_primary_renderer + views_txt = video_primary_renderer .try &.dig?("viewCount", "videoViewCountRenderer", "viewCount", "runs", 0, "text") - .try &.as_s.to_i64 - views ||= video_details["viewCount"]?.try &.as_s.to_i64 + views_txt ||= video_details["viewCount"]? + views = views_txt.try &.as_s.gsub(/\D/, "").to_i64? length_txt = (microformat["lengthSeconds"]? || video_details["lengthSeconds"]) .try &.as_s.to_i64 @@ -270,7 +270,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any license = nil metadata.try &.each do |row| - metadata_title = row.dig?("metadataRowRenderer", "title", "simpleText").try &.as_s + metadata_title = extract_text(row.dig?("metadataRowRenderer", "title")) contents = row.dig?("metadataRowRenderer", "contents", 0) if metadata_title == "Category" From 2acff70811eeb82d7944b358e03171a775106e86 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Mon, 3 Oct 2022 21:58:52 +0200 Subject: [PATCH 16/73] videos: handle different JSON structs being present in cache --- src/invidious/videos.cr | 17 ++++++++++++++++- src/invidious/videos/parser.cr | 6 +++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index bec26de9..c055f2a7 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -7,6 +7,16 @@ end struct Video include DB::Serializable + # Version of the JSON structure + # It prevents us from loading an incompatible version from cache + # (either newer or older, if instances with different versions run + # concurrently, e.g during a version upgrade rollout). + # + # NOTE: don't forget to bump this number if any change is made to + # the `params` structure in videos/parser.cr!!! + # + SCHEMA_VERSION = 2 + property id : String @[DB::Field(converter: Video::JSONConverter)] @@ -55,6 +65,10 @@ struct Video return VideoType.parse?(video_type) || VideoType::Video end + def schema_version : Int + return info["version"]?.try &.as_i || 1 + end + def published : Time return info["published"]? .try { |t| Time.parse(t.as_s, "%Y-%m-%d", Time::Location::UTC) } || Time.utc @@ -326,7 +340,8 @@ def get_video(id, refresh = true, region = nil, force_refresh = false) if (refresh && (Time.utc - video.updated > 10.minutes) || (video.premiere_timestamp.try &.< Time.utc)) || - force_refresh + force_refresh || + video.schema_version != Video::SCHEMA_VERSION # cache control begin video = fetch_video(id, region) Invidious::Database::Videos.update(video) diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr index 53372942..64c8d21a 100644 --- a/src/invidious/videos/parser.cr +++ b/src/invidious/videos/parser.cr @@ -71,7 +71,8 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_ # Stop here if video is not a scheduled livestream if playability_status != "LIVE_STREAM_OFFLINE" return { - "reason" => JSON::Any.new(reason), + "version" => JSON::Any.new(Video::SCHEMA_VERSION.to_i64), + "reason" => JSON::Any.new(reason), } end elsif video_id != player_response.dig("videoDetails", "videoId") @@ -121,6 +122,9 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_ params[f] = player_response[f] if player_response[f]? end + # Data structure version, for cache control + params["version"] = JSON::Any.new(Video::SCHEMA_VERSION.to_i64) + return params end From cc5c83333f2a51dc178b698a548b64f01a2ff453 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sun, 6 Nov 2022 21:23:58 +0100 Subject: [PATCH 17/73] videos: improve fetching of streaming data --- src/invidious/videos.cr | 6 --- src/invidious/videos/parser.cr | 78 +++++++++++++++++++++------------- 2 files changed, 48 insertions(+), 36 deletions(-) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index c055f2a7..786ef416 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -380,12 +380,6 @@ def fetch_video(id, region) end end - # Try to fetch video info using an embedded client - if info["reason"]? - embed_info = extract_video_info(video_id: id, context_screen: "embed") - info = embed_info if !embed_info["reason"]? - end - if reason = info["reason"]? if reason == "Video unavailable" raise NotFoundException.new(reason.as_s || "") diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr index 64c8d21a..e3f6170d 100644 --- a/src/invidious/videos/parser.cr +++ b/src/invidious/videos/parser.cr @@ -50,12 +50,9 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)? } end -def extract_video_info(video_id : String, proxy_region : String? = nil, context_screen : String? = nil) +def extract_video_info(video_id : String, proxy_region : String? = nil) # Init client config for the API client_config = YoutubeAPI::ClientConfig.new(proxy_region: proxy_region) - if context_screen == "embed" - client_config.client_type = YoutubeAPI::ClientType::TvHtml5ScreenEmbed - end # Fetch data from the player endpoint player_response = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config) @@ -69,7 +66,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_ reason ||= player_response.dig("playabilityStatus", "reason").as_s # Stop here if video is not a scheduled livestream - if playability_status != "LIVE_STREAM_OFFLINE" + if !{"LIVE_STREAM_OFFLINE", "LOGIN_REQUIRED"}.any?(playability_status) return { "version" => JSON::Any.new(Video::SCHEMA_VERSION.to_i64), "reason" => JSON::Any.new(reason), @@ -84,7 +81,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_ end # Don't fetch the next endpoint if the video is unavailable. - if {"OK", "LIVE_STREAM_OFFLINE"}.any?(playability_status) + if {"OK", "LIVE_STREAM_OFFLINE", "LOGIN_REQUIRED"}.any?(playability_status) next_response = YoutubeAPI.next({"videoId": video_id, "params": ""}) player_response = player_response.merge(next_response) end @@ -92,33 +89,34 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_ params = parse_video_info(video_id, player_response) params["reason"] = JSON::Any.new(reason) if reason - # Fetch the video streams using an Android client in order to get the decrypted URLs and - # maybe fix throttling issues (#2194).See for the explanation about the decrypted URLs: - # https://github.com/TeamNewPipe/NewPipeExtractor/issues/562 - if reason.nil? - if context_screen == "embed" - client_config.client_type = YoutubeAPI::ClientType::AndroidScreenEmbed - else - client_config.client_type = YoutubeAPI::ClientType::Android - end - android_player = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config) + new_player_response = nil - # Sometimes, the video is available from the web client, but not on Android, so check - # that here, and fallback to the streaming data from the web client if needed. - # See: https://github.com/iv-org/invidious/issues/2549 - if video_id != android_player.dig("videoDetails", "videoId") - # YouTube may return a different video player response than expected. - # See: https://github.com/TeamNewPipe/NewPipe/issues/8713 - raise VideoNotAvailableException.new("The video returned by YouTube isn't the requested one. (ANDROID client)") - elsif android_player["playabilityStatus"]["status"] == "OK" - params["streamingData"] = android_player["streamingData"]? || JSON::Any.new("") - else - params["streamingData"] = player_response["streamingData"]? || JSON::Any.new("") - end + if reason.nil? + # Fetch the video streams using an Android client in order to get the + # decrypted URLs and maybe fix throttling issues (#2194). See the + # following issue for an explanation about decrypted URLs: + # https://github.com/TeamNewPipe/NewPipeExtractor/issues/562 + client_config.client_type = YoutubeAPI::ClientType::Android + new_player_response = try_fetch_streaming_data(video_id, client_config) + elsif !reason.includes?("your country") # Handled separately + # The Android embedded client could help here + client_config.client_type = YoutubeAPI::ClientType::AndroidScreenEmbed + new_player_response = try_fetch_streaming_data(video_id, client_config) end - # TODO: clean that up - {"captions", "microformat", "playabilityStatus", "storyboards", "videoDetails"}.each do |f| + # Last hope + if new_player_response.nil? + client_config.client_type = YoutubeAPI::ClientType::TvHtml5ScreenEmbed + new_player_response = try_fetch_streaming_data(video_id, client_config) + end + + # Replace player response and reset reason + if !new_player_response.nil? + player_response = new_player_response + params.delete("reason") + end + + {"captions", "playabilityStatus", "playerConfig", "storyboards", "streamingData"}.each do |f| params[f] = player_response[f] if player_response[f]? end @@ -128,6 +126,26 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_ return params end +def try_fetch_streaming_data(id : String, client_config : YoutubeAPI::ClientConfig) : Hash(String, JSON::Any)? + LOGGER.debug("try_fetch_streaming_data: [#{id}] Using #{client_config.client_type} client.") + response = YoutubeAPI.player(video_id: id, params: "", client_config: client_config) + + playability_status = response["playabilityStatus"]["status"] + LOGGER.debug("try_fetch_streaming_data: [#{id}] Got playabilityStatus == #{playability_status}.") + + if id != response.dig("videoDetails", "videoId") + # YouTube may return a different video player response than expected. + # See: https://github.com/TeamNewPipe/NewPipe/issues/8713 + raise VideoNotAvailableException.new( + "The video returned by YouTube isn't the requested one. (#{client_config.client_type} client)" + ) + elsif playability_status == "OK" + return response + else + return nil + end +end + def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any)) : Hash(String, JSON::Any) # Top level elements From 47cc26cb3c5862e6ae96f89882ee08c6a8185672 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Wed, 16 Nov 2022 18:18:35 +0100 Subject: [PATCH 18/73] videos: fix 'Arithmetic overflow' error --- src/invidious/videos.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 786ef416..d626c7d1 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -280,7 +280,7 @@ struct Video {% for op, type in {i32: Int32, i64: Int64} %} private macro getset_{{op}}(name) def \{{name.id.underscore}} : {{type}} - return info[\{{name.stringify}}]?.try &.as_i.to_{{op}} || 0_{{op}} + return info[\{{name.stringify}}]?.try &.as_i64.to_{{op}} || 0_{{op}} end def \{{name.id.underscore}}=(value : Int) From 1bb8f2815dd3cf7ab4a0080a5355ca4c0287319f Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Thu, 17 Nov 2022 22:41:51 +0000 Subject: [PATCH 19/73] CI: Use Crystal 1.6.2 in test matrix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dfe3ba87..4aa334c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: - 1.3.2 - 1.4.1 - 1.5.1 - - 1.6.1 + - 1.6.2 include: - crystal: nightly stable: false From afc0ec3c30d82b5cbbb38b09d3e57cdab2be5700 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sun, 20 Nov 2022 22:52:33 +0100 Subject: [PATCH 20/73] search: Fix short text parsing --- src/invidious/channels/about.cr | 5 +++-- src/invidious/helpers/utils.cr | 24 +++++++++++------------- src/invidious/yt_backend/extractors.cr | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/invidious/channels/about.cr b/src/invidious/channels/about.cr index f60ee7af..4c442959 100644 --- a/src/invidious/channels/about.cr +++ b/src/invidious/channels/about.cr @@ -130,8 +130,9 @@ def get_about_info(ucid, locale) : AboutChannel tabs = tabs_json.reject { |node| node["tabRenderer"]?.nil? }.map(&.["tabRenderer"]["title"].as_s.downcase) end - sub_count = initdata["header"]["c4TabbedHeaderRenderer"]?.try &.["subscriberCountText"]?.try &.["simpleText"]?.try &.as_s? - .try { |text| short_text_to_number(text.split(" ")[0]) } || 0 + sub_count = initdata + .dig?("header", "c4TabbedHeaderRenderer", "subscriberCountText", "simpleText").try &.as_s? + .try { |text| short_text_to_number(text.split(" ")[0]).to_i32 } || 0 AboutChannel.new( ucid: ucid, diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index 8ae5034a..ed0cca38 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -161,21 +161,19 @@ def number_with_separator(number) number.to_s.reverse.gsub(/(\d{3})(?=\d)/, "\\1,").reverse end -def short_text_to_number(short_text : String) : Int32 - case short_text - when .ends_with? "M" - number = short_text.rstrip(" mM").to_f - number *= 1000000 - when .ends_with? "K" - number = short_text.rstrip(" kK").to_f - number *= 1000 - else - number = short_text.rstrip(" ") +def short_text_to_number(short_text : String) : Int64 + matches = /(?\d+(\.\d+)?)\s?(?[mMkKbB])?/.match(short_text) + number = matches.try &.["number"].to_f || 0.0 + + case matches.try &.["suffix"].downcase + when "k" then number *= 1_000 + when "m" then number *= 1_000_000 + when "b" then number *= 1_000_000_000 end - number = number.to_i - - return number + return number.to_i64 +rescue ex + return 0_i64 end def number_to_short_text(number) diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index 8112930d..edc722cf 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -170,7 +170,7 @@ private module Parsers # Always simpleText # TODO change default value to nil subscriber_count = item_contents.dig?("subscriberCountText", "simpleText") - .try { |s| short_text_to_number(s.as_s.split(" ")[0]) } || 0 + .try { |s| short_text_to_number(s.as_s.split(" ")[0]).to_i32 } || 0 # Auto-generated channels doesn't have videoCountText # Taken from: https://github.com/iv-org/invidious/pull/2228#discussion_r717620922 From f44506b7e032e8ed29dfc6a1c817442e4cf747f1 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sun, 20 Nov 2022 23:48:59 +0100 Subject: [PATCH 21/73] yt api: bump web client version --- src/invidious/yt_backend/youtube_api.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/yt_backend/youtube_api.cr b/src/invidious/yt_backend/youtube_api.cr index 02327025..91a9332c 100644 --- a/src/invidious/yt_backend/youtube_api.cr +++ b/src/invidious/yt_backend/youtube_api.cr @@ -43,7 +43,7 @@ module YoutubeAPI ClientType::Web => { name: "WEB", name_proto: "1", - version: "2.20220804.07.00", + version: "2.20221118.01.00", api_key: DEFAULT_API_KEY, screen: "WATCH_FULL_SCREEN", os_name: "Windows", From 9eb2ad367e271ebffaf0b908d51df7639e6c7645 Mon Sep 17 00:00:00 2001 From: PrivacyDevel <105459436+PrivacyDevel@users.noreply.github.com> Date: Tue, 22 Nov 2022 15:51:14 +0000 Subject: [PATCH 22/73] Correct config.example.yml dark_mode comment --- config/config.example.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.example.yml b/config/config.example.yml index 264a5bea..b8c44873 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -613,7 +613,7 @@ default_user_preferences: ## ## Enable/Disable dark mode. ## - ## Accepted values: true, false + ## Accepted values: "dark" ## Default: ## #dark_mode: From 96560672965feb3cc28f8ca579fef229b4823378 Mon Sep 17 00:00:00 2001 From: PrivacyDevel <105459436+PrivacyDevel@users.noreply.github.com> Date: Tue, 22 Nov 2022 17:08:32 +0000 Subject: [PATCH 23/73] Add "light" and "auto" as accepted values for dark_mode --- config/config.example.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.example.yml b/config/config.example.yml index b8c44873..68e777c1 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -613,7 +613,7 @@ default_user_preferences: ## ## Enable/Disable dark mode. ## - ## Accepted values: "dark" + ## Accepted values: "dark", "light", "auto" ## Default: ## #dark_mode: From 4fc5d43374ca39890a98a27d129979eb960c1c4b Mon Sep 17 00:00:00 2001 From: PrivacyDevel <105459436+PrivacyDevel@users.noreply.github.com> Date: Tue, 22 Nov 2022 17:22:46 +0000 Subject: [PATCH 24/73] Update config.example.yml --- config/config.example.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.example.yml b/config/config.example.yml index 68e777c1..8794880d 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -614,9 +614,9 @@ default_user_preferences: ## Enable/Disable dark mode. ## ## Accepted values: "dark", "light", "auto" - ## Default: + ## Default: "auto" ## - #dark_mode: + #dark_mode: "auto" ## ## Enable/Disable thin mode (no video thumbnails). From 1f6c2342596ee864cc46cf97540af640e1ba3c78 Mon Sep 17 00:00:00 2001 From: dev Date: Thu, 1 Dec 2022 11:34:54 +0100 Subject: [PATCH 25/73] added tini for proper signal forwarding --- docker/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 34549df1..57864883 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -43,7 +43,7 @@ RUN if [[ "${release}" == 1 && "${disable_quic}" == 1 ]] ; then \ FROM alpine:3.16 -RUN apk add --no-cache librsvg ttf-opensans +RUN apk add --no-cache librsvg ttf-opensans tini WORKDIR /invidious RUN addgroup -g 1000 -S invidious && \ adduser -u 1000 -S invidious -G invidious @@ -58,4 +58,5 @@ RUN chmod o+rX -R ./assets ./config ./locales EXPOSE 3000 USER invidious +ENTRYPOINT ["/sbin/tini", "--"] CMD [ "/invidious/invidious" ] From 99bf5197812b470f17e66aec2ca6eccc55ca6e15 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Thu, 1 Dec 2022 20:09:31 +0100 Subject: [PATCH 26/73] shards: Bump protodec to v0.1.5 --- shard.lock | 2 +- shard.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shard.lock b/shard.lock index cdce1160..235e4c25 100644 --- a/shard.lock +++ b/shard.lock @@ -34,7 +34,7 @@ shards: protodec: git: https://github.com/iv-org/protodec.git - version: 0.1.4 + version: 0.1.5 radix: git: https://github.com/luislavena/radix.git diff --git a/shard.yml b/shard.yml index 9c9b0d37..7ee0bb2a 100644 --- a/shard.yml +++ b/shard.yml @@ -24,7 +24,7 @@ dependencies: version: ~> 0.6.1 protodec: github: iv-org/protodec - version: ~> 0.1.4 + version: ~> 0.1.5 lsquic: github: iv-org/lsquic.cr version: ~> 2.18.1-2 From fbcce57ce29b05c234c0c31b5f179d861e143260 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Fri, 11 Nov 2022 01:31:32 +0100 Subject: [PATCH 27/73] channel: use extractor utils to parse tabs (+ code cleaning) --- src/invidious/channels/about.cr | 54 ++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/invidious/channels/about.cr b/src/invidious/channels/about.cr index 4c442959..bb9bd8c7 100644 --- a/src/invidious/channels/about.cr +++ b/src/invidious/channels/about.cr @@ -100,34 +100,40 @@ def get_about_info(ucid, locale) : AboutChannel total_views = 0_i64 joined = Time.unix(0) - tabs = [] of String + tab_names = [] of String - tabs_json = initdata["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]?.try &.as_a? - if !tabs_json.nil? - # Retrieve information from the tabs array. The index we are looking for varies between channels. - tabs_json.each do |node| - # Try to find the about section which is located in only one of the tabs. - channel_about_meta = node["tabRenderer"]?.try &.["content"]?.try &.["sectionListRenderer"]? - .try &.["contents"]?.try &.[0]?.try &.["itemSectionRenderer"]?.try &.["contents"]? - .try &.[0]?.try &.["channelAboutFullMetadataRenderer"]? + if tabs_json = initdata["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]? + # Get the name of the tabs available on this channel + tab_names = tabs_json.as_a + .compact_map(&.dig?("tabRenderer", "title").try &.as_s.downcase) - if !channel_about_meta.nil? - total_views = channel_about_meta["viewCountText"]?.try &.["simpleText"]?.try &.as_s.gsub(/\D/, "").to_i64? || 0_i64 + # Get the currently active tab ("About") + about_tab = extract_selected_tab(tabs_json) - # The joined text is split to several sub strings. The reduce joins those strings before parsing the date. - joined = channel_about_meta["joinedDateText"]?.try &.["runs"]?.try &.as_a.reduce("") { |acc, nd| acc + nd["text"].as_s } - .try { |text| Time.parse(text, "Joined %b %-d, %Y", Time::Location.local) } || Time.unix(0) + # Try to find the about metadata section + channel_about_meta = about_tab.dig?( + "content", + "sectionListRenderer", "contents", 0, + "itemSectionRenderer", "contents", 0, + "channelAboutFullMetadataRenderer" + ) - # Normal Auto-generated channels - # https://support.google.com/youtube/answer/2579942 - # For auto-generated channels, channel_about_meta only has ["description"]["simpleText"] and ["primaryLinks"][0]["title"]["simpleText"] - if (channel_about_meta["primaryLinks"]?.try &.size || 0) == 1 && (channel_about_meta["primaryLinks"][0]?) && - (channel_about_meta["primaryLinks"][0]["title"]?.try &.["simpleText"]?.try &.as_s? || "") == "Auto-generated by YouTube" - auto_generated = true - end - end + if !channel_about_meta.nil? + total_views = channel_about_meta.dig?("viewCountText", "simpleText").try &.as_s.gsub(/\D/, "").to_i64? || 0_i64 + + # The joined text is split to several sub strings. The reduce joins those strings before parsing the date. + joined = extract_text(channel_about_meta["joinedDateText"]?) + .try { |text| Time.parse(text, "Joined %b %-d, %Y", Time::Location.local) } || Time.unix(0) + + # Normal Auto-generated channels + # https://support.google.com/youtube/answer/2579942 + # For auto-generated channels, channel_about_meta only has + # ["description"]["simpleText"] and ["primaryLinks"][0]["title"]["simpleText"] + auto_generated = ( + (channel_about_meta["primaryLinks"]?.try &.size) == 1 && \ + extract_text(channel_about_meta.dig?("primaryLinks", 0, "title")) == "Auto-generated by YouTube" + ) end - tabs = tabs_json.reject { |node| node["tabRenderer"]?.nil? }.map(&.["tabRenderer"]["title"].as_s.downcase) end sub_count = initdata @@ -148,7 +154,7 @@ def get_about_info(ucid, locale) : AboutChannel joined: joined, is_family_friendly: is_family_friendly, allowed_regions: allowed_regions, - tabs: tabs, + tabs: tab_names, verified: author_verified || false, ) end From 9588fcb5d1dd90e8591ed53a342727a0df6923c4 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sat, 3 Dec 2022 22:39:24 +0100 Subject: [PATCH 28/73] frontend: remove paging on channel videos --- src/invidious/routes/channels.cr | 5 +---- src/invidious/views/channel.ecr | 18 +++--------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index c6e02cbd..f26f29f5 100644 --- a/src/invidious/routes/channels.cr +++ b/src/invidious/routes/channels.cr @@ -12,9 +12,6 @@ module Invidious::Routes::Channels end locale, user, subscriptions, continuation, ucid, channel = data - page = env.params.query["page"]?.try &.to_i? - page ||= 1 - sort_by = env.params.query["sort_by"]?.try &.downcase if channel.auto_generated @@ -35,7 +32,7 @@ module Invidious::Routes::Channels sort_options = {"newest", "oldest", "popular"} sort_by ||= "newest" - count, items = get_60_videos(channel.ucid, channel.author, page, channel.auto_generated, sort_by) + count, items = get_60_videos(channel.ucid, channel.author, 1, channel.auto_generated, sort_by) end templated "channel" diff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecr index dea86abe..878587d4 100644 --- a/src/invidious/views/channel.ecr +++ b/src/invidious/views/channel.ecr @@ -90,7 +90,7 @@ <% if sort_by == sort %> <%= translate(locale, sort) %> <% else %> - + <%= translate(locale, sort) %> <% end %> @@ -111,19 +111,7 @@ From bdc51cd20fd2df99c2fe5ddc281aada86000a783 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Thu, 10 Nov 2022 23:32:51 +0100 Subject: [PATCH 29/73] extractors: separate 'extract' and 'parse' logic --- src/invidious/channels/playlists.cr | 2 +- src/invidious/search/processors.cr | 2 +- src/invidious/yt_backend/extractors.cr | 54 +++++++++++++++----------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/invidious/channels/playlists.cr b/src/invidious/channels/playlists.cr index d5628f6a..e6c0a1d5 100644 --- a/src/invidious/channels/playlists.cr +++ b/src/invidious/channels/playlists.cr @@ -8,7 +8,7 @@ def fetch_channel_playlists(ucid, author, continuation, sort_by) items = [] of SearchItem continuation_items.as_a.select(&.as_h.has_key?("gridPlaylistRenderer")).each { |item| - extract_item(item, author, ucid).try { |t| items << t } + parse_item(item, author, ucid).try { |t| items << t } } continuation = continuation_items.as_a.last["continuationItemRenderer"]? diff --git a/src/invidious/search/processors.cr b/src/invidious/search/processors.cr index d1409c06..683a4a7e 100644 --- a/src/invidious/search/processors.cr +++ b/src/invidious/search/processors.cr @@ -37,7 +37,7 @@ module Invidious::Search items = [] of SearchItem continuation_items.as_a.select(&.as_h.has_key?("itemSectionRenderer")).each do |item| - extract_item(item["itemSectionRenderer"]["contents"].as_a[0]).try { |t| items << t } + parse_item(item["itemSectionRenderer"]["contents"].as_a[0]).try { |t| items << t } end return items diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index edc722cf..a4b20d04 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -20,6 +20,8 @@ private ITEM_PARSERS = { Parsers::ReelItemRendererParser, } +private alias InitialData = Hash(String, JSON::Any) + record AuthorFallback, name : String, id : String # Namespace for logic relating to parsing InnerTube data into various datastructs. @@ -348,7 +350,7 @@ private module Parsers raw_contents = content_container["items"]?.try &.as_a if !raw_contents.nil? raw_contents.each do |item| - result = extract_item(item) + result = parse_item(item) if !result.nil? contents << result end @@ -510,7 +512,7 @@ private module Extractors # }] # module YouTubeTabs - def self.process(initial_data : Hash(String, JSON::Any)) + def self.process(initial_data : InitialData) if target = initial_data["twoColumnBrowseResultsRenderer"]? self.extract(target) end @@ -575,7 +577,7 @@ private module Extractors # } # module SearchResults - def self.process(initial_data : Hash(String, JSON::Any)) + def self.process(initial_data : InitialData) if target = initial_data["twoColumnSearchResultsRenderer"]? self.extract(target) end @@ -608,8 +610,8 @@ private module Extractors # The way they are structured is too varied to be accurately written down here. # However, they all eventually lead to an array of parsable items after traversing # through the JSON structure. - module Continuation - def self.process(initial_data : Hash(String, JSON::Any)) + module ContinuationContent + def self.process(initial_data : InitialData) if target = initial_data["continuationContents"]? self.extract(target) elsif target = initial_data["appendContinuationItemsAction"]? @@ -691,8 +693,7 @@ end # Parses an item from Youtube's JSON response into a more usable structure. # The end result can either be a SearchVideo, SearchPlaylist or SearchChannel. -def extract_item(item : JSON::Any, author_fallback : String? = "", - author_id_fallback : String? = "") +def parse_item(item : JSON::Any, author_fallback : String? = "", author_id_fallback : String? = "") # We "allow" nil values but secretly use empty strings instead. This is to save us the # hassle of modifying every author_fallback and author_id_fallback arg usage # which is more often than not nil. @@ -702,24 +703,23 @@ def extract_item(item : JSON::Any, author_fallback : String? = "", # Each parser automatically validates the data given to see if the data is # applicable to itself. If not nil is returned and the next parser is attempted. ITEM_PARSERS.each do |parser| - LOGGER.trace("extract_item: Attempting to parse item using \"#{parser.parser_name}\" (cycling...)") + LOGGER.trace("parse_item: Attempting to parse item using \"#{parser.parser_name}\" (cycling...)") if result = parser.process(item, author_fallback) - LOGGER.debug("extract_item: Successfully parsed via #{parser.parser_name}") - + LOGGER.debug("parse_item: Successfully parsed via #{parser.parser_name}") return result else - LOGGER.trace("extract_item: Parser \"#{parser.parser_name}\" does not apply. Cycling to the next one...") + LOGGER.trace("parse_item: Parser \"#{parser.parser_name}\" does not apply. Cycling to the next one...") end end end # Parses multiple items from YouTube's initial JSON response into a more usable structure. # The end result is an array of SearchItem. -def extract_items(initial_data : Hash(String, JSON::Any), author_fallback : String? = nil, - author_id_fallback : String? = nil) : Array(SearchItem) - items = [] of SearchItem - +# +# This function yields the container so that items can be parsed separately. +# +def extract_items(initial_data : InitialData, &block) if unpackaged_data = initial_data["contents"]?.try &.as_h elsif unpackaged_data = initial_data["response"]?.try &.as_h elsif unpackaged_data = initial_data.dig?("onResponseReceivedActions", 0).try &.as_h @@ -727,24 +727,32 @@ def extract_items(initial_data : Hash(String, JSON::Any), author_fallback : Stri unpackaged_data = initial_data end - # This is identical to the parser cycling of extract_item(). + # This is identical to the parser cycling of parse_item(). ITEM_CONTAINER_EXTRACTOR.each do |extractor| LOGGER.trace("extract_items: Attempting to extract item container using \"#{extractor.extractor_name}\" (cycling...)") if container = extractor.process(unpackaged_data) LOGGER.debug("extract_items: Successfully unpacked container with \"#{extractor.extractor_name}\"") # Extract items in container - container.each do |item| - if parsed_result = extract_item(item, author_fallback, author_id_fallback) - items << parsed_result - end - end - - break + container.each { |item| yield item } else LOGGER.trace("extract_items: Extractor \"#{extractor.extractor_name}\" does not apply. Cycling to the next one...") end end +end + +# Wrapper using the block function above +def extract_items( + initial_data : InitialData, + author_fallback : String? = nil, + author_id_fallback : String? = nil +) : Array(SearchItem) + items = [] of SearchItem + + extract_items(initial_data) do |item| + parsed = parse_item(item, author_fallback, author_id_fallback) + items << parsed if !parsed.nil? + end return items end From ce7db8d2cb87111af15de2de9faf12aae38283bb Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sat, 5 Nov 2022 18:56:35 +0100 Subject: [PATCH 30/73] extractors: Add continuation token parser --- spec/invidious/hashtag_spec.cr | 4 +- src/invidious/channels/playlists.cr | 16 +----- src/invidious/hashtag.cr | 3 +- src/invidious/helpers/serialized_yt_data.cr | 7 +++ src/invidious/search/processors.cr | 14 ++--- src/invidious/yt_backend/extractors.cr | 54 +++++++++++++++----- src/invidious/yt_backend/extractors_utils.cr | 27 ++-------- 7 files changed, 63 insertions(+), 62 deletions(-) diff --git a/spec/invidious/hashtag_spec.cr b/spec/invidious/hashtag_spec.cr index 77676878..266ec57b 100644 --- a/spec/invidious/hashtag_spec.cr +++ b/spec/invidious/hashtag_spec.cr @@ -4,7 +4,7 @@ Spectator.describe Invidious::Hashtag do it "parses richItemRenderer containers (test 1)" do # Enable mock test_content = load_mock("hashtag/martingarrix_page1") - videos = extract_items(test_content) + videos, _ = extract_items(test_content) expect(typeof(videos)).to eq(Array(SearchItem)) expect(videos.size).to eq(60) @@ -57,7 +57,7 @@ Spectator.describe Invidious::Hashtag do it "parses richItemRenderer containers (test 2)" do # Enable mock test_content = load_mock("hashtag/martingarrix_page2") - videos = extract_items(test_content) + videos, _ = extract_items(test_content) expect(typeof(videos)).to eq(Array(SearchItem)) expect(videos.size).to eq(60) diff --git a/src/invidious/channels/playlists.cr b/src/invidious/channels/playlists.cr index e6c0a1d5..0d46499a 100644 --- a/src/invidious/channels/playlists.cr +++ b/src/invidious/channels/playlists.cr @@ -1,18 +1,7 @@ def fetch_channel_playlists(ucid, author, continuation, sort_by) if continuation response_json = YoutubeAPI.browse(continuation) - continuation_items = response_json["onResponseReceivedActions"]? - .try &.[0]["appendContinuationItemsAction"]["continuationItems"] - - return [] of SearchItem, nil if !continuation_items - - items = [] of SearchItem - continuation_items.as_a.select(&.as_h.has_key?("gridPlaylistRenderer")).each { |item| - parse_item(item, author, ucid).try { |t| items << t } - } - - continuation = continuation_items.as_a.last["continuationItemRenderer"]? - .try &.["continuationEndpoint"]["continuationCommand"]["token"].as_s + items, continuation = extract_items(response_json, author, ucid) else url = "/channel/#{ucid}/playlists?flow=list&view=1" @@ -30,8 +19,7 @@ def fetch_channel_playlists(ucid, author, continuation, sort_by) initial_data = extract_initial_data(response.body) return [] of SearchItem, nil if !initial_data - items = extract_items(initial_data, author, ucid) - continuation = response.body.match(/"token":"(?[^"]+)"/).try &.["continuation"]? + items, continuation = extract_items(initial_data, author, ucid) end return items, continuation diff --git a/src/invidious/hashtag.cr b/src/invidious/hashtag.cr index afe31a36..bc329205 100644 --- a/src/invidious/hashtag.cr +++ b/src/invidious/hashtag.cr @@ -8,7 +8,8 @@ module Invidious::Hashtag client_config = YoutubeAPI::ClientConfig.new(region: region) response = YoutubeAPI.browse(continuation: ctoken, client_config: client_config) - return extract_items(response) + items, _ = extract_items(response) + return items end def generate_continuation(hashtag : String, cursor : Int) diff --git a/src/invidious/helpers/serialized_yt_data.cr b/src/invidious/helpers/serialized_yt_data.cr index c52e2a0d..635f0984 100644 --- a/src/invidious/helpers/serialized_yt_data.cr +++ b/src/invidious/helpers/serialized_yt_data.cr @@ -265,4 +265,11 @@ class Category end end +struct Continuation + getter token + + def initialize(@token : String) + end +end + alias SearchItem = SearchVideo | SearchChannel | SearchPlaylist | Category diff --git a/src/invidious/search/processors.cr b/src/invidious/search/processors.cr index 683a4a7e..7e909590 100644 --- a/src/invidious/search/processors.cr +++ b/src/invidious/search/processors.cr @@ -9,7 +9,8 @@ module Invidious::Search client_config = YoutubeAPI::ClientConfig.new(region: query.region) initial_data = YoutubeAPI.search(query.text, search_params, client_config: client_config) - return extract_items(initial_data) + items, _ = extract_items(initial_data) + return items end # Search a youtube channel @@ -30,16 +31,7 @@ module Invidious::Search continuation = produce_channel_search_continuation(ucid, query.text, query.page) response_json = YoutubeAPI.browse(continuation) - continuation_items = response_json["onResponseReceivedActions"]? - .try &.[0]["appendContinuationItemsAction"]["continuationItems"] - - return [] of SearchItem if !continuation_items - - items = [] of SearchItem - continuation_items.as_a.select(&.as_h.has_key?("itemSectionRenderer")).each do |item| - parse_item(item["itemSectionRenderer"]["contents"].as_a[0]).try { |t| items << t } - end - + items, _ = extract_items(response_json, "", ucid) return items end diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index a4b20d04..baf52118 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -7,7 +7,7 @@ require "../helpers/serialized_yt_data" private ITEM_CONTAINER_EXTRACTOR = { Extractors::YouTubeTabs, Extractors::SearchResults, - Extractors::Continuation, + Extractors::ContinuationContent, } private ITEM_PARSERS = { @@ -18,6 +18,7 @@ private ITEM_PARSERS = { Parsers::CategoryRendererParser, Parsers::RichItemRendererParser, Parsers::ReelItemRendererParser, + Parsers::ContinuationItemRendererParser, } private alias InitialData = Hash(String, JSON::Any) @@ -347,14 +348,9 @@ private module Parsers content_container = item_contents["contents"] end - raw_contents = content_container["items"]?.try &.as_a - if !raw_contents.nil? - raw_contents.each do |item| - result = parse_item(item) - if !result.nil? - contents << result - end - end + content_container["items"]?.try &.as_a.each do |item| + result = parse_item(item, author_fallback.name, author_fallback.id) + contents << result if result.is_a?(SearchItem) end Category.new({ @@ -477,6 +473,35 @@ private module Parsers return {{@type.name}} end end + + # Parses an InnerTube continuationItemRenderer into a Continuation. + # Returns nil when the given object isn't a continuationItemRenderer. + # + # continuationItemRenderer contains various metadata ued to load more + # content (i.e when the user scrolls down). The interesting bit is the + # protobuf object known as the "continutation token". Previously, those + # were generated from sratch, but recent (as of 11/2022) Youtube changes + # are forcing us to extract them from replies. + # + module ContinuationItemRendererParser + def self.process(item : JSON::Any, author_fallback : AuthorFallback) + if item_contents = item["continuationItemRenderer"]? + return self.parse(item_contents) + end + end + + private def self.parse(item_contents) + token = item_contents + .dig?("continuationEndpoint", "continuationCommand", "token") + .try &.as_s + + return Continuation.new(token) if token + end + + def self.parser_name + return {{@type.name}} + end + end end # The following are the extractors for extracting an array of items from @@ -746,13 +771,18 @@ def extract_items( initial_data : InitialData, author_fallback : String? = nil, author_id_fallback : String? = nil -) : Array(SearchItem) +) : {Array(SearchItem), String?} items = [] of SearchItem + continuation = nil extract_items(initial_data) do |item| parsed = parse_item(item, author_fallback, author_id_fallback) - items << parsed if !parsed.nil? + + case parsed + when .is_a?(Continuation) then continuation = parsed.token + when .is_a?(SearchItem) then items << parsed + end end - return items + return items, continuation end diff --git a/src/invidious/yt_backend/extractors_utils.cr b/src/invidious/yt_backend/extractors_utils.cr index f8245160..0cb3c079 100644 --- a/src/invidious/yt_backend/extractors_utils.cr +++ b/src/invidious/yt_backend/extractors_utils.cr @@ -68,10 +68,10 @@ rescue ex return false end -def extract_videos(initial_data : Hash(String, JSON::Any), author_fallback : String? = nil, author_id_fallback : String? = nil) - extracted = extract_items(initial_data, author_fallback, author_id_fallback) +def extract_videos(initial_data : Hash(String, JSON::Any), author_fallback : String? = nil, author_id_fallback : String? = nil) : Array(SearchVideo) + extracted, _ = extract_items(initial_data, author_fallback, author_id_fallback) - target = [] of SearchItem + target = [] of (SearchItem | Continuation) extracted.each do |i| if i.is_a?(Category) i.contents.each { |cate_i| target << cate_i if !cate_i.is_a? Video } @@ -79,28 +79,11 @@ def extract_videos(initial_data : Hash(String, JSON::Any), author_fallback : Str target << i end end - return target.select(SearchVideo).map(&.as(SearchVideo)) + + return target.select(SearchVideo) end def extract_selected_tab(tabs) # Extract the selected tab from the array of tabs Youtube returns return selected_target = tabs.as_a.select(&.["tabRenderer"]?.try &.["selected"]?.try &.as_bool)[0]["tabRenderer"] end - -def fetch_continuation_token(items : Array(JSON::Any)) - # Fetches the continuation token from an array of items - return items.last["continuationItemRenderer"]? - .try &.["continuationEndpoint"]["continuationCommand"]["token"].as_s -end - -def fetch_continuation_token(initial_data : Hash(String, JSON::Any)) - # Fetches the continuation token from initial data - if initial_data["onResponseReceivedActions"]? - continuation_items = initial_data["onResponseReceivedActions"][0]["appendContinuationItemsAction"]["continuationItems"] - else - tab = extract_selected_tab(initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]) - continuation_items = tab["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"][0]["gridRenderer"]["items"] - end - - return fetch_continuation_token(continuation_items.as_a) -end From 8e8ca4fcc5cfcb7bebc3f29440d6abc1de770513 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sat, 12 Nov 2022 00:04:27 +0100 Subject: [PATCH 31/73] Prepare to create a 'Channel' module --- src/invidious.cr | 9 ++++++++- src/invidious/jobs/notification_job.cr | 4 ++-- src/invidious/jobs/refresh_channels_job.cr | 2 +- src/invidious/jobs/refresh_feeds_job.cr | 2 +- src/invidious/jobs/subscribe_to_feeds_job.cr | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 2874cc71..5064f0b8 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -48,6 +48,13 @@ require "./invidious/search/*" require "./invidious/routes/**" require "./invidious/jobs/**" +# Declare the base namespace for invidious +module Invidious +end + +# Simple alias to make code easier to read +alias IV = Invidious + CONFIG = Config.load HMAC_KEY = CONFIG.hmac_key || Random::Secure.hex(32) @@ -172,7 +179,7 @@ if CONFIG.popular_enabled Invidious::Jobs.register Invidious::Jobs::PullPopularVideosJob.new(PG_DB) end -CONNECTION_CHANNEL = Channel({Bool, Channel(PQ::Notification)}).new(32) +CONNECTION_CHANNEL = ::Channel({Bool, ::Channel(PQ::Notification)}).new(32) Invidious::Jobs.register Invidious::Jobs::NotificationJob.new(CONNECTION_CHANNEL, CONFIG.database_url) Invidious::Jobs.register Invidious::Jobs::ClearExpiredItemsJob.new diff --git a/src/invidious/jobs/notification_job.cr b/src/invidious/jobs/notification_job.cr index 2f525e08..b445107b 100644 --- a/src/invidious/jobs/notification_job.cr +++ b/src/invidious/jobs/notification_job.cr @@ -1,12 +1,12 @@ class Invidious::Jobs::NotificationJob < Invidious::Jobs::BaseJob - private getter connection_channel : Channel({Bool, Channel(PQ::Notification)}) + private getter connection_channel : ::Channel({Bool, ::Channel(PQ::Notification)}) private getter pg_url : URI def initialize(@connection_channel, @pg_url) end def begin - connections = [] of Channel(PQ::Notification) + connections = [] of ::Channel(PQ::Notification) PG.connect_listen(pg_url, "notifications") { |event| connections.each(&.send(event)) } diff --git a/src/invidious/jobs/refresh_channels_job.cr b/src/invidious/jobs/refresh_channels_job.cr index 92681408..80812a63 100644 --- a/src/invidious/jobs/refresh_channels_job.cr +++ b/src/invidious/jobs/refresh_channels_job.cr @@ -8,7 +8,7 @@ class Invidious::Jobs::RefreshChannelsJob < Invidious::Jobs::BaseJob max_fibers = CONFIG.channel_threads lim_fibers = max_fibers active_fibers = 0 - active_channel = Channel(Bool).new + active_channel = ::Channel(Bool).new backoff = 2.minutes loop do diff --git a/src/invidious/jobs/refresh_feeds_job.cr b/src/invidious/jobs/refresh_feeds_job.cr index 4b52c959..4f8130df 100644 --- a/src/invidious/jobs/refresh_feeds_job.cr +++ b/src/invidious/jobs/refresh_feeds_job.cr @@ -7,7 +7,7 @@ class Invidious::Jobs::RefreshFeedsJob < Invidious::Jobs::BaseJob def begin max_fibers = CONFIG.feed_threads active_fibers = 0 - active_channel = Channel(Bool).new + active_channel = ::Channel(Bool).new loop do db.query("SELECT email FROM users WHERE feed_needs_update = true OR feed_needs_update IS NULL") do |rs| diff --git a/src/invidious/jobs/subscribe_to_feeds_job.cr b/src/invidious/jobs/subscribe_to_feeds_job.cr index a431a48a..8584fb9c 100644 --- a/src/invidious/jobs/subscribe_to_feeds_job.cr +++ b/src/invidious/jobs/subscribe_to_feeds_job.cr @@ -12,7 +12,7 @@ class Invidious::Jobs::SubscribeToFeedsJob < Invidious::Jobs::BaseJob end active_fibers = 0 - active_channel = Channel(Bool).new + active_channel = ::Channel(Bool).new loop do db.query_all("SELECT id FROM channels WHERE CURRENT_TIMESTAMP - subscribed > interval '4 days' OR subscribed IS NULL") do |rs| From c5ee2bfc0f5e485f91e53dedc879312c3e729be8 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Fri, 11 Nov 2022 00:44:24 +0100 Subject: [PATCH 32/73] channel: use YT API to fetch playlist items --- src/invidious/channels/playlists.cr | 40 +++++++++++++++-------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/invidious/channels/playlists.cr b/src/invidious/channels/playlists.cr index 0d46499a..8fdac3a7 100644 --- a/src/invidious/channels/playlists.cr +++ b/src/invidious/channels/playlists.cr @@ -1,28 +1,30 @@ def fetch_channel_playlists(ucid, author, continuation, sort_by) if continuation - response_json = YoutubeAPI.browse(continuation) - items, continuation = extract_items(response_json, author, ucid) + initial_data = YoutubeAPI.browse(continuation) else - url = "/channel/#{ucid}/playlists?flow=list&view=1" + params = + case sort_by + when "last", "last_added" + # Equivalent to "&sort=lad" + # {"2:string": "playlists", "3:varint": 4, "4:varint": 1, "6:varint": 1} + "EglwbGF5bGlzdHMYBCABMAE%3D" + when "oldest", "oldest_created" + # formerly "&sort=da" + # Not available anymore :c or maybe ?? + # {"2:string": "playlists", "3:varint": 2, "4:varint": 1, "6:varint": 1} + "EglwbGF5bGlzdHMYAiABMAE%3D" + # {"2:string": "playlists", "3:varint": 1, "4:varint": 1, "6:varint": 1} + # "EglwbGF5bGlzdHMYASABMAE%3D" + when "newest", "newest_created" + # Formerly "&sort=dd" + # {"2:string": "playlists", "3:varint": 3, "4:varint": 1, "6:varint": 1} + "EglwbGF5bGlzdHMYAyABMAE%3D" + end - case sort_by - when "last", "last_added" - # - when "oldest", "oldest_created" - url += "&sort=da" - when "newest", "newest_created" - url += "&sort=dd" - else nil # Ignore - end - - response = YT_POOL.client &.get(url) - initial_data = extract_initial_data(response.body) - return [] of SearchItem, nil if !initial_data - - items, continuation = extract_items(initial_data, author, ucid) + initial_data = YoutubeAPI.browse(ucid, params: params || "") end - return items, continuation + return extract_items(initial_data, ucid, author) end # ## NOTE: DEPRECATED From 2903e896ecf2404bf932438a33432125a6ad1fca Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Fri, 11 Nov 2022 20:26:34 +0100 Subject: [PATCH 33/73] channel: use YT API + extractors to fetch videos --- src/invidious/channels/channels.cr | 65 ++++++++--------- src/invidious/channels/playlists.cr | 2 +- src/invidious/channels/videos.cr | 94 ++++++++++++++++++------- src/invidious/routes/api/v1/channels.cr | 66 +++++++---------- src/invidious/routes/channels.cr | 4 +- 5 files changed, 127 insertions(+), 104 deletions(-) diff --git a/src/invidious/channels/channels.cr b/src/invidious/channels/channels.cr index e3d3d9ee..27369f12 100644 --- a/src/invidious/channels/channels.cr +++ b/src/invidious/channels/channels.cr @@ -180,11 +180,16 @@ def fetch_channel(ucid, pull_all_videos : Bool) LOGGER.trace("fetch_channel: #{ucid} : author = #{author}, auto_generated = #{auto_generated}") - page = 1 + channel = InvidiousChannel.new({ + id: ucid, + author: author, + updated: Time.utc, + deleted: false, + subscribed: nil, + }) LOGGER.trace("fetch_channel: #{ucid} : Downloading channel videos page") - initial_data = get_channel_videos_response(ucid, page, auto_generated: auto_generated) - videos = extract_videos(initial_data, author, ucid) + videos, continuation = IV::Channel::Tabs.get_videos(channel) LOGGER.trace("fetch_channel: #{ucid} : Extracting videos from channel RSS feed") rss.xpath_nodes("//feed/entry").each do |entry| @@ -197,7 +202,9 @@ def fetch_channel(ucid, pull_all_videos : Bool) views = entry.xpath_node("group/community/statistics").try &.["views"]?.try &.to_i64? views ||= 0_i64 - channel_video = videos.select { |video| video.id == video_id }[0]? + channel_video = videos + .select(SearchVideo) + .select(&.id.== video_id)[0]? length_seconds = channel_video.try &.length_seconds length_seconds ||= 0 @@ -235,30 +242,25 @@ def fetch_channel(ucid, pull_all_videos : Bool) end if pull_all_videos - page += 1 - - ids = [] of String - loop do - initial_data = get_channel_videos_response(ucid, page, auto_generated: auto_generated) - videos = extract_videos(initial_data, author, ucid) + # Keep fetching videos using the continuation token retrieved earlier + videos, continuation = IV::Channel::Tabs.get_videos(channel, continuation: continuation) - count = videos.size - videos = videos.map { |video| ChannelVideo.new({ - id: video.id, - title: video.title, - published: video.published, - updated: Time.utc, - ucid: video.ucid, - author: video.author, - length_seconds: video.length_seconds, - live_now: video.live_now, - premiere_timestamp: video.premiere_timestamp, - views: video.views, - }) } - - videos.each do |video| - ids << video.id + count = 0 + videos.select(SearchVideo).each do |video| + count += 1 + video = ChannelVideo.new({ + id: video.id, + title: video.title, + published: video.published, + updated: Time.utc, + ucid: video.ucid, + author: video.author, + length_seconds: video.length_seconds, + live_now: video.live_now, + premiere_timestamp: video.premiere_timestamp, + views: video.views, + }) # We are notified of Red videos elsewhere (PubSub), which includes a correct published date, # so since they don't provide a published date here we can safely ignore them. @@ -269,17 +271,10 @@ def fetch_channel(ucid, pull_all_videos : Bool) end break if count < 25 - page += 1 + sleep 500.milliseconds end end - channel = InvidiousChannel.new({ - id: ucid, - author: author, - updated: Time.utc, - deleted: false, - subscribed: nil, - }) - + channel.updated = Time.utc return channel end diff --git a/src/invidious/channels/playlists.cr b/src/invidious/channels/playlists.cr index 8fdac3a7..772eecb9 100644 --- a/src/invidious/channels/playlists.cr +++ b/src/invidious/channels/playlists.cr @@ -24,7 +24,7 @@ def fetch_channel_playlists(ucid, author, continuation, sort_by) initial_data = YoutubeAPI.browse(ucid, params: params || "") end - return extract_items(initial_data, ucid, author) + return extract_items(initial_data, author, ucid) end # ## NOTE: DEPRECATED diff --git a/src/invidious/channels/videos.cr b/src/invidious/channels/videos.cr index b495e597..23ad4e02 100644 --- a/src/invidious/channels/videos.cr +++ b/src/invidious/channels/videos.cr @@ -16,6 +16,14 @@ def produce_channel_videos_continuation(ucid, page = 1, auto_generated = nil, so .try { |i| Base64.urlsafe_encode(i) } .try { |i| URI.encode_www_form(i) } + sort_by_numerical = + case sort_by + when "newest" then 1_i64 + when "popular" then 2_i64 + when "oldest" then 3_i64 # Broken as of 10/2022 :c + else 1_i64 # Fallback to "newest" + end + object_inner_1 = { "110:embedded" => { "3:embedded" => { @@ -24,7 +32,7 @@ def produce_channel_videos_continuation(ucid, page = 1, auto_generated = nil, so "1:string" => object_inner_2_encoded, "2:string" => "00000000-0000-0000-0000-000000000000", }, - "3:varint" => 1_i64, + "3:varint" => sort_by_numerical, }, }, }, @@ -52,34 +60,66 @@ def produce_channel_videos_continuation(ucid, page = 1, auto_generated = nil, so return continuation end -def get_channel_videos_response(ucid, page = 1, auto_generated = nil, sort_by = "newest") - continuation = produce_channel_videos_continuation(ucid, page, - auto_generated: auto_generated, sort_by: sort_by, v2: true) - - return YoutubeAPI.browse(continuation) -end - -def get_60_videos(ucid, author, page, auto_generated, sort_by = "newest") - videos = [] of SearchVideo - - # 2.times do |i| - # initial_data = get_channel_videos_response(ucid, page * 2 + (i - 1), auto_generated: auto_generated, sort_by: sort_by) - initial_data = get_channel_videos_response(ucid, 1, auto_generated: auto_generated, sort_by: sort_by) - videos = extract_videos(initial_data, author, ucid) - # end - - return videos.size, videos -end - -def get_latest_videos(ucid) - initial_data = get_channel_videos_response(ucid) - author = initial_data["metadata"]?.try &.["channelMetadataRenderer"]?.try &.["title"]?.try &.as_s - - return extract_videos(initial_data, author, ucid) -end - # Used in bypass_captcha_job.cr def produce_channel_videos_url(ucid, page = 1, auto_generated = nil, sort_by = "newest", v2 = false) continuation = produce_channel_videos_continuation(ucid, page, auto_generated, sort_by, v2) return "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" end + +module Invidious::Channel::Tabs + extend self + + # ------------------- + # Regular videos + # ------------------- + + def make_initial_video_ctoken(ucid, sort_by) : String + return produce_channel_videos_continuation(ucid, sort_by: sort_by) + end + + # Wrapper for AboutChannel, as we still need to call get_videos with + # an author name and ucid directly (e.g in RSS feeds). + # TODO: figure out how to get rid of that + def get_videos(channel : AboutChannel, *, continuation : String? = nil, sort_by = "newest") + return get_videos( + channel.author, channel.ucid, + continuation: continuation, sort_by: sort_by + ) + end + + # Wrapper for InvidiousChannel, as we still need to call get_videos with + # an author name and ucid directly (e.g in RSS feeds). + # TODO: figure out how to get rid of that + def get_videos(channel : InvidiousChannel, *, continuation : String? = nil, sort_by = "newest") + return get_videos( + channel.author, channel.id, + continuation: continuation, sort_by: sort_by + ) + end + + def get_videos(author : String, ucid : String, *, continuation : String? = nil, sort_by = "newest") + continuation ||= make_initial_video_ctoken(ucid, sort_by) + initial_data = YoutubeAPI.browse(continuation: continuation) + + return extract_items(initial_data, author, ucid) + end + + def get_60_videos(channel : AboutChannel, *, continuation : String? = nil, sort_by = "newest") + if continuation.nil? + # Fetch the first "page" of video + items, next_continuation = get_videos(channel, sort_by: sort_by) + else + # Fetch a "page" of videos using the given continuation token + items, next_continuation = get_videos(channel, continuation: continuation) + end + + # If there is more to load, then load a second "page" + # and replace the previous continuation token + if !next_continuation.nil? + items_2, next_continuation = get_videos(channel, continuation: next_continuation) + items.concat items_2 + end + + return items, next_continuation + end +end diff --git a/src/invidious/routes/api/v1/channels.cr b/src/invidious/routes/api/v1/channels.cr index 6b81c546..72d9ae5f 100644 --- a/src/invidious/routes/api/v1/channels.cr +++ b/src/invidious/routes/api/v1/channels.cr @@ -5,8 +5,6 @@ module Invidious::Routes::API::V1::Channels env.response.content_type = "application/json" ucid = env.params.url["ucid"] - sort_by = env.params.query["sort_by"]?.try &.downcase - sort_by ||= "newest" begin channel = get_about_info(ucid, locale) @@ -19,16 +17,13 @@ module Invidious::Routes::API::V1::Channels return error_json(500, ex) end - page = 1 - if channel.auto_generated - videos = [] of SearchVideo - count = 0 - else - begin - count, videos = get_60_videos(channel.ucid, channel.author, page, channel.auto_generated, sort_by) - rescue ex - return error_json(500, ex) - end + # Retrieve "sort by" setting from URL parameters + sort_by = env.params.query["sort_by"]?.try &.downcase || "newest" + + begin + videos, _ = Channel::Tabs.get_videos(channel, sort_by: sort_by) + rescue ex + return error_json(500, ex) end JSON.build do |json| @@ -134,25 +129,11 @@ module Invidious::Routes::API::V1::Channels end def self.latest(env) - locale = env.get("preferences").as(Preferences).locale + # Remove parameters that could affect this endpoint's behavior + env.params.query.delete("sort_by") if env.params.query.has_key?("sort_by") + env.params.query.delete("continuation") if env.params.query.has_key?("continuation") - env.response.content_type = "application/json" - - ucid = env.params.url["ucid"] - - begin - videos = get_latest_videos(ucid) - rescue ex - return error_json(500, ex) - end - - JSON.build do |json| - json.array do - videos.each do |video| - video.to_json(locale, json) - end - end - end + return self.videos(env) end def self.videos(env) @@ -161,11 +142,6 @@ module Invidious::Routes::API::V1::Channels env.response.content_type = "application/json" ucid = env.params.url["ucid"] - page = env.params.query["page"]?.try &.to_i? - page ||= 1 - sort_by = env.params.query["sort"]?.try &.downcase - sort_by ||= env.params.query["sort_by"]?.try &.downcase - sort_by ||= "newest" begin channel = get_about_info(ucid, locale) @@ -178,17 +154,27 @@ module Invidious::Routes::API::V1::Channels return error_json(500, ex) end + # Retrieve some URL parameters + sort_by = env.params.query["sort_by"]?.try &.downcase || "newest" + continuation = env.params.query["continuation"]? + begin - count, videos = get_60_videos(channel.ucid, channel.author, page, channel.auto_generated, sort_by) + videos, next_continuation = Channel::Tabs.get_60_videos( + channel, continuation: continuation, sort_by: sort_by + ) rescue ex return error_json(500, ex) end - JSON.build do |json| - json.array do - videos.each do |video| - video.to_json(locale, json) + return JSON.build do |json| + json.object do + json.field "videos" do + json.array do + videos.each &.to_json(locale, json) + end end + + json.field "continuation", next_continuation if next_continuation end end end diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index f26f29f5..2773deb7 100644 --- a/src/invidious/routes/channels.cr +++ b/src/invidious/routes/channels.cr @@ -32,7 +32,9 @@ module Invidious::Routes::Channels sort_options = {"newest", "oldest", "popular"} sort_by ||= "newest" - count, items = get_60_videos(channel.ucid, channel.author, 1, channel.auto_generated, sort_by) + items, continuation = Channel::Tabs.get_60_videos( + channel, continuation: continuation, sort_by: sort_by + ) end templated "channel" From 52ef89f02d0ab29fd0f218abc4051328b3d96809 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sat, 12 Nov 2022 00:09:03 +0100 Subject: [PATCH 34/73] channel: Add support for shorts and livestreams (backend only) --- src/invidious/channels/videos.cr | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/invidious/channels/videos.cr b/src/invidious/channels/videos.cr index 23ad4e02..bea406c1 100644 --- a/src/invidious/channels/videos.cr +++ b/src/invidious/channels/videos.cr @@ -122,4 +122,54 @@ module Invidious::Channel::Tabs return items, next_continuation end + + # ------------------- + # Shorts + # ------------------- + + def get_shorts(channel : AboutChannel, continuation : String? = nil) + if continuation.nil? + # EgZzaG9ydHPyBgUKA5oBAA%3D%3D is the protobuf object to load "shorts" + # TODO: try to extract the continuation tokens that allows other sorting options + initial_data = YoutubeAPI.browse(channel.ucid, params: "EgZzaG9ydHPyBgUKA5oBAA%3D%3D") + else + initial_data = YoutubeAPI.browse(continuation: continuation) + end + + return extract_items(initial_data, channel.author, channel.ucid) + end + + # ------------------- + # Livestreams + # ------------------- + + def get_livestreams(channel : AboutChannel, continuation : String? = nil) + if continuation.nil? + # EgdzdHJlYW1z8gYECgJ6AA%3D%3D is the protobuf object to load "streams" + initial_data = YoutubeAPI.browse(channel.ucid, params: "EgdzdHJlYW1z8gYECgJ6AA%3D%3D") + else + initial_data = YoutubeAPI.browse(continuation: continuation) + end + + return extract_items(initial_data, channel.author, channel.ucid) + end + + def get_60_livestreams(channel : AboutChannel, continuation : String? = nil) + if continuation.nil? + # Fetch the first "page" of streams + items, next_continuation = get_livestreams(channel) + else + # Fetch a "page" of streams using the given continuation token + items, next_continuation = get_livestreams(channel, continuation: continuation) + end + + # If there is more to load, then load a second "page" + # and replace the previous continuation token + if !next_continuation.nil? + items_2, next_continuation = get_livestreams(channel, continuation: next_continuation) + items.concat items_2 + end + + return items, next_continuation + end end From 5d6abd5301b14c24475bf7ad477a43c60ff78993 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Thu, 1 Dec 2022 23:01:31 +0100 Subject: [PATCH 35/73] extractors: Fix ReelItemRendererParser --- src/invidious/yt_backend/extractors.cr | 32 ++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index baf52118..bca0dcbd 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -382,7 +382,9 @@ private module Parsers end private def self.parse(item_contents, author_fallback) - return VideoRendererParser.process(item_contents, author_fallback) + child = VideoRendererParser.process(item_contents, author_fallback) + child ||= ReelItemRendererParser.process(item_contents, author_fallback) + return child end def self.parser_name @@ -406,12 +408,18 @@ private module Parsers private def self.parse(item_contents, author_fallback) video_id = item_contents["videoId"].as_s - video_details_container = item_contents.dig( - "navigationEndpoint", "reelWatchEndpoint", - "overlay", "reelPlayerOverlayRenderer", - "reelPlayerHeaderSupportedRenderers", - "reelPlayerHeaderRenderer" - ) + begin + video_details_container = item_contents.dig( + "navigationEndpoint", "reelWatchEndpoint", + "overlay", "reelPlayerOverlayRenderer", + "reelPlayerHeaderSupportedRenderers", + "reelPlayerHeaderRenderer" + ) + rescue ex : KeyError + # Extract key name from original message + key = /"([^"]+)"/.match(ex.message || "").try &.[1]? + raise BrokenTubeException.new(key || "reelPlayerOverlayRenderer") + end # Author infos @@ -434,9 +442,9 @@ private module Parsers # View count - view_count_text = video_details_container.dig?("viewCountText", "simpleText") - view_count_text ||= video_details_container - .dig?("viewCountText", "accessibility", "accessibilityData", "label") + # View count used to be in the reelWatchEndpoint, but that changed? + view_count_text = item_contents.dig?("viewCountText", "simpleText") + view_count_text ||= video_details_container.dig?("viewCountText", "simpleText") view_count = view_count_text.try &.as_s.gsub(/\D+/, "").to_i64? || 0_i64 @@ -448,8 +456,8 @@ private module Parsers regex_match = /- (?\d+ minutes? )?(?\d+ seconds?)+ -/.match(a11y_data) - minutes = regex_match.try &.["min"].to_i(strict: false) || 0 - seconds = regex_match.try &.["sec"].to_i(strict: false) || 0 + minutes = regex_match.try &.["min"]?.try &.to_i(strict: false) || 0 + seconds = regex_match.try &.["sec"]?.try &.to_i(strict: false) || 0 duration = (minutes*60 + seconds) From 6c9754e66316d903ed4f89d2cd59cd82940509f5 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Wed, 30 Nov 2022 00:29:48 +0100 Subject: [PATCH 36/73] frontend: Add support for shorts and livestreams --- locales/en-US.json | 9 +++-- src/invidious/channels/about.cr | 10 ++++- src/invidious/frontend/channel_page.cr | 43 ++++++++++++++++++++ src/invidious/routes/channels.cr | 54 ++++++++++++++++++++++++-- src/invidious/routing.cr | 4 +- src/invidious/views/channel.ecr | 30 +++++--------- src/invidious/views/community.ecr | 15 +------ src/invidious/views/playlists.ecr | 14 +------ 8 files changed, 124 insertions(+), 55 deletions(-) create mode 100644 src/invidious/frontend/channel_page.cr diff --git a/locales/en-US.json b/locales/en-US.json index 5554b928..44b40c24 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -404,9 +404,7 @@ "`x` marked it with a ❤": "`x` marked it with a ❤", "Audio mode": "Audio mode", "Video mode": "Video mode", - "Videos": "Videos", "Playlists": "Playlists", - "Community": "Community", "search_filters_title": "Filters", "search_filters_date_label": "Upload date", "search_filters_date_option_none": "Any date", @@ -472,5 +470,10 @@ "crash_page_read_the_faq": "read the Frequently Asked Questions (FAQ)", "crash_page_search_issue": "searched for existing issues on GitHub", "crash_page_report_issue": "If none of the above helped, please open a new issue on GitHub (preferably in English) and include the following text in your message (do NOT translate that text):", - "error_video_not_in_playlist": "The requested video doesn't exist in this playlist. Click here for the playlist home page." + "error_video_not_in_playlist": "The requested video doesn't exist in this playlist. Click here for the playlist home page.", + "channel_tab_videos_label": "Videos", + "channel_tab_shorts_label": "Shorts", + "channel_tab_streams_label": "Livestreams", + "channel_tab_playlists_label": "Playlists", + "channel_tab_community_label": "Community" } diff --git a/src/invidious/channels/about.cr b/src/invidious/channels/about.cr index bb9bd8c7..09c3427a 100644 --- a/src/invidious/channels/about.cr +++ b/src/invidious/channels/about.cr @@ -104,8 +104,14 @@ def get_about_info(ucid, locale) : AboutChannel if tabs_json = initdata["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]? # Get the name of the tabs available on this channel - tab_names = tabs_json.as_a - .compact_map(&.dig?("tabRenderer", "title").try &.as_s.downcase) + tab_names = tabs_json.as_a.compact_map do |entry| + name = entry.dig?("tabRenderer", "title").try &.as_s.downcase + + # This is a small fix to not add extra code on the HTML side + # I.e, the URL for the "live" tab is .../streams, so use "streams" + # everywhere for the sake of simplicity + (name == "live") ? "streams" : name + end # Get the currently active tab ("About") about_tab = extract_selected_tab(tabs_json) diff --git a/src/invidious/frontend/channel_page.cr b/src/invidious/frontend/channel_page.cr new file mode 100644 index 00000000..7ac0e071 --- /dev/null +++ b/src/invidious/frontend/channel_page.cr @@ -0,0 +1,43 @@ +module Invidious::Frontend::ChannelPage + extend self + + enum TabsAvailable + Videos + Shorts + Streams + Playlists + Community + end + + def generate_tabs_links(locale : String, channel : AboutChannel, selected_tab : TabsAvailable) + return String.build(1500) do |str| + base_url = "/channel/#{channel.ucid}" + + TabsAvailable.each do |tab| + # Ignore playlists, as it is not supported for auto-generated channels yet + next if (tab.playlists? && channel.auto_generated) + + tab_name = tab.to_s.downcase + + if channel.tabs.includes? tab_name + str << %(
\n) + + if tab == selected_tab + str << "\t" + str << translate(locale, "channel_tab_#{tab_name}_label") + str << "\n" + else + # Video tab doesn't have the last path component + url = tab.videos? ? base_url : "#{base_url}/#{tab_name}" + + str << %(\t) + str << translate(locale, "channel_tab_#{tab_name}_label") + str << "\n" + end + + str << "
" + end + end + end + end +end diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index 2773deb7..78b38341 100644 --- a/src/invidious/routes/channels.cr +++ b/src/invidious/routes/channels.cr @@ -18,7 +18,7 @@ module Invidious::Routes::Channels sort_options = {"last", "oldest", "newest"} sort_by ||= "last" - items, continuation = fetch_channel_playlists(channel.ucid, channel.author, continuation, sort_by) + items, next_continuation = fetch_channel_playlists(channel.ucid, channel.author, continuation, sort_by) items.uniq! do |item| if item.responds_to?(:title) item.title @@ -32,11 +32,59 @@ module Invidious::Routes::Channels sort_options = {"newest", "oldest", "popular"} sort_by ||= "newest" - items, continuation = Channel::Tabs.get_60_videos( + # Fetch items and continuation token + items, next_continuation = Channel::Tabs.get_videos( channel, continuation: continuation, sort_by: sort_by ) end + selected_tab = Frontend::ChannelPage::TabsAvailable::Videos + templated "channel" + end + + def self.shorts(env) + data = self.fetch_basic_information(env) + return data if !data.is_a?(Tuple) + + locale, user, subscriptions, continuation, ucid, channel = data + + if !channel.tabs.includes? "shorts" + return env.redirect "/channel/#{channel.ucid}" + end + + # TODO: support sort option for shorts + sort_by = "" + sort_options = [] of String + + # Fetch items and continuation token + items, next_continuation = Channel::Tabs.get_shorts( + channel, continuation: continuation + ) + + selected_tab = Frontend::ChannelPage::TabsAvailable::Shorts + templated "channel" + end + + def self.streams(env) + data = self.fetch_basic_information(env) + return data if !data.is_a?(Tuple) + + locale, user, subscriptions, continuation, ucid, channel = data + + if !channel.tabs.includes? "streams" + return env.redirect "/channel/#{channel.ucid}" + end + + # TODO: support sort option for livestreams + sort_by = "" + sort_options = [] of String + + # Fetch items and continuation token + items, next_continuation = Channel::Tabs.get_60_livestreams( + channel, continuation: continuation + ) + + selected_tab = Frontend::ChannelPage::TabsAvailable::Streams templated "channel" end @@ -124,7 +172,7 @@ module Invidious::Routes::Channels end selected_tab = env.request.path.split("/")[-1] - if ["home", "videos", "playlists", "community", "channels", "about"].includes? selected_tab + if {"home", "videos", "shorts", "streams", "playlists", "community", "channels", "about"}.includes? selected_tab url = "/channel/#{ucid}/#{selected_tab}" else url = "/channel/#{ucid}" diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index f409f13c..08739c3d 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -115,6 +115,8 @@ module Invidious::Routing get "/channel/:ucid", Routes::Channels, :home get "/channel/:ucid/home", Routes::Channels, :home get "/channel/:ucid/videos", Routes::Channels, :videos + get "/channel/:ucid/shorts", Routes::Channels, :shorts + get "/channel/:ucid/streams", Routes::Channels, :streams get "/channel/:ucid/playlists", Routes::Channels, :playlists get "/channel/:ucid/community", Routes::Channels, :community get "/channel/:ucid/about", Routes::Channels, :about @@ -122,7 +124,7 @@ module Invidious::Routing get "/user/:user/live", Routes::Channels, :live get "/c/:user/live", Routes::Channels, :live - ["", "/videos", "/playlists", "/community", "/about"].each do |path| + {"", "/videos", "/shorts", "/streams", "/playlists", "/community", "/about"}.each do |path| # /c/LinusTechTips get "/c/:user#{path}", Routes::Channels, :brand_redirect # /user/linustechtips | Not always the same as /c/ diff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecr index 878587d4..f6cc3340 100644 --- a/src/invidious/views/channel.ecr +++ b/src/invidious/views/channel.ecr @@ -64,23 +64,8 @@ <%= translate(locale, "Switch Invidious Instance") %> <% end %> - <% if !channel.auto_generated %> -
- <%= translate(locale, "Videos") %> -
- <% end %> -
- <% if channel.auto_generated %> - <%= translate(locale, "Playlists") %> - <% else %> - <%= translate(locale, "Playlists") %> - <% end %> -
-
- <% if channel.tabs.includes? "community" %> - <%= translate(locale, "Community") %> - <% end %> -
+ + <%= Invidious::Frontend::ChannelPage.generate_tabs_links(locale, channel, selected_tab) %>
@@ -111,7 +96,12 @@
diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr index 3bc29e55..e467a679 100644 --- a/src/invidious/views/community.ecr +++ b/src/invidious/views/community.ecr @@ -50,19 +50,8 @@ <%= translate(locale, "Switch Invidious Instance") %> <% end %> - <% if !channel.auto_generated %> - - <% end %> - -
- <% if channel.tabs.includes? "community" %> - <%= translate(locale, "Community") %> - <% end %> -
+ + <%= Invidious::Frontend::ChannelPage.generate_tabs_links(locale, channel, Invidious::Frontend::ChannelPage::TabsAvailable::Community) %>
diff --git a/src/invidious/views/playlists.ecr b/src/invidious/views/playlists.ecr index c8718e7b..56d25ef5 100644 --- a/src/invidious/views/playlists.ecr +++ b/src/invidious/views/playlists.ecr @@ -54,19 +54,7 @@ <% end %> - -
- <% if !channel.auto_generated %> - <%= translate(locale, "Playlists") %> - <% end %> -
-
- <% if channel.tabs.includes? "community" %> - <%= translate(locale, "Community") %> - <% end %> -
+ <%= Invidious::Frontend::ChannelPage.generate_tabs_links(locale, channel, Invidious::Frontend::ChannelPage::TabsAvailable::Playlists) %>
From 40c666cab22693cf9d31895978ae4b4356e6579b Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sun, 4 Dec 2022 19:24:51 +0100 Subject: [PATCH 37/73] api: Add support for shorts and livestreams --- src/invidious/routes/api/v1/channels.cr | 118 ++++++++++++++++++------ src/invidious/routing.cr | 3 + 2 files changed, 92 insertions(+), 29 deletions(-) diff --git a/src/invidious/routes/api/v1/channels.cr b/src/invidious/routes/api/v1/channels.cr index 72d9ae5f..4e92b54e 100644 --- a/src/invidious/routes/api/v1/channels.cr +++ b/src/invidious/routes/api/v1/channels.cr @@ -1,11 +1,7 @@ module Invidious::Routes::API::V1::Channels - def self.home(env) - locale = env.get("preferences").as(Preferences).locale - - env.response.content_type = "application/json" - - ucid = env.params.url["ucid"] - + # Macro to avoid duplicating some code below + # This sets the `channel` variable, or handles Exceptions. + private macro get_channel begin channel = get_about_info(ucid, locale) rescue ex : ChannelRedirect @@ -16,6 +12,17 @@ module Invidious::Routes::API::V1::Channels rescue ex return error_json(500, ex) end + end + + def self.home(env) + locale = env.get("preferences").as(Preferences).locale + ucid = env.params.url["ucid"] + + env.response.content_type = "application/json" + + # Use the private macro defined above. + channel = nil # Make the compiler happy + get_channel() # Retrieve "sort by" setting from URL parameters sort_by = env.params.query["sort_by"]?.try &.downcase || "newest" @@ -138,21 +145,13 @@ module Invidious::Routes::API::V1::Channels def self.videos(env) locale = env.get("preferences").as(Preferences).locale + ucid = env.params.url["ucid"] env.response.content_type = "application/json" - ucid = env.params.url["ucid"] - - begin - channel = get_about_info(ucid, locale) - rescue ex : ChannelRedirect - env.response.headers["Location"] = env.request.resource.gsub(ucid, ex.channel_id) - return error_json(302, "Channel is unavailable", {"authorId" => ex.channel_id}) - rescue ex : NotFoundException - return error_json(404, ex) - rescue ex - return error_json(500, ex) - end + # Use the private macro defined above. + channel = nil # Make the compiler happy + get_channel() # Retrieve some URL parameters sort_by = env.params.query["sort_by"]?.try &.downcase || "newest" @@ -179,6 +178,74 @@ module Invidious::Routes::API::V1::Channels end end + def self.shorts(env) + locale = env.get("preferences").as(Preferences).locale + ucid = env.params.url["ucid"] + + env.response.content_type = "application/json" + + # Use the private macro defined above. + channel = nil # Make the compiler happy + get_channel() + + # Retrieve continuation from URL parameters + continuation = env.params.query["continuation"]? + + begin + videos, next_continuation = Channel::Tabs.get_shorts( + channel, continuation: continuation + ) + rescue ex + return error_json(500, ex) + end + + return JSON.build do |json| + json.object do + json.field "videos" do + json.array do + videos.each &.to_json(locale, json) + end + end + + json.field "continuation", next_continuation if next_continuation + end + end + end + + def self.streams(env) + locale = env.get("preferences").as(Preferences).locale + ucid = env.params.url["ucid"] + + env.response.content_type = "application/json" + + # Use the private macro defined above. + channel = nil # Make the compiler happy + get_channel() + + # Retrieve continuation from URL parameters + continuation = env.params.query["continuation"]? + + begin + videos, next_continuation = Channel::Tabs.get_60_livestreams( + channel, continuation: continuation + ) + rescue ex + return error_json(500, ex) + end + + return JSON.build do |json| + json.object do + json.field "videos" do + json.array do + videos.each &.to_json(locale, json) + end + end + + json.field "continuation", next_continuation if next_continuation + end + end + end + def self.playlists(env) locale = env.get("preferences").as(Preferences).locale @@ -190,16 +257,9 @@ module Invidious::Routes::API::V1::Channels env.params.query["sort_by"]?.try &.downcase || "last" - begin - channel = get_about_info(ucid, locale) - rescue ex : ChannelRedirect - env.response.headers["Location"] = env.request.resource.gsub(ucid, ex.channel_id) - return error_json(302, "Channel is unavailable", {"authorId" => ex.channel_id}) - rescue ex : NotFoundException - return error_json(404, ex) - rescue ex - return error_json(500, ex) - end + # Use the macro defined above + channel = nil # Make the compiler happy + get_channel() items, continuation = fetch_channel_playlists(channel.ucid, channel.author, continuation, sort_by) diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index 08739c3d..0e6fba21 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -222,6 +222,9 @@ module Invidious::Routing # Channels get "/api/v1/channels/:ucid", {{namespace}}::Channels, :home + get "/api/v1/channels/:ucid/shorts", {{namespace}}::Channels, :shorts + get "/api/v1/channels/:ucid/streams", {{namespace}}::Channels, :streams + {% for route in {"videos", "latest", "playlists", "community", "search"} %} get "/api/v1/channels/#{{{route}}}/:ucid", {{namespace}}::Channels, :{{route}} get "/api/v1/channels/:ucid/#{{{route}}}", {{namespace}}::Channels, :{{route}} From b6a4de66a5414f8ae790033fc3fc9e9fda70a860 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sun, 4 Dec 2022 23:19:25 +0100 Subject: [PATCH 38/73] frontend: Unify the various channel pages --- src/invidious/routes/channels.cr | 33 ++++--- src/invidious/views/channel.ecr | 95 +++++------------- src/invidious/views/community.ecr | 65 +++---------- .../views/components/channel_info.ecr | 60 ++++++++++++ src/invidious/views/playlists.ecr | 96 ------------------- 5 files changed, 116 insertions(+), 233 deletions(-) create mode 100644 src/invidious/views/components/channel_info.ecr delete mode 100644 src/invidious/views/playlists.ecr diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index 78b38341..77d309fb 100644 --- a/src/invidious/routes/channels.cr +++ b/src/invidious/routes/channels.cr @@ -7,18 +7,19 @@ module Invidious::Routes::Channels def self.videos(env) data = self.fetch_basic_information(env) - if !data.is_a?(Tuple) - return data - end + return data if !data.is_a?(Tuple) + locale, user, subscriptions, continuation, ucid, channel = data sort_by = env.params.query["sort_by"]?.try &.downcase if channel.auto_generated sort_options = {"last", "oldest", "newest"} - sort_by ||= "last" - items, next_continuation = fetch_channel_playlists(channel.ucid, channel.author, continuation, sort_by) + items, next_continuation = fetch_channel_playlists( + channel.ucid, channel.author, continuation, (sort_by || "last") + ) + items.uniq! do |item| if item.responds_to?(:title) item.title @@ -30,11 +31,10 @@ module Invidious::Routes::Channels items.each(&.author = "") else sort_options = {"newest", "oldest", "popular"} - sort_by ||= "newest" # Fetch items and continuation token items, next_continuation = Channel::Tabs.get_videos( - channel, continuation: continuation, sort_by: sort_by + channel, continuation: continuation, sort_by: (sort_by || "newest") ) end @@ -90,24 +90,26 @@ module Invidious::Routes::Channels def self.playlists(env) data = self.fetch_basic_information(env) - if !data.is_a?(Tuple) - return data - end + return data if !data.is_a?(Tuple) + locale, user, subscriptions, continuation, ucid, channel = data sort_options = {"last", "oldest", "newest"} sort_by = env.params.query["sort_by"]?.try &.downcase - sort_by ||= "last" if channel.auto_generated return env.redirect "/channel/#{channel.ucid}" end - items, continuation = fetch_channel_playlists(channel.ucid, channel.author, continuation, sort_by) + items, next_continuation = fetch_channel_playlists( + channel.ucid, channel.author, continuation, (sort_by || "last") + ) + items = items.select(SearchPlaylist).map(&.as(SearchPlaylist)) items.each(&.author = "") - templated "playlists" + selected_tab = Frontend::ChannelPage::TabsAvailable::Playlists + templated "channel" end def self.community(env) @@ -121,12 +123,15 @@ module Invidious::Routes::Channels thin_mode = thin_mode == "true" continuation = env.params.query["continuation"]? - # sort_by = env.params.query["sort_by"]?.try &.downcase if !channel.tabs.includes? "community" return env.redirect "/channel/#{channel.ucid}" end + # TODO: support sort options for community posts + sort_by = "" + sort_options = [] of String + begin items = JSON.parse(fetch_channel_community(ucid, continuation, locale, "json", thin_mode)) rescue ex : InfoException diff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecr index f6cc3340..039f8752 100644 --- a/src/invidious/views/channel.ecr +++ b/src/invidious/views/channel.ecr @@ -1,8 +1,23 @@ -<% ucid = channel.ucid %> -<% author = HTML.escape(channel.author) %> -<% channel_profile_pic = URI.parse(channel.author_thumbnail).request_target %> +<%- + ucid = channel.ucid + author = HTML.escape(channel.author) + channel_profile_pic = URI.parse(channel.author_thumbnail).request_target + + relative_url = + case selected_tab + when .shorts? then "/channel/#{ucid}/shorts" + when .streams? then "/channel/#{ucid}/streams" + when .playlists? then "/channel/#{ucid}/playlists" + else + "/channel/#{ucid}" + end + + youtube_url = "https://www.youtube.com#{relative_url}" + redirect_url = Invidious::Frontend::Misc.redirect_url(env) +-%> <% content_for "header" do %> +<%- if selected_tab.videos? -%> @@ -14,76 +29,14 @@ - -<%= author %> - Invidious +<%- end -%> + + +<%= author %> - Invidious <% end %> -<% if channel.banner %> -
- "> -
- -
-
-
-<% end %> - -
-
-
- - <%= author %><% if !channel.verified.nil? && channel.verified %> <% end %> -
-
-
-

- -

-
-
- -
-
-

<%= channel.description_html %>

-
-
- -
- <% sub_count_text = number_to_short_text(channel.sub_count) %> - <%= rendered "components/subscribe_widget" %> -
- -
-
- <%= translate(locale, "View channel on YouTube") %> -
- <% if env.get("preferences").as(Preferences).automatic_instance_redirect%> - "><%= translate(locale, "Switch Invidious Instance") %> - <% else %> - <%= translate(locale, "Switch Invidious Instance") %> - <% end %> -
- - <%= Invidious::Frontend::ChannelPage.generate_tabs_links(locale, channel, selected_tab) %> -
-
-
-
- <% sort_options.each do |sort| %> -
- <% if sort_by == sort %> - <%= translate(locale, sort) %> - <% else %> - - <%= translate(locale, sort) %> - - <% end %> -
- <% end %> -
-
-
+<%= rendered "components/channel_info" %>

@@ -99,7 +52,7 @@
<% if next_continuation %> - &sort_by=<%= URI.encode_www_form(sort_by) %><% end %>"> + <%= translate(locale, "Next page") %> <% end %> diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr index e467a679..9e11d562 100644 --- a/src/invidious/views/community.ecr +++ b/src/invidious/views/community.ecr @@ -1,60 +1,21 @@ -<% ucid = channel.ucid %> -<% author = HTML.escape(channel.author) %> +<%- + ucid = channel.ucid + author = HTML.escape(channel.author) + channel_profile_pic = URI.parse(channel.author_thumbnail).request_target + + relative_url = "/channel/#{ucid}/community" + youtube_url = "https://www.youtube.com#{relative_url}" + redirect_url = Invidious::Frontend::Misc.redirect_url(env) + + selected_tab = Invidious::Frontend::ChannelPage::TabsAvailable::Community +-%> <% content_for "header" do %> + <%= author %> - Invidious <% end %> -<% if channel.banner %> -
- "> -
- -
-
-
-<% end %> - -
-
-
- - <%= author %><% if !channel.verified.nil? && channel.verified %> <% end %> -
-
-
-

- -

-
-
- -
-
-

<%= XML.parse_html(channel.description_html).xpath_node(%q(.//pre)).try &.content %>

-
-
- -
- <% sub_count_text = number_to_short_text(channel.sub_count) %> - <%= rendered "components/subscribe_widget" %> -
- -
-
- <%= translate(locale, "View channel on YouTube") %> -
- <% if env.get("preferences").as(Preferences).automatic_instance_redirect%> - "><%= translate(locale, "Switch Invidious Instance") %> - <% else %> - <%= translate(locale, "Switch Invidious Instance") %> - <% end %> -
- - <%= Invidious::Frontend::ChannelPage.generate_tabs_links(locale, channel, Invidious::Frontend::ChannelPage::TabsAvailable::Community) %> -
-
-
+<%= rendered "components/channel_info" %>

diff --git a/src/invidious/views/components/channel_info.ecr b/src/invidious/views/components/channel_info.ecr new file mode 100644 index 00000000..f216359f --- /dev/null +++ b/src/invidious/views/components/channel_info.ecr @@ -0,0 +1,60 @@ +<% if channel.banner %> +
+ "> +
+ +
+
+
+<% end %> + +
+
+
+ + <%= author %><% if !channel.verified.nil? && channel.verified %> <% end %> +
+
+
+

+ +

+
+
+ +
+
+

<%= channel.description_html %>

+
+
+ +
+ <% sub_count_text = number_to_short_text(channel.sub_count) %> + <%= rendered "components/subscribe_widget" %> +
+ +
+
+ + + + <%= Invidious::Frontend::ChannelPage.generate_tabs_links(locale, channel, selected_tab) %> +
+
+
+ <% sort_options.each do |sort| %> +
+ <% if sort_by == sort %> + <%= translate(locale, sort) %> + <% else %> + <%= translate(locale, sort) %> + <% end %> +
+ <% end %> +
+
+
diff --git a/src/invidious/views/playlists.ecr b/src/invidious/views/playlists.ecr deleted file mode 100644 index 56d25ef5..00000000 --- a/src/invidious/views/playlists.ecr +++ /dev/null @@ -1,96 +0,0 @@ -<% ucid = channel.ucid %> -<% author = HTML.escape(channel.author) %> - -<% content_for "header" do %> -<%= author %> - Invidious -<% end %> - -<% if channel.banner %> -
- "> -
- -
-
-
-<% end %> - -
-
-
- - <%= author %><% if !channel.verified.nil? && channel.verified %> <% end %> -
-
-
-

- -

-
-
- -
-
-

<%= XML.parse_html(channel.description_html).xpath_node(%q(.//pre)).try &.content if !channel.description_html.empty? %>

-
-
- -
- <% sub_count_text = number_to_short_text(channel.sub_count) %> - <%= rendered "components/subscribe_widget" %> -
- -
-
- - -
- <% if env.get("preferences").as(Preferences).automatic_instance_redirect%> - "><%= translate(locale, "Switch Invidious Instance") %> - <% else %> - <%= translate(locale, "Switch Invidious Instance") %> - <% end %> -
- - <%= Invidious::Frontend::ChannelPage.generate_tabs_links(locale, channel, Invidious::Frontend::ChannelPage::TabsAvailable::Playlists) %> -
-
-
-
- <% {"last", "oldest", "newest"}.each do |sort| %> -
- <% if sort_by == sort %> - <%= translate(locale, sort) %> - <% else %> - - <%= translate(locale, sort) %> - - <% end %> -
- <% end %> -
-
-
- -
-
-
- -
-<% items.each do |item| %> - <%= rendered "components/item" %> -<% end %> -
- - From 4e3a9306260b737e2d13c6a763899b946a6ecfbb Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Mon, 5 Dec 2022 00:50:04 +0100 Subject: [PATCH 39/73] frontend: Add support for the "featured channels" page --- locales/en-US.json | 3 +- src/invidious/channels/about.cr | 50 +++++-------------------- src/invidious/frontend/channel_page.cr | 1 + src/invidious/routes/api/v1/channels.cr | 24 ++---------- src/invidious/routes/channels.cr | 20 ++++++++++ src/invidious/routing.cr | 1 + src/invidious/views/channel.ecr | 1 + 7 files changed, 37 insertions(+), 63 deletions(-) diff --git a/locales/en-US.json b/locales/en-US.json index 44b40c24..12955665 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -475,5 +475,6 @@ "channel_tab_shorts_label": "Shorts", "channel_tab_streams_label": "Livestreams", "channel_tab_playlists_label": "Playlists", - "channel_tab_community_label": "Community" + "channel_tab_community_label": "Community", + "channel_tab_channels_label": "Channels" } diff --git a/src/invidious/channels/about.cr b/src/invidious/channels/about.cr index 09c3427a..0054f8f2 100644 --- a/src/invidious/channels/about.cr +++ b/src/invidious/channels/about.cr @@ -16,12 +16,6 @@ record AboutChannel, tabs : Array(String), verified : Bool -record AboutRelatedChannel, - ucid : String, - author : String, - author_url : String, - author_thumbnail : String - def get_about_info(ucid, locale) : AboutChannel begin # "EgVhYm91dA==" is the base64-encoded protobuf object {"2:string":"about"} @@ -165,41 +159,15 @@ def get_about_info(ucid, locale) : AboutChannel ) end -def fetch_related_channels(about_channel : AboutChannel) : Array(AboutRelatedChannel) - # params is {"2:string":"channels"} encoded - channels = YoutubeAPI.browse(browse_id: about_channel.ucid, params: "EghjaGFubmVscw%3D%3D") - - tabs = channels.dig?("contents", "twoColumnBrowseResultsRenderer", "tabs").try(&.as_a?) || [] of JSON::Any - tab = tabs.find(&.dig?("tabRenderer", "title").try(&.as_s?).try(&.== "Channels")) - - return [] of AboutRelatedChannel if tab.nil? - - items = tab.dig?( - "tabRenderer", "content", - "sectionListRenderer", "contents", 0, - "itemSectionRenderer", "contents", 0, - "gridRenderer", "items" - ).try &.as_a? - - related = [] of AboutRelatedChannel - return related if (items.nil? || items.empty?) - - items.each do |item| - renderer = item["gridChannelRenderer"]? - next if !renderer - - related_id = renderer.dig("channelId").as_s - related_title = renderer.dig("title", "simpleText").as_s - related_author_url = renderer.dig("navigationEndpoint", "browseEndpoint", "canonicalBaseUrl").as_s - related_author_thumbnail = HelperExtractors.get_thumbnails(renderer) - - related << AboutRelatedChannel.new( - ucid: related_id, - author: related_title, - author_url: related_author_url, - author_thumbnail: related_author_thumbnail, - ) +def fetch_related_channels(about_channel : AboutChannel, continuation : String? = nil) : {Array(SearchChannel), String?} + if continuation.nil? + # params is {"2:string":"channels"} encoded + initial_data = YoutubeAPI.browse(browse_id: about_channel.ucid, params: "EghjaGFubmVscw%3D%3D") + else + initial_data = YoutubeAPI.browse(continuation) end - return related + items, continuation = extract_items(initial_data) + + return items.select(SearchChannel), continuation end diff --git a/src/invidious/frontend/channel_page.cr b/src/invidious/frontend/channel_page.cr index 7ac0e071..53745dd5 100644 --- a/src/invidious/frontend/channel_page.cr +++ b/src/invidious/frontend/channel_page.cr @@ -7,6 +7,7 @@ module Invidious::Frontend::ChannelPage Streams Playlists Community + Channels end def generate_tabs_links(locale : String, channel : AboutChannel, selected_tab : TabsAvailable) diff --git a/src/invidious/routes/api/v1/channels.cr b/src/invidious/routes/api/v1/channels.cr index 4e92b54e..28ccdab9 100644 --- a/src/invidious/routes/api/v1/channels.cr +++ b/src/invidious/routes/api/v1/channels.cr @@ -102,31 +102,13 @@ module Invidious::Routes::API::V1::Channels json.array do # Fetch related channels begin - related_channels = fetch_related_channels(channel) + related_channels, _ = fetch_related_channels(channel) rescue ex - related_channels = [] of AboutRelatedChannel + related_channels = [] of SearchChannel end related_channels.each do |related_channel| - json.object do - json.field "author", related_channel.author - json.field "authorId", related_channel.ucid - json.field "authorUrl", related_channel.author_url - - json.field "authorThumbnails" do - json.array do - qualities = {32, 48, 76, 100, 176, 512} - - qualities.each do |quality| - json.object do - json.field "url", related_channel.author_thumbnail.gsub(/=\d+/, "=s#{quality}") - json.field "width", quality - json.field "height", quality - end - end - end - end - end + related_channel.to_json(locale, json) end end end # relatedChannels diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index 77d309fb..d3969d29 100644 --- a/src/invidious/routes/channels.cr +++ b/src/invidious/routes/channels.cr @@ -147,6 +147,26 @@ module Invidious::Routes::Channels templated "community" end + def self.channels(env) + data = self.fetch_basic_information(env) + return data if !data.is_a?(Tuple) + + locale, user, subscriptions, continuation, ucid, channel = data + + if channel.auto_generated + return env.redirect "/channel/#{channel.ucid}" + end + + items, next_continuation = fetch_related_channels(channel, continuation) + + # Featured/related channels can't be sorted + sort_options = [] of String + sort_by = nil + + selected_tab = Frontend::ChannelPage::TabsAvailable::Channels + templated "channel" + end + def self.about(env) data = self.fetch_basic_information(env) if !data.is_a?(Tuple) diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index 0e6fba21..84dbed5b 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -119,6 +119,7 @@ module Invidious::Routing get "/channel/:ucid/streams", Routes::Channels, :streams get "/channel/:ucid/playlists", Routes::Channels, :playlists get "/channel/:ucid/community", Routes::Channels, :community + get "/channel/:ucid/channels", Routes::Channels, :channels get "/channel/:ucid/about", Routes::Channels, :about get "/channel/:ucid/live", Routes::Channels, :live get "/user/:user/live", Routes::Channels, :live diff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecr index 039f8752..a29315ef 100644 --- a/src/invidious/views/channel.ecr +++ b/src/invidious/views/channel.ecr @@ -8,6 +8,7 @@ when .shorts? then "/channel/#{ucid}/shorts" when .streams? then "/channel/#{ucid}/streams" when .playlists? then "/channel/#{ucid}/playlists" + when .channels? then "/channel/#{ucid}/channels" else "/channel/#{ucid}" end From 69b8e0919fd0a410d35f5f5fccc4753f79faf940 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Thu, 22 Dec 2022 17:26:30 +0100 Subject: [PATCH 40/73] api: Add support for the "featured channels" endpoint --- src/invidious/routes/api/v1/channels.cr | 31 +++++++++++++++++++++++++ src/invidious/routing.cr | 1 + 2 files changed, 32 insertions(+) diff --git a/src/invidious/routes/api/v1/channels.cr b/src/invidious/routes/api/v1/channels.cr index 28ccdab9..ca2b2734 100644 --- a/src/invidious/routes/api/v1/channels.cr +++ b/src/invidious/routes/api/v1/channels.cr @@ -283,6 +283,37 @@ module Invidious::Routes::API::V1::Channels end end + def self.channels(env) + locale = env.get("preferences").as(Preferences).locale + ucid = env.params.url["ucid"] + + env.response.content_type = "application/json" + + # Use the macro defined above + channel = nil # Make the compiler happy + get_channel() + + continuation = env.params.query["continuation"]? + + begin + items, next_continuation = fetch_related_channels(channel, continuation) + rescue ex + return error_json(500, ex) + end + + JSON.build do |json| + json.object do + json.field "relatedChannels" do + json.array do + items.each &.to_json(locale, json) + end + end + + json.field "continuation", next_continuation if next_continuation + end + end + end + def self.search(env) locale = env.get("preferences").as(Preferences).locale region = env.params.query["region"]? diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index 84dbed5b..54bd82a4 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -225,6 +225,7 @@ module Invidious::Routing get "/api/v1/channels/:ucid", {{namespace}}::Channels, :home get "/api/v1/channels/:ucid/shorts", {{namespace}}::Channels, :shorts get "/api/v1/channels/:ucid/streams", {{namespace}}::Channels, :streams + get "/api/v1/channels/:ucid/channels", {{namespace}}::Channels, :channels {% for route in {"videos", "latest", "playlists", "community", "search"} %} get "/api/v1/channels/#{{{route}}}/:ucid", {{namespace}}::Channels, :{{route}} From f9eb839c7ae2c29e641495c4a2affd384445bf97 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Thu, 22 Dec 2022 13:05:13 +0100 Subject: [PATCH 41/73] channel: remove dead playlists code --- spec/invidious/helpers_spec.cr | 6 ---- src/invidious/channels/playlists.cr | 55 ----------------------------- 2 files changed, 61 deletions(-) diff --git a/spec/invidious/helpers_spec.cr b/spec/invidious/helpers_spec.cr index ab361770..f81cd29a 100644 --- a/spec/invidious/helpers_spec.cr +++ b/spec/invidious/helpers_spec.cr @@ -23,12 +23,6 @@ Spectator.describe "Helper" do end end - describe "#produce_channel_playlists_url" do - it "correctly produces a /browse_ajax URL with the given UCID and cursor" do - expect(produce_channel_playlists_url("UCCj956IF62FbT7Gouszaj9w", "AIOkY9EQpi_gyn1_QrFuZ1reN81_MMmI1YmlBblw8j7JHItEFG5h7qcJTNd4W9x5Quk_CVZ028gW")).to eq("/browse_ajax?continuation=4qmFsgLNARIYVUNDajk1NklGNjJGYlQ3R291c3phajl3GrABRWdsd2JHRjViR2x6ZEhNd0FqZ0JZQUZxQUxnQkFIcG1VVlZzVUdFeGF6VlNWa1ozWVZZNWJtVlhOSGhZTVVaNVVtNVdZVTFZU214VWFtZDRXREF4VG1KVmEzaFhWekZ6VVcxS2MyUjZhSEZPTUhCSlUxaFNSbEpyWXpGaFJHUjRXVEJ3VlZSdFVUQldlbXcwVGxaR01XRXhPVVJXYkc5M1RXcG9ibFozSUFFWUF3PT0%3D&gl=US&hl=en") - end - end - describe "#produce_comment_continuation" do it "correctly produces a continuation token for comments" do expect(produce_comment_continuation("_cE8xSu6swE", "ADSJ_i2qvJeFtL0htmS5_K5Ctj3eGFVBMWL9Wd42o3kmUL6_mAzdLp85-liQZL0mYr_16BhaggUqX652Sv9JqV6VXinShSP-ZT6rL4NolPBaPXVtJsO5_rA_qE3GubAuLFw9uzIIXU2-HnpXbdgPLWTFavfX206hqWmmpHwUOrmxQV_OX6tYkM3ux3rPAKCDrT8eWL7MU3bLiNcnbgkW8o0h8KYLL_8BPa8LcHbTv8pAoNkjerlX1x7K4pqxaXPoyz89qNlnh6rRx6AXgAzzoHH1dmcyQ8CIBeOHg-m4i8ZxdX4dP88XWrIFg-jJGhpGP8JUMDgZgavxVx225hUEYZMyrLGler5em4FgbG62YWC51moLDLeYEA")).to eq("EkMSC19jRTh4U3U2c3dFyAEA4AEBogINKP___________wFAAMICHQgEGhdodHRwczovL3d3dy55b3V0dWJlLmNvbSIAGAYyjAMK9gJBRFNKX2kycXZKZUZ0TDBodG1TNV9LNUN0ajNlR0ZWQk1XTDlXZDQybzNrbVVMNl9tQXpkTHA4NS1saVFaTDBtWXJfMTZCaGFnZ1VxWDY1MlN2OUpxVjZWWGluU2hTUC1aVDZyTDROb2xQQmFQWFZ0SnNPNV9yQV9xRTNHdWJBdUxGdzl1eklJWFUyLUhucFhiZGdQTFdURmF2ZlgyMDZocVdtbXBId1VPcm14UVZfT1g2dFlrTTN1eDNyUEFLQ0RyVDhlV0w3TVUzYkxpTmNuYmdrVzhvMGg4S1lMTF84QlBhOExjSGJUdjhwQW9Oa2plcmxYMXg3SzRwcXhhWFBveXo4OXFObG5oNnJSeDZBWGdBenpvSEgxZG1jeVE4Q0lCZU9IZy1tNGk4WnhkWDRkUDg4WFdySUZnLWpKR2hwR1A4SlVNRGdaZ2F2eFZ4MjI1aFVFWVpNeXJMR2xlcjVlbTRGZ2JHNjJZV0M1MW1vTERMZVlFQSIPIgtfY0U4eFN1NnN3RTAAKBQ%3D") diff --git a/src/invidious/channels/playlists.cr b/src/invidious/channels/playlists.cr index 772eecb9..8dc824b2 100644 --- a/src/invidious/channels/playlists.cr +++ b/src/invidious/channels/playlists.cr @@ -26,58 +26,3 @@ def fetch_channel_playlists(ucid, author, continuation, sort_by) return extract_items(initial_data, author, ucid) end - -# ## NOTE: DEPRECATED -# Reason -> Unstable -# The Protobuf object must be provided with an id of the last playlist from the current "page" -# in order to fetch the next one accurately -# (if the id isn't included, entries shift around erratically between pages, -# leading to repetitions and skip overs) -# -# Since it's impossible to produce the appropriate Protobuf without an id being provided by the user, -# it's better to stick to continuation tokens provided by the first request and onward -def produce_channel_playlists_url(ucid, cursor, sort = "newest", auto_generated = false) - object = { - "80226972:embedded" => { - "2:string" => ucid, - "3:base64" => { - "2:string" => "playlists", - "6:varint" => 2_i64, - "7:varint" => 1_i64, - "12:varint" => 1_i64, - "13:string" => "", - "23:varint" => 0_i64, - }, - }, - } - - if cursor - cursor = Base64.urlsafe_encode(cursor, false) if !auto_generated - object["80226972:embedded"]["3:base64"].as(Hash)["15:string"] = cursor - end - - if auto_generated - object["80226972:embedded"]["3:base64"].as(Hash)["4:varint"] = 0x32_i64 - else - object["80226972:embedded"]["3:base64"].as(Hash)["4:varint"] = 1_i64 - case sort - when "oldest", "oldest_created" - object["80226972:embedded"]["3:base64"].as(Hash)["3:varint"] = 2_i64 - when "newest", "newest_created" - object["80226972:embedded"]["3:base64"].as(Hash)["3:varint"] = 3_i64 - when "last", "last_added" - object["80226972:embedded"]["3:base64"].as(Hash)["3:varint"] = 4_i64 - else nil # Ignore - end - end - - object["80226972:embedded"]["3:string"] = Base64.urlsafe_encode(Protodec::Any.from_json(Protodec::Any.cast_json(object["80226972:embedded"]["3:base64"]))) - object["80226972:embedded"].delete("3:base64") - - continuation = object.try { |i| Protodec::Any.cast_json(i) } - .try { |i| Protodec::Any.from_json(i) } - .try { |i| Base64.urlsafe_encode(i) } - .try { |i| URI.encode_www_form(i) } - - return "/browse_ajax?continuation=#{continuation}&gl=US&hl=en" -end From 4659e27b568293d06aa2b33f00867b132c7b4a92 Mon Sep 17 00:00:00 2001 From: brackets0 Date: Thu, 29 Dec 2022 12:50:38 +0000 Subject: [PATCH 42/73] fix: on hover btn #descexpansionbutton cursor to pointer --- assets/css/default.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/css/default.css b/assets/css/default.css index ab2b79e6..a61beaaf 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -504,6 +504,10 @@ hr { height: 100%; } +#descexpansionbutton:hover { + cursor: pointer; +} + #descexpansionbutton ~ label { order: 1; margin-top: 20px; From 865704dc7b0dee818b0f7636a085fcf1736635a7 Mon Sep 17 00:00:00 2001 From: confused_alex Date: Sun, 1 Jan 2023 19:41:58 +0100 Subject: [PATCH 43/73] Fixed dead link (#3526) --- src/invidious/views/user/data_control.ecr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/views/user/data_control.ecr b/src/invidious/views/user/data_control.ecr index 74ccc06c..a451159f 100644 --- a/src/invidious/views/user/data_control.ecr +++ b/src/invidious/views/user/data_control.ecr @@ -14,7 +14,7 @@
From 98301a223750b61915d61ac5221e8b71ea2b40ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Devos?= Date: Thu, 5 Jan 2023 23:08:05 +0000 Subject: [PATCH 44/73] Add ability to disable all user notifications (#3473) --- config/config.example.yml | 11 ++++++ src/invidious/channels/channels.cr | 14 ++++++-- src/invidious/config.cr | 2 ++ src/invidious/database/users.cr | 10 ++++++ src/invidious/routes/embed.cr | 2 +- src/invidious/routes/feeds.cr | 38 +++++++++++++-------- src/invidious/routes/watch.cr | 2 +- src/invidious/routing.cr | 10 ++++-- src/invidious/views/feeds/subscriptions.ecr | 4 +++ src/invidious/views/template.ecr | 4 ++- src/invidious/views/user/preferences.ecr | 2 ++ 11 files changed, 77 insertions(+), 22 deletions(-) diff --git a/config/config.example.yml b/config/config.example.yml index 8794880d..8abe1b9e 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -295,6 +295,17 @@ https_only: false ## #admins: [""] +## +## Enable/Disable the user notifications for all users +## +## Note: On large instances, it is recommended to set this option to 'false' +## in order to reduce the amount of data written to the database, and hence +## improve the overall performance of the instance. +## +## Accepted values: true, false +## Default: true +## +#enable_user_notifications: true # ----------------------------- # Background jobs diff --git a/src/invidious/channels/channels.cr b/src/invidious/channels/channels.cr index e3d3d9ee..9806d1da 100644 --- a/src/invidious/channels/channels.cr +++ b/src/invidious/channels/channels.cr @@ -228,7 +228,11 @@ def fetch_channel(ucid, pull_all_videos : Bool) if was_insert LOGGER.trace("fetch_channel: #{ucid} : video #{video_id} : Inserted, updating subscriptions") - Invidious::Database::Users.add_notification(video) + if CONFIG.enable_user_notifications + Invidious::Database::Users.add_notification(video) + else + Invidious::Database::Users.feed_needs_update(video) + end else LOGGER.trace("fetch_channel: #{ucid} : video #{video_id} : Updated") end @@ -264,7 +268,13 @@ def fetch_channel(ucid, pull_all_videos : Bool) # so since they don't provide a published date here we can safely ignore them. if Time.utc - video.published > 1.minute was_insert = Invidious::Database::ChannelVideos.insert(video) - Invidious::Database::Users.add_notification(video) if was_insert + if was_insert + if CONFIG.enable_user_notifications + Invidious::Database::Users.add_notification(video) + else + Invidious::Database::Users.feed_needs_update(video) + end + end end end diff --git a/src/invidious/config.cr b/src/invidious/config.cr index c9bf43a4..9fc58409 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -110,6 +110,8 @@ class Config property hsts : Bool? = true # Disable proxying server-wide: options: 'dash', 'livestreams', 'downloads', 'local' property disable_proxy : Bool? | Array(String)? = false + # Enable the user notifications for all users + property enable_user_notifications : Bool = true # URL to the modified source code to be easily AGPL compliant # Will display in the footer, next to the main source code link diff --git a/src/invidious/database/users.cr b/src/invidious/database/users.cr index f62b43ea..0a4a4fd8 100644 --- a/src/invidious/database/users.cr +++ b/src/invidious/database/users.cr @@ -154,6 +154,16 @@ module Invidious::Database::Users # Update (misc) # ------------------- + def feed_needs_update(video : ChannelVideo) + request = <<-SQL + UPDATE users + SET feed_needs_update = true + WHERE $1 = ANY(subscriptions) + SQL + + PG_DB.exec(request, video.ucid) + end + def update_preferences(user : User) request = <<-SQL UPDATE users diff --git a/src/invidious/routes/embed.cr b/src/invidious/routes/embed.cr index 289d87c9..266f7ba4 100644 --- a/src/invidious/routes/embed.cr +++ b/src/invidious/routes/embed.cr @@ -147,7 +147,7 @@ module Invidious::Routes::Embed # PG_DB.exec("UPDATE users SET watched = array_append(watched, $1) WHERE email = $2", id, user.as(User).email) # end - if notifications && notifications.includes? id + if CONFIG.enable_user_notifications && notifications && notifications.includes? id Invidious::Database::Users.remove_notification(user.as(User), id) env.get("user").as(User).notifications.delete(id) notifications.delete(id) diff --git a/src/invidious/routes/feeds.cr b/src/invidious/routes/feeds.cr index b601db94..fb482e33 100644 --- a/src/invidious/routes/feeds.cr +++ b/src/invidious/routes/feeds.cr @@ -96,12 +96,14 @@ module Invidious::Routes::Feeds videos, notifications = get_subscription_feed(user, max_results, page) - # "updated" here is used for delivering new notifications, so if - # we know a user has looked at their feed e.g. in the past 10 minutes, - # they've already seen a video posted 20 minutes ago, and don't need - # to be notified. - Invidious::Database::Users.clear_notifications(user) - user.notifications = [] of String + if CONFIG.enable_user_notifications + # "updated" here is used for delivering new notifications, so if + # we know a user has looked at their feed e.g. in the past 10 minutes, + # they've already seen a video posted 20 minutes ago, and don't need + # to be notified. + Invidious::Database::Users.clear_notifications(user) + user.notifications = [] of String + end env.set "user", user templated "feeds/subscriptions" @@ -404,13 +406,15 @@ module Invidious::Routes::Feeds video = get_video(id, force_refresh: true) - # Deliver notifications to `/api/v1/auth/notifications` - payload = { - "topic" => video.ucid, - "videoId" => video.id, - "published" => published.to_unix, - }.to_json - PG_DB.exec("NOTIFY notifications, E'#{payload}'") + if CONFIG.enable_user_notifications + # Deliver notifications to `/api/v1/auth/notifications` + payload = { + "topic" => video.ucid, + "videoId" => video.id, + "published" => published.to_unix, + }.to_json + PG_DB.exec("NOTIFY notifications, E'#{payload}'") + end video = ChannelVideo.new({ id: id, @@ -426,7 +430,13 @@ module Invidious::Routes::Feeds }) was_insert = Invidious::Database::ChannelVideos.insert(video, with_premiere_timestamp: true) - Invidious::Database::Users.add_notification(video) if was_insert + if was_insert + if CONFIG.enable_user_notifications + Invidious::Database::Users.add_notification(video) + else + Invidious::Database::Users.feed_needs_update(video) + end + end end end diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr index 5f481557..5d3845c3 100644 --- a/src/invidious/routes/watch.cr +++ b/src/invidious/routes/watch.cr @@ -80,7 +80,7 @@ module Invidious::Routes::Watch Invidious::Database::Users.mark_watched(user.as(User), id) end - if notifications && notifications.includes? id + if CONFIG.enable_user_notifications && notifications && notifications.includes? id Invidious::Database::Users.remove_notification(user.as(User), id) env.get("user").as(User).notifications.delete(id) notifications.delete(id) diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index f409f13c..1995677c 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -37,7 +37,9 @@ module Invidious::Routing get "/feed/webhook/:token", Routes::Feeds, :push_notifications_get post "/feed/webhook/:token", Routes::Feeds, :push_notifications_post - get "/modify_notifications", Routes::Notifications, :modify + if CONFIG.enable_user_notifications + get "/modify_notifications", Routes::Notifications, :modify + end {% end %} self.register_image_routes @@ -260,8 +262,10 @@ module Invidious::Routing post "/api/v1/auth/tokens/register", {{namespace}}::Authenticated, :register_token post "/api/v1/auth/tokens/unregister", {{namespace}}::Authenticated, :unregister_token - get "/api/v1/auth/notifications", {{namespace}}::Authenticated, :notifications - post "/api/v1/auth/notifications", {{namespace}}::Authenticated, :notifications + if CONFIG.enable_user_notifications + get "/api/v1/auth/notifications", {{namespace}}::Authenticated, :notifications + post "/api/v1/auth/notifications", {{namespace}}::Authenticated, :notifications + end # Misc get "/api/v1/stats", {{namespace}}::Misc, :stats diff --git a/src/invidious/views/feeds/subscriptions.ecr b/src/invidious/views/feeds/subscriptions.ecr index 8d56ad14..76f2f2bd 100644 --- a/src/invidious/views/feeds/subscriptions.ecr +++ b/src/invidious/views/feeds/subscriptions.ecr @@ -23,6 +23,8 @@
+<% if CONFIG.enable_user_notifications %> +
<%= translate_count(locale, "subscriptions_unseen_notifs_count", notifications.size) %>
@@ -39,6 +41,8 @@ <% end %>
+<% end %> +

diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr index 98f72eba..77265679 100644 --- a/src/invidious/views/template.ecr +++ b/src/invidious/views/template.ecr @@ -54,7 +54,7 @@ + <% if CONFIG.enable_user_notifications %> <% end %> + <% end %> <% end %> <% if env.get?("user") && CONFIG.admins.includes? env.get?("user").as(Invidious::User).email %> From e2ce9c2cee7b4e91c54eff94ac0bea29cad6376f Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:10 +0100 Subject: [PATCH 45/73] Add Odia translation Co-authored-by: GET100PERCENT Co-authored-by: Hosted Weblate --- locales/or.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 locales/or.json diff --git a/locales/or.json b/locales/or.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/locales/or.json @@ -0,0 +1 @@ +{} From a36363198c80f83ae4284ebf2e9a76647b9136c8 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:10 +0100 Subject: [PATCH 46/73] Update Arabic translation Co-authored-by: Hosted Weblate Co-authored-by: Mohamed-Touhami MAHDI --- locales/ar.json | 126 ++++++++++++++++++++++++------------------------ 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/locales/ar.json b/locales/ar.json index fbe88b03..2a746e5d 100644 --- a/locales/ar.json +++ b/locales/ar.json @@ -1,11 +1,11 @@ { "LIVE": "مُباشِر", - "Shared `x` ago": "تمَّ رفع المقطع المرئيّ مُنذ `x`", + "Shared `x` ago": "تمَّ الرفع مُنذ `x`", "Unsubscribe": "إلغاء الاشتراك", - "Subscribe": "الإشتراك", - "View channel on YouTube": "زيارة القناة على موقع يوتيوب", - "View playlist on YouTube": "عرض قائمة التشغيل على اليوتيوب", - "newest": "الأجدد", + "Subscribe": "الاشتراك", + "View channel on YouTube": "زيارة القناة على يوتيوب", + "View playlist on YouTube": "عرض قائمة التشغيل على يوتيوب", + "newest": "الأحدث", "oldest": "الأقدم", "popular": "الأكثر شعبية", "last": "الأخيرة", @@ -96,8 +96,8 @@ "`x` is live": "`x` في بث مباشر", "preferences_category_data": "إعدادات التفضيلات", "Clear watch history": "حذف سجل المشاهدة", - "Import/export data": "إضافة\\استخراج البيانات", - "Change password": "غير كلمة السر", + "Import/export data": "إستيراد و تصدير البيانات", + "Change password": "تغير كلمة السر", "Manage subscriptions": "إدارة الاشتراكات", "Manage tokens": "إدارة الرموز", "Watch history": "سجل المشاهدة", @@ -137,7 +137,7 @@ "Title": "العنوان", "Playlist privacy": "إعدادات الخصوصية", "Editing playlist `x`": "تعديل قائمة التشغيل `x`", - "Show more": "إظهار المزيد", + "Show more": "عرض المزيد", "Show less": "عرض اقل", "Watch on YouTube": "مشاهدة الفيديو على اليوتيوب", "Switch Invidious Instance": "تبديل المثيل Invidious", @@ -147,20 +147,20 @@ "License: ": "التراخيص: ", "Family friendly? ": "محتوى عائلي؟ ", "Wilson score: ": "درجة ويلسون: ", - "Engagement: ": "نسبة المشاركة: ", + "Engagement: ": "نسبة التفاعل: ", "Whitelisted regions: ": "الدول المسموح فيها هذا الفيديو: ", "Blacklisted regions: ": "الدول المحظور فيها هذا الفيديو: ", - "Shared `x`": "شارك منذ `x`", + "Shared `x`": "تمت المشاركة في `x`", "Premieres in `x`": "يعرض فى `x`", "Premieres `x`": "يعرض `x`", "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "أهلًا! يبدو أن جافاسكريبت معطلٌ لديك. اضغط هنا لعرض التعليقات، وَضَع في اعتبارك أنها ستأخذ وقتًا أطول للتحميل.", "View YouTube comments": "عرض تعليقات اليوتيوب", - "View more comments on Reddit": "عرض المزيد من التعليقات على\\من موقع Reddit", + "View more comments on Reddit": "عرض المزيد من التعليقات على\\من موقع ريديت", "View `x` comments": { "([^.,0-9]|^)1([^.,0-9]|$)": "عرض `x` تعليقات", "": "عرض `x` تعليقات" }, - "View Reddit comments": "عرض تعليقات ريدإت Reddit", + "View Reddit comments": "عرض تعليقات ريديت", "Hide replies": "إخفاء الردود", "Show replies": "عرض الردود", "Incorrect password": "كلمة السر غير صحيحة", @@ -182,20 +182,20 @@ "channel:`x`": "قناة:`x`", "Deleted or invalid channel": "قناة ممسوحة او غير صالحة", "This channel does not exist.": "هذه القناة غير موجودة.", - "Could not get channel info.": "لم يستطع الحصول على معلومات القناة.", - "Could not fetch comments": "لم يتمكن من إحضار التعليقات", + "Could not get channel info.": "لم يتمكن الحصول على معلومات القناة.", + "Could not fetch comments": "لا يتمكن إحضار التعليقات", "`x` ago": "`x` منذ", - "Load more": "عرض المزيد", + "Load more": "تحميل المزيد", "Could not create mix.": "تعذر إنشاء مزيج.", "Empty playlist": "قائمة التشغيل فارغة", "Not a playlist.": "قائمة التشغيل غير صالحة.", "Playlist does not exist.": "قائمة التشغيل غير موجودة.", - "Could not pull trending pages.": "لم يستطع عرض الصفحات الراجئة.", - "Hidden field \"challenge\" is a required field": "مكان مخفي \"تحدي\" مكان مطلوب", - "Hidden field \"token\" is a required field": "مكان مخفي \"رمز\" مكان مطلوب", - "Erroneous challenge": "تحدي غير صالح", + "Could not pull trending pages.": "لا يتمكن عرض الصفحات الراجئة.", + "Hidden field \"challenge\" is a required field": "الحقل المخفي \"تحدي\" حقل مطلوب", + "Hidden field \"token\" is a required field": "الحقل المخفي \"رمز\" حقل مطلوب", + "Erroneous challenge": "تحدي خاطئ", "Erroneous token": "رمز مميز خاطئ", - "No such user": "مستخدم غير صالح", + "No such user": "مستخدم غير موجود", "Token is expired, please try again": "الرمز منتهى الصلاحية، الرجاء المحاولة مرة اخرى", "English": "إنجليزي", "English (auto-generated)": "إنجليزي (تم إنشائه تلقائيًا)", @@ -328,12 +328,12 @@ "Videos": "الفيديوهات", "Playlists": "قوائم التشغيل", "Community": "المجتمع", - "search_filters_sort_option_relevance": "ملاؤم", + "search_filters_sort_option_relevance": "ملائمة", "search_filters_sort_option_rating": "تقييم", "search_filters_sort_option_date": "التاريخ", "search_filters_sort_option_views": "مشاهدات", "search_filters_type_label": "نوع المحتوى", - "search_filters_duration_label": "المدة الزمنية", + "search_filters_duration_label": "المدة", "search_filters_features_label": "الميزات", "search_filters_sort_label": "فرز", "search_filters_date_option_hour": "آخر ساعة", @@ -351,8 +351,8 @@ "search_filters_features_option_c_commons": "المشاع الإبداعي", "search_filters_features_option_three_d": "ثلاثي الأبعاد", "search_filters_features_option_live": "مباشر", - "search_filters_features_option_four_k": "4k", - "search_filters_features_option_location": "الأماكن", + "search_filters_features_option_four_k": "4K", + "search_filters_features_option_location": "المكان", "search_filters_features_option_hdr": "وضع التباين العالي", "Current version: ": "الإصدار الحالي: ", "next_steps_error_message": "بعد ذلك يجب أن تحاول: ", @@ -360,10 +360,10 @@ "next_steps_error_message_go_to_youtube": "انتقل إلى يوتيوب", "search_filters_duration_option_short": "قصير (< 4 دقائق)", "search_filters_duration_option_long": "طويل (> 20 دقيقة)", - "footer_source_code": "شفرة المصدر", - "footer_original_source_code": "كود المصدر الأصلي", - "footer_modfied_source_code": "شفرة المصدر المعدلة", - "adminprefs_modified_source_code_url_label": "URL إلى مستودع التعليمات البرمجية المصدرية المعدلة", + "footer_source_code": "الكود المصدر", + "footer_original_source_code": "الكود المصدر الأصلي", + "footer_modfied_source_code": "الكود المصدر المعدل", + "adminprefs_modified_source_code_url_label": "URL إلى مستودع الكود المصدر المعدل", "footer_documentation": "التوثيق", "footer_donate_page": "تبرّع", "preferences_region_label": "بلد المحتوى: ", @@ -398,31 +398,31 @@ "invidious": "الخيالي", "preferences_save_player_pos_label": "حفظ موضع التشغيل: ", "crash_page_you_found_a_bug": "يبدو أنك قد وجدت خطأً برمجيًّا في Invidious!", - "generic_videos_count_0": "لا فيديوهات", + "generic_videos_count_0": "لا يوجد فيديوهات", "generic_videos_count_1": "فيديو واحد", "generic_videos_count_2": "فيديوهين", "generic_videos_count_3": "{{count}} فيديوهات", "generic_videos_count_4": "{{count}} فيديو", "generic_videos_count_5": "{{count}} فيديو", - "generic_subscribers_count_0": "لا مشتركين", + "generic_subscribers_count_0": "لا يوجد مشترك", "generic_subscribers_count_1": "مشترك واحد", "generic_subscribers_count_2": "مشتركان", "generic_subscribers_count_3": "{{count}} مشتركين", "generic_subscribers_count_4": "{{count}} مشترك", "generic_subscribers_count_5": "{{count}} مشترك", - "generic_views_count_0": "لا مشاهدات", + "generic_views_count_0": "لا يوجد مشاهدة", "generic_views_count_1": "مشاهدة واحدة", "generic_views_count_2": "مشاهدتان", "generic_views_count_3": "{{count}} مشاهدات", "generic_views_count_4": "{{count}} مشاهدة", "generic_views_count_5": "{{count}} مشاهدة", - "generic_subscriptions_count_0": "لا اشتراكات", + "generic_subscriptions_count_0": "لا يوجد اشتراك", "generic_subscriptions_count_1": "اشتراك واحد", "generic_subscriptions_count_2": "اشتراكان", "generic_subscriptions_count_3": "{{count}} اشتراكات", "generic_subscriptions_count_4": "{{count}} اشتراك", "generic_subscriptions_count_5": "{{count}} اشتراك", - "generic_playlists_count_0": "لا قوائم تشغيل", + "generic_playlists_count_0": "لا يوجد قوائم تشغيل", "generic_playlists_count_1": "قائمة تشغيل واحدة", "generic_playlists_count_2": "قائمتا تشغيل", "generic_playlists_count_3": "{{count}} قوائم تشغيل", @@ -463,10 +463,10 @@ "search_message_change_filters_or_query": "حاول توسيع استعلام البحث و / أو تغيير عوامل التصفية.", "search_filters_date_label": "تاريخ الرفع", "generic_count_weeks_0": "{{count}} أسبوع", - "generic_count_weeks_1": "{{count}} أسبوع", - "generic_count_weeks_2": "{{count}} أسبوع", - "generic_count_weeks_3": "{{count}} أسبوع", - "generic_count_weeks_4": "{{count}} أسابيع", + "generic_count_weeks_1": "أسبوع واحد", + "generic_count_weeks_2": "أسبوعين", + "generic_count_weeks_3": "{{count}} أسابيع", + "generic_count_weeks_4": "{{count}} أسبوع", "generic_count_weeks_5": "{{count}} أسبوع", "Popular enabled: ": "تم تمكين الشعبية: ", "search_filters_duration_option_medium": "متوسط (4-20 دقيقة)", @@ -474,16 +474,16 @@ "search_filters_type_option_all": "أي نوع", "search_filters_features_option_vr180": "VR180", "generic_count_minutes_0": "{{count}} دقيقة", - "generic_count_minutes_1": "{{count}} دقيقة", - "generic_count_minutes_2": "{{count}} دقيقة", - "generic_count_minutes_3": "{{count}} دقيقة", - "generic_count_minutes_4": "{{count}} دقائق", + "generic_count_minutes_1": "دقيقة واحدة", + "generic_count_minutes_2": "دقيقتين", + "generic_count_minutes_3": "{{count}} دقائق", + "generic_count_minutes_4": "{{count}} دقيقة", "generic_count_minutes_5": "{{count}} دقيقة", "generic_count_hours_0": "{{count}} ساعة", - "generic_count_hours_1": "{{count}} ساعة", - "generic_count_hours_2": "{{count}} ساعة", - "generic_count_hours_3": "{{count}} ساعة", - "generic_count_hours_4": "{{count}} ساعات", + "generic_count_hours_1": "ساعة واحدة", + "generic_count_hours_2": "ساعتين", + "generic_count_hours_3": "{{count}} ساعات", + "generic_count_hours_4": "{{count}} ساعة", "generic_count_hours_5": "{{count}} ساعة", "comments_view_x_replies_0": "عرض رد {{count}}", "comments_view_x_replies_1": "عرض رد {{count}}", @@ -493,10 +493,10 @@ "comments_view_x_replies_5": "عرض رد {{count}}", "search_message_use_another_instance": " يمكنك أيضًا البحث عن في مثيل آخر .", "comments_points_count_0": "{{count}} نقطة", - "comments_points_count_1": "{{count}} نقطة", - "comments_points_count_2": "{{count}} نقطة", - "comments_points_count_3": "{{count}} نقطة", - "comments_points_count_4": "{{count}} نقاط", + "comments_points_count_1": "نقطة واحدة", + "comments_points_count_2": "نقطتان", + "comments_points_count_3": "{{count}} نقط", + "comments_points_count_4": "{{count}} نقطة", "comments_points_count_5": "{{count}} نقطة", "generic_count_years_0": "{{count}} السنة", "generic_count_years_1": "{{count}} السنة", @@ -512,17 +512,17 @@ "tokens_count_5": "الرمز المميز {{count}}", "search_filters_apply_button": "تطبيق الفلاتر المحددة", "search_filters_duration_option_none": "أي مدة", - "subscriptions_unseen_notifs_count_0": "{{count}} إشعار غير مرئي", - "subscriptions_unseen_notifs_count_1": "{{count}} إشعار غير مرئي", - "subscriptions_unseen_notifs_count_2": "{{count}} إشعار غير مرئي", - "subscriptions_unseen_notifs_count_3": "{{count}} إشعار غير مرئي", - "subscriptions_unseen_notifs_count_4": "{{count}} إشعارات غير مرئية", - "subscriptions_unseen_notifs_count_5": "{{count}} إشعار غير مرئي", + "subscriptions_unseen_notifs_count_0": "{{count}} إشعار جديد", + "subscriptions_unseen_notifs_count_1": "إشعار واحد جديد", + "subscriptions_unseen_notifs_count_2": "إشعارين جديدين", + "subscriptions_unseen_notifs_count_3": "{{count}} إشعارات جديدة", + "subscriptions_unseen_notifs_count_4": "{{count}} إشعارا جديد", + "subscriptions_unseen_notifs_count_5": "{{count}} إشعار جديد", "generic_count_days_0": "{{count}} يوم", - "generic_count_days_1": "{{count}} يوم", - "generic_count_days_2": "{{count}} يوم", - "generic_count_days_3": "{{count}} يوم", - "generic_count_days_4": "{{count}} أيام", + "generic_count_days_1": "يوم واحد", + "generic_count_days_2": "يومين", + "generic_count_days_3": "{{count}} أيام", + "generic_count_days_4": "{{count}} يوم", "generic_count_days_5": "{{count}} يوم", "generic_count_months_0": "{{count}} شهر", "generic_count_months_1": "{{count}} شهر", @@ -531,10 +531,10 @@ "generic_count_months_4": "{{count}} شهور", "generic_count_months_5": "{{count}} شهر", "generic_count_seconds_0": "{{count}} ثانية", - "generic_count_seconds_1": "{{count}} ثانية", - "generic_count_seconds_2": "{{count}} ثانية", - "generic_count_seconds_3": "{{count}} ثانية", - "generic_count_seconds_4": "{{count}} ثوانٍ", + "generic_count_seconds_1": "ثانية واحدة", + "generic_count_seconds_2": "ثانيتين", + "generic_count_seconds_3": "{{count}} ثوانٍ", + "generic_count_seconds_4": "{{count}} ثانية", "generic_count_seconds_5": "{{count}} ثانية", "error_video_not_in_playlist": "الفيديو المطلوب غير موجود في قائمة التشغيل هذه. انقر هنا للحصول على الصفحة الرئيسية لقائمة التشغيل. " } From e2864a5ba10d47af856ba1f468cecb75c3940427 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:10 +0100 Subject: [PATCH 47/73] Update Italian translation Co-authored-by: atilluF --- locales/it.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/it.json b/locales/it.json index 63a8e8d4..c195f3b9 100644 --- a/locales/it.json +++ b/locales/it.json @@ -290,7 +290,7 @@ "Southern Sotho": "Sotho del Sud", "Spanish": "Spagnolo", "Spanish (Latin America)": "Spagnolo (America latina)", - "Sundanese": "Sudanese", + "Sundanese": "Sundanese", "Swahili": "Swahili", "Swedish": "Svedese", "Tajik": "Tagico", From 4d6ff3a3c69c7938a3fa628b1cc34c75e8961870 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:10 +0100 Subject: [PATCH 48/73] Update Hungarian translation Co-authored-by: Hosted Weblate Co-authored-by: Kroca Karoly --- locales/hu-HU.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/locales/hu-HU.json b/locales/hu-HU.json index 50e505dc..19ada1d8 100644 --- a/locales/hu-HU.json +++ b/locales/hu-HU.json @@ -470,5 +470,7 @@ "search_filters_duration_option_none": "Mindegy", "search_filters_duration_option_medium": "Átlagos (4 és 20 perc között)", "search_filters_features_option_vr180": "180°-os virtuális valóság", - "search_filters_apply_button": "Keresés a megadott szűrőkkel" + "search_filters_apply_button": "Keresés a megadott szűrőkkel", + "Popular enabled: ": "Népszerű engedélyezve ", + "error_video_not_in_playlist": "A lejátszási listában keresett videó nem létezik. Kattintson ide a lejátszási listához jutáshoz." } From 72aa5c94af53d42fea5c04796d1c78a9cbb39101 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:10 +0100 Subject: [PATCH 49/73] Update Portuguese (Brazil) translation Co-authored-by: Hosted Weblate Co-authored-by: Vinicius --- locales/pt-BR.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/locales/pt-BR.json b/locales/pt-BR.json index 9576d646..41b457bb 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -471,5 +471,6 @@ "Turkish (auto-generated)": "Turco (gerado automaticamente)", "search_filters_duration_option_medium": "Médio (4 - 20 minutos)", "search_filters_features_option_vr180": "VR180", - "Popular enabled: ": "Popular habilitado: " + "Popular enabled: ": "Popular habilitado: ", + "error_video_not_in_playlist": "O vídeo solicitado não existe nesta playlist. Clique aqui para acessar a página inicial da playlist." } From 23b229ebb71b8d8dfd62a660c4f8f13b34aaeed2 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:10 +0100 Subject: [PATCH 50/73] Update Finnish translation Co-authored-by: Hosted Weblate Co-authored-by: tomechio --- locales/fi.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/locales/fi.json b/locales/fi.json index cbb18825..bef9027f 100644 --- a/locales/fi.json +++ b/locales/fi.json @@ -471,5 +471,6 @@ "search_message_use_another_instance": " Voit myös hakea toisella instanssilla.", "search_filters_date_option_none": "Milloin tahansa", "search_filters_type_option_all": "Mikä tahansa tyyppi", - "Popular enabled: ": "Suosittu käytössä: " + "Popular enabled: ": "Suosittu käytössä: ", + "error_video_not_in_playlist": "Pyydettyä videota ei löydy tästä soittolistasta. Klikkaa tähän päästäksesi soittolistan etusivulle." } From 6b2fff83b53284e76dc326efe49dd31195fd8ee6 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:11 +0100 Subject: [PATCH 51/73] Update Albanian translation Co-authored-by: Besnik Bleta Co-authored-by: Hosted Weblate --- locales/sq.json | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/locales/sq.json b/locales/sq.json index 76f1eaa3..76dfd1b7 100644 --- a/locales/sq.json +++ b/locales/sq.json @@ -446,6 +446,22 @@ "Import YouTube subscriptions": "Importoni pajtime YouTube/OPML", "Export data as JSON": "Eksportoji të dhënat Invidious si JSON", "preferences_vr_mode_label": "Video me ndërveprim 360 gradë (lyp WebGL): ", - "Shared `x`": "Ndau me të tjerë `x`", - "search_filters_title": "Filtra" + "Shared `x`": "Ndarë me të tjerë më `x`", + "search_filters_title": "Filtra", + "Popular enabled: ": "Me populloret të aktivizuara: ", + "error_video_not_in_playlist": "Videoja e kërkuar s’ekziston në këtë luajlistë. Klikoni këtu për faqen hyrëse të luajlistës.", + "search_message_use_another_instance": " Mundeni edhe të kërkoni në një instancë tjetër.", + "search_filters_date_label": "Datë ngarkimi", + "preferences_watch_history_label": "Aktivizo historik parjesh: ", + "Top enabled: ": "Me kryesueset të aktivizuara: ", + "preferences_video_loop_label": "Përsërite gjithmonë: ", + "search_message_no_results": "S’u gjetën përfundime.", + "Could not pull trending pages.": "S’u morën dot faqet në modë.", + "search_filters_date_option_none": "Çfarëdo date", + "search_message_change_filters_or_query": "Provoni të zgjeroni kërkesën tuaj të kërkimit dhe/ose të ndryshoni filtrat.", + "search_filters_type_option_all": "Çfarëdo lloji", + "search_filters_duration_option_none": "Çfarëdo kohëzgjatjeje", + "search_filters_duration_option_medium": "Mesatare (4 - 20 minuta)", + "search_filters_features_option_vr180": "VR180", + "search_filters_apply_button": "Apliko filtrat e përzgjedhur" } From 9c9d71d41adca69291c072226d229f6764e53040 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:11 +0100 Subject: [PATCH 52/73] Update German translation Co-authored-by: DarkMoonExpeditionRobot Co-authored-by: Hosted Weblate --- locales/de.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/locales/de.json b/locales/de.json index 3ac32a31..a2070cf5 100644 --- a/locales/de.json +++ b/locales/de.json @@ -471,5 +471,6 @@ "search_filters_apply_button": "Ausgewählte Filter anwenden", "search_filters_duration_option_none": "Beliebige Länge", "search_filters_date_label": "Upload-Datum", - "search_filters_date_option_none": "Beliebiges Datum" + "search_filters_date_option_none": "Beliebiges Datum", + "error_video_not_in_playlist": "Das angeforderte Video existiert nicht in dieser Wiedergabeliste. Klicken Sie hier, um zur Startseite der Wiedergabeliste zu gelangen." } From 233de2eff9b80af11fe2747851b15079c4a2ffe1 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:11 +0100 Subject: [PATCH 53/73] Update Esperanto translation Update Esperanto translation Co-authored-by: Hosted Weblate Co-authored-by: Jorge Maldonado Ventura --- locales/eo.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locales/eo.json b/locales/eo.json index fb5bb69c..5aa2bbc6 100644 --- a/locales/eo.json +++ b/locales/eo.json @@ -5,8 +5,8 @@ "Subscribe": "Abonu", "View channel on YouTube": "Vidu kanalon en JuTubo", "View playlist on YouTube": "Vidu ludliston en JuTubo", - "newest": "pli novaj", - "oldest": "pli malnovaj", + "newest": "plej novaj", + "oldest": "plej malnovaj", "popular": "popularaj", "last": "lasta", "Next page": "Sekva paĝo", From a57770eb1f413abd16910dc22bd194051b1ddda5 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:11 +0100 Subject: [PATCH 54/73] Update Turkish translation Co-authored-by: Fatih K Co-authored-by: Hosted Weblate --- locales/tr.json | 554 ++++++++++++++++++++++++------------------------ 1 file changed, 277 insertions(+), 277 deletions(-) diff --git a/locales/tr.json b/locales/tr.json index 77aacb40..17db1cf1 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -1,126 +1,126 @@ { "LIVE": "CANLI", - "Shared `x` ago": "`x` önce paylaşıldı", - "Unsubscribe": "Abonelikten çık", - "Subscribe": "Abone ol", - "View channel on YouTube": "Kanalı YouTube'da görüntüle", - "View playlist on YouTube": "Oynatma listesini YouTube'da görüntüle", - "newest": "en yeni", - "oldest": "en eski", - "popular": "popüler", - "last": "son", - "Next page": "Sonraki sayfa", - "Previous page": "Önceki sayfa", + "Shared `x` ago": "`x` Önce Paylaşıldı", + "Unsubscribe": "Abonelikten Çık", + "Subscribe": "Abone Ol", + "View channel on YouTube": "Kanalı YouTube'da Görüntüle", + "View playlist on YouTube": "Oynatma Listesini YouTube'da Görüntüle", + "newest": "En Yeni", + "oldest": "En Eski", + "popular": "Popüler", + "last": "Son", + "Next page": "Sonraki Sayfa", + "Previous page": "Önceki Sayfa", "Clear watch history?": "İzleme geçmişi temizlensin mi?", - "New password": "Yeni parola", - "New passwords must match": "Yeni parolalar eşleşmek zorunda", - "Cannot change password for Google accounts": "Google hesapları için parola değiştirilemez", + "New password": "Yeni Parola", + "New passwords must match": "Yeni Parolalar Eşleşmek Zorunda", + "Cannot change password for Google accounts": "Google Hesapları İçin Parola Değiştirilemez", "Authorize token?": "Belirteç yetkilendirilsin mi?", "Authorize token for `x`?": "`x` için belirteç yetkilendirilsin mi?", "Yes": "Evet", "No": "Hayır", "Import and Export Data": "Verileri İçe ve Dışa Aktar", - "Import": "İçe aktar", - "Import Invidious data": "İnvidious JSON verilerini içe aktar", - "Import YouTube subscriptions": "YouTube/OPML aboneliklerini içe aktar", - "Import FreeTube subscriptions (.db)": "FreeTube aboneliklerini içe aktar (.db)", - "Import NewPipe subscriptions (.json)": "NewPipe aboneliklerini içe aktar (.json)", - "Import NewPipe data (.zip)": "NewPipe verilerini içe aktar (.zip)", - "Export": "Dışa aktar", - "Export subscriptions as OPML": "Abonelikleri OPML olarak dışa aktar", - "Export subscriptions as OPML (for NewPipe & FreeTube)": "Abonelikleri OPML olarak dışa aktar (NewPipe ve FreeTube için)", - "Export data as JSON": "Invidious verilerini JSON olarak dışa aktar", + "Import": "İçe Aktar", + "Import Invidious data": "Invidious JSON Verilerini İçe Aktar", + "Import YouTube subscriptions": "YouTube/OPML Aboneliklerini İçe Aktar", + "Import FreeTube subscriptions (.db)": "FreeTube Aboneliklerini İçe Aktar (.db)", + "Import NewPipe subscriptions (.json)": "NewPipe Aboneliklerini İçe Aktar (.json)", + "Import NewPipe data (.zip)": "NewPipe Verilerini İçe Aktar (.zip)", + "Export": "Dışa Aktar", + "Export subscriptions as OPML": "Abonelikleri OPML Olarak Dışa Aktar", + "Export subscriptions as OPML (for NewPipe & FreeTube)": "Abonelikleri OPML Olarak Dışa Aktar (NewPipe ve FreeTube İçin)", + "Export data as JSON": "İnvidious Verilerini JSON Olarak Dışa Aktar", "Delete account?": "Hesap silinsin mi?", "History": "Geçmiş", - "An alternative front-end to YouTube": "YouTube için alternatif bir ön-yüz", - "JavaScript license information": "JavaScript lisans bilgileri", - "source": "kaynak", - "Log in": "Oturum aç", - "Log in/register": "Oturum aç/kayıt ol", - "Log in with Google": "Google ile oturum aç", - "User ID": "Kullanıcı kimliği", + "An alternative front-end to YouTube": "YouTube İçin Alternatif Bir Ön-Yüz", + "JavaScript license information": "JavaScript Lisans Bilgileri", + "source": "Kaynak", + "Log in": "Oturum Aç", + "Log in/register": "Oturum Aç/Kayıt Ol", + "Log in with Google": "Google İle Oturum Aç", + "User ID": "Kullanıcı Kimliği", "Password": "Parola", "Time (h:mm:ss):": "Zaman (h:mm:ss):", "Text CAPTCHA": "Metin CAPTCHA", "Image CAPTCHA": "Resim CAPTCHA", "Sign In": "Oturum Aç", "Register": "Kayıt Ol", - "E-mail": "E-posta", - "Google verification code": "Google doğrulama kodu", + "E-mail": "E-Posta", + "Google verification code": "Google Doğrulama Kodu", "Preferences": "Tercihler", - "preferences_category_player": "Oynatıcı tercihleri", - "preferences_video_loop_label": "Sürekli döngü: ", - "preferences_autoplay_label": "Otomatik oynat: ", - "preferences_continue_label": "Öntanımlı olarak sonrakini oynat: ", - "preferences_continue_autoplay_label": "Sonraki videoyu otomatik oynat: ", - "preferences_listen_label": "Öntanımlı olarak dinle: ", - "preferences_local_label": "Videoları proxy'le: ", - "preferences_speed_label": "Öntanımlı hız: ", - "preferences_quality_label": "Tercih edilen video kalitesi: ", - "preferences_volume_label": "Oynatıcı ses seviyesi: ", - "preferences_comments_label": "Öntanımlı yorumlar: ", + "preferences_category_player": "Oynatıcı Tercihleri", + "preferences_video_loop_label": "Sürekli Döngü: ", + "preferences_autoplay_label": "Otomatik Oynat: ", + "preferences_continue_label": "Öntanımlı Olarak Sonrakini Oynat: ", + "preferences_continue_autoplay_label": "Sonraki Videoyu Otomatik Oynat: ", + "preferences_listen_label": "Öntanımlı Olarak Dinle: ", + "preferences_local_label": "Videolara Proxy Uygula: ", + "preferences_speed_label": "Öntanımlı Hız: ", + "preferences_quality_label": "Tercih Edilen Video Kalitesi: ", + "preferences_volume_label": "Oynatıcı Ses Seviyesi: ", + "preferences_comments_label": "Öntanımlı Yorumlar: ", "youtube": "YouTube", "reddit": "Reddit", - "preferences_captions_label": "Öntanımlı altyazılar: ", - "Fallback captions: ": "Yedek altyazılar: ", - "preferences_related_videos_label": "İlgili videoları göster: ", - "preferences_annotations_label": "Öntanımlı olarak ek açıklamaları göster: ", - "preferences_extend_desc_label": "Video açıklamasını otomatik olarak genişlet: ", - "preferences_vr_mode_label": "Etkileşimli 360 derece videolar (WebGL gerektirir): ", - "preferences_category_visual": "Görsel tercihler", - "preferences_player_style_label": "Oynatıcı biçimi: ", - "Dark mode: ": "Karanlık mod: ", + "preferences_captions_label": "Öntanımlı Altyazılar: ", + "Fallback captions: ": "Yedek Altyazılar: ", + "preferences_related_videos_label": "İlgili Videoları Göster: ", + "preferences_annotations_label": "Öntanımlı Olarak Ek Açıklamaları Göster: ", + "preferences_extend_desc_label": "Video Açıklamasını Otomatik Olarak Genişlet: ", + "preferences_vr_mode_label": "Etkileşimli 360 Derece Videolar (WebGL Gerektirir): ", + "preferences_category_visual": "Görsel Tercihler", + "preferences_player_style_label": "Oynatıcı Biçimi: ", + "Dark mode: ": "Koyu Mod: ", "preferences_dark_mode_label": "Tema: ", - "dark": "karanlık", - "light": "aydınlık", - "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_category_subscription": "Abonelik tercihleri", - "preferences_annotations_subscribed_label": "Abone olunan kanallar için ek açıklamaları öntanımlı olarak göster: ", - "Redirect homepage to feed: ": "Ana sayfayı akışa yönlendir: ", - "preferences_max_results_label": "Akışta gösterilen video sayısı: ", - "preferences_sort_label": "Videoları sıralama kriteri: ", - "published": "yayınlandı", - "published - reverse": "yayınlandı - ters", - "alphabetically": "alfabetik olarak", - "alphabetically - reverse": "alfabetik olarak - ters", - "channel name": "kanal adı", - "channel name - reverse": "kanal adı - ters", - "Only show latest video from channel: ": "Sadece kanaldaki en son videoyu göster: ", - "Only show latest unwatched video from channel: ": "Sadece kanaldaki en son izlenmemiş videoyu göster: ", - "preferences_unseen_only_label": "Sadece izlenmemişleri göster: ", - "preferences_notifications_only_label": "Sadece bildirimleri göster (eğer varsa): ", - "Enable web notifications": "Ağ bildirimlerini etkinleştir", - "`x` uploaded a video": "`x` bir video yükledi", - "`x` is live": "`x` canlı yayında", - "preferences_category_data": "Veri tercihleri", - "Clear watch history": "İzleme geçmişini temizle", - "Import/export data": "Verileri içe/dışa aktar", - "Change password": "Parolayı değiştir", - "Manage subscriptions": "Abonelikleri yönet", - "Manage tokens": "Belirteçleri yönet", - "Watch history": "İzleme geçmişi", - "Delete account": "Hesap silme", - "preferences_category_admin": "Yönetici tercihleri", - "preferences_default_home_label": "Öntanımlı ana sayfa: ", - "preferences_feed_menu_label": "Akış menüsü: ", - "preferences_show_nick_label": "Takma adı üstte göster: ", - "Top enabled: ": "Top etkin: ", - "CAPTCHA enabled: ": "CAPTCHA etkin: ", - "Login enabled: ": "Oturum açma etkin: ", - "Registration enabled: ": "Kayıt olma etkin: ", - "Report statistics: ": "Rapor istatistikleri: ", - "Save preferences": "Tercihleri kaydet", - "Subscription manager": "Abonelik yöneticisi", - "Token manager": "Belirteç yöneticisi", + "dark": "Koyu", + "light": "Açık", + "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_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: ", + "preferences_max_results_label": "Akışta Gösterilen Video Sayısı: ", + "preferences_sort_label": "Videoları Sıralama Kriteri: ", + "published": "Yayınlandı", + "published - reverse": "Yayınlandı - Ters", + "alphabetically": "Alfabetik Olarak", + "alphabetically - reverse": "Alfabetik Olarak - Ters", + "channel name": "Kanal Adı", + "channel name - reverse": "Kanal Adı - Ters", + "Only show latest video from channel: ": "Sadece Kanaldaki En Son Videoyu Göster: ", + "Only show latest unwatched video from channel: ": "Sadece Kanaldaki En Son İzlenmemiş Videoyu Göster: ", + "preferences_unseen_only_label": "Sadece İzlenmemişleri Göster: ", + "preferences_notifications_only_label": "Sadece Bildirimleri Göster (Eğer Varsa): ", + "Enable web notifications": "Ağ Bildirimlerini Etkinleştir", + "`x` uploaded a video": "`x` Bir Video Yükledi", + "`x` is live": "`x` Canlı Yayında", + "preferences_category_data": "Veri Tercihleri", + "Clear watch history": "İzleme Geçmişini Temizle", + "Import/export data": "Verileri İçe/Dışa Aktar", + "Change password": "Parolayı Değiştir", + "Manage subscriptions": "Abonelikleri Yönet", + "Manage tokens": "Belirteçleri Yönet", + "Watch history": "İzleme Geçmişi", + "Delete account": "Hesap Silme", + "preferences_category_admin": "Yönetici Tercihleri", + "preferences_default_home_label": "Öntanımlı Ana Sayfa: ", + "preferences_feed_menu_label": "Akış Menüsü: ", + "preferences_show_nick_label": "Takma Adı Üstte Göster: ", + "Top enabled: ": "Top Etkin: ", + "CAPTCHA enabled: ": "CAPTCHA Etkin: ", + "Login enabled: ": "Oturum Açma Etkin: ", + "Registration enabled: ": "Kayıt Olma Etkin: ", + "Report statistics: ": "Rapor İstatistikleri: ", + "Save preferences": "Tercihleri Kaydet", + "Subscription manager": "Abonelik Yöneticisi", + "Token manager": "Belirteç Yöneticisi", "Token": "Belirteç", - "Import/export": "İçe/dışa aktar", - "unsubscribe": "abonelikten çık", - "revoke": "geri al", + "Import/export": "İçe/Dışa Aktar", + "unsubscribe": "Abonelikten Çık", + "revoke": "Geri Al", "Subscriptions": "Abonelikler", - "search": "ara", - "Log out": "Çıkış yap", + "search": "Ara", + "Log out": "Çıkış Yap", "Released under the AGPLv3 on Github.": "GitHub'da AGPLv3 altında yayınlandı.", "Source available here.": "Kaynak kodları burada bulunabilir.", "View JavaScript license information.": "JavaScript lisans bilgilerini görüntüle.", @@ -129,76 +129,76 @@ "Public": "Genel", "Unlisted": "Listelenmemiş", "Private": "Özel", - "View all playlists": "Tüm oynatma listelerini görüntüle", - "Updated `x` ago": "`x` önce güncellendi", + "View all playlists": "Tüm Oynatma Listelerini Görüntüle", + "Updated `x` ago": "`x` Önce Güncellendi", "Delete playlist `x`?": "`x` oynatma listesi silinsin mi?", - "Delete playlist": "Oynatma listesini sil", - "Create playlist": "Oynatma listesi oluştur", + "Delete playlist": "Oynatma Listesini Sil", + "Create playlist": "Oynatma Listesi Oluştur", "Title": "Başlık", - "Playlist privacy": "Oynatma listesi gizliliği", - "Editing playlist `x`": "`x` oynatma listesi düzenleniyor", - "Show more": "Daha fazla göster", - "Show less": "Daha az göster", - "Watch on YouTube": "YouTube'da izle", + "Playlist privacy": "Oynatma Listesi Gizliliği", + "Editing playlist `x`": "`x` Oynatma Listesi Düzenleniyor", + "Show more": "Daha Fazla Göster", + "Show less": "Daha Az Göster", + "Watch on YouTube": "YouTube'da İzle", "Switch Invidious Instance": "Invidious Örneğini Değiştir", - "Hide annotations": "Ek açıklamaları gizle", - "Show annotations": "Ek açıklamaları göster", + "Hide annotations": "Ek Açıklamaları Gizle", + "Show annotations": "Ek Açıklamaları Göster", "Genre: ": "Tür: ", "License: ": "Lisans: ", "Family friendly? ": "Aile için uygun mu? ", - "Wilson score: ": "Wilson puanı: ", - "Engagement: ": "İzleyenlerin oy verme oranı: ", - "Whitelisted regions: ": "Beyaz listeye alınan bölgeler: ", - "Blacklisted regions: ": "Kara listeye alınan bölgeler: ", - "Shared `x`": "`x` paylaşıldı", - "Premieres in `x`": "`x`içinde ilk gösterim", - "Premieres `x`": "`x` ilk gösterim", + "Wilson score: ": "Wilson Puanı: ", + "Engagement: ": "İzleyenlerin Oy Verme Oranı: ", + "Whitelisted regions: ": "Beyaz Listeye Alınan Bölgeler: ", + "Blacklisted regions: ": "Kara Listeye Alınan Bölgeler: ", + "Shared `x`": "`x` Paylaşıldı", + "Premieres in `x`": "`x`İçinde İlk Gösterim", + "Premieres `x`": "`x` İlk Gösterim", "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.": "Merhaba! JavaScript'i kapatmış gibi görünüyorsun. Yorumları görüntülemek için buraya tıkla, yüklenmelerinin biraz uzun sürebileceğini unutma.", - "View YouTube comments": "YouTube yorumlarını görüntüle", - "View more comments on Reddit": "Reddit'te daha fazla yorum görüntüle", + "View YouTube comments": "YouTube Yorumlarını Görüntüle", + "View more comments on Reddit": "Reddit'te Daha Fazla Yorum Görüntüle", "View `x` comments": { - "([^.,0-9]|^)1([^.,0-9]|$)": "`x` yorumu görüntüle", - "": "`x` yorumu görüntüle" + "([^.,0-9]|^)1([^.,0-9]|$)": "`x` Yorumu Görüntüle", + "": "`x` Yorumu Görüntüle" }, - "View Reddit comments": "Reddit yorumlarını görüntüle", - "Hide replies": "Cevapları gizle", - "Show replies": "Cevapları göster", - "Incorrect password": "Yanlış parola", - "Quota exceeded, try again in a few hours": "Kota aşıldı, birkaç saat içinde tekrar deneyin", - "Unable to log in, make sure two-factor authentication (Authenticator or SMS) is turned on.": "Oturum açılamadı, iki faktörlü kimlik doğrulamanın (Authenticator ya da SMS) açık olduğundan emin olun.", - "Invalid TFA code": "Geçersiz TFA kodu", + "View Reddit comments": "Reddit Yorumlarını Görüntüle", + "Hide replies": "Cevapları Gizle", + "Show replies": "Cevapları Göster", + "Incorrect password": "Yanlış Parola", + "Quota exceeded, try again in a few hours": "Kota aşıldı, birkaç saat içinde tekrar deneyin.", + "Unable to log in, make sure two-factor authentication (Authenticator or SMS) is turned on.": "Oturum açılamadı, iki faktörlü kimlik doğrulamanın (Kimlik Doğrulayıcı ya da SMS) açık olduğundan emin olun.", + "Invalid TFA code": "Geçersiz TFA Kodu", "Login failed. This may be because two-factor authentication is not turned on for your account.": "Giriş başarısız. Bunun nedeni, hesabınız için iki faktörlü kimlik doğrulamanın açık olmaması olabilir.", - "Wrong answer": "Yanlış cevap", + "Wrong answer": "Yanlış Cevap", "Erroneous CAPTCHA": "Hatalı CAPTCHA", - "CAPTCHA is a required field": "CAPTCHA zorunlu bir alandır", - "User ID is a required field": "Kullanıcı kimliği zorunlu bir alandır", - "Password is a required field": "Parola zorunlu bir alandır", - "Wrong username or password": "Yanlış kullanıcı adı ya da parola", - "Please sign in using 'Log in with Google'": "Lütfen 'Google ile giriş yap' seçeneğini kullanarak oturum açın", - "Password cannot be empty": "Parola boş olamaz", - "Password cannot be longer than 55 characters": "Parola 55 karakterden uzun olamaz", - "Please log in": "Lütfen oturum açın", - "Invidious Private Feed for `x`": "`x` için İnvidious Özel Akışı", - "channel:`x`": "kanal:`x`", - "Deleted or invalid channel": "Silinmiş ya da geçersiz kanal", + "CAPTCHA is a required field": "CAPTCHA Zorunlu Bir Alandır", + "User ID is a required field": "Kullanıcı Kimliği Zorunlu Bir Alandır", + "Password is a required field": "Parola Zorunlu Bir Alandır", + "Wrong username or password": "Yanlış Kullanıcı Adı ya da Parola", + "Please sign in using 'Log in with Google'": "Lütfen 'Google İle Giriş Yap' Seçeneğini Kullanarak Oturum Açın", + "Password cannot be empty": "Parola Boş Olamaz", + "Password cannot be longer than 55 characters": "Parola 55 Karakterden Uzun Olamaz", + "Please log in": "Lütfen Oturum Açın", + "Invidious Private Feed for `x`": "`x` İçin Invidious Özel Akışı", + "channel:`x`": "Kanal:`x`", + "Deleted or invalid channel": "Silinmiş ya da Geçersiz Kanal", "This channel does not exist.": "Bu kanal mevcut değil.", "Could not get channel info.": "Kanal bilgisi alınamadı.", - "Could not fetch comments": "Yorumlar alınamadı", - "`x` ago": "`x` önce", - "Load more": "Daha fazla yükle", + "Could not fetch comments": "Yorumlar Alınamadı", + "`x` ago": "`x` Önce", + "Load more": "Daha Fazla Yükle", "Could not create mix.": "Mix oluşturulamadı.", - "Empty playlist": "Boş oynatma listesi", + "Empty playlist": "Boş Oynatma Listesi", "Not a playlist.": "Oynatma listesi değil.", "Playlist does not exist.": "Oynatma listesi mevcut değil.", "Could not pull trending pages.": "Trend sayfaları alınamıyor.", - "Hidden field \"challenge\" is a required field": "Gizli alan \"challenge\" zorunlu bir alandır", - "Hidden field \"token\" is a required field": "\"belirteç\" gizli alanı zorunlu bir alandır", - "Erroneous challenge": "Hatalı challenge", - "Erroneous token": "Hatalı belirteç", - "No such user": "Böyle bir kullanıcı yok", - "Token is expired, please try again": "Belirtecin süresi doldu, lütfen tekrar deneyin", + "Hidden field \"challenge\" is a required field": "Gizli Alan \"Challenge\" Zorunlu Bir Alandır", + "Hidden field \"token\" is a required field": "\"Belirteç\" Gizli Alanı Zorunlu Bir Alandır", + "Erroneous challenge": "Hatalı Challenge", + "Erroneous token": "Hatalı Belirteç", + "No such user": "Böyle Bir Kullanıcı Yok", + "Token is expired, please try again": "Belirtecin Süresi Doldu, Lütfen Tekrar Deneyin", "English": "İngilizce", - "English (auto-generated)": "İngilizce (otomatik oluşturuldu)", + "English (auto-generated)": "İngilizce (Otomatik Oluşturuldu)", "Afrikaans": "Afrikanca", "Albanian": "Arnavutça", "Amharic": "Amharca", @@ -230,9 +230,9 @@ "German": "Almanca", "Greek": "Yunanca", "Gujarati": "Guceratça", - "Haitian Creole": "Haiti Creole dili", + "Haitian Creole": "Haiti Creole Dili", "Hausa": "Hausaca", - "Hawaiian": "Hawaii dili", + "Hawaiian": "Hawaii Dili", "Hebrew": "İbranice", "Hindi": "Hintçe", "Hmong": "Hmong", @@ -244,7 +244,7 @@ "Italian": "İtalyanca", "Japanese": "Japonca", "Javanese": "Cava dili", - "Kannada": "Kannada dili", + "Kannada": "Kannada Dili", "Kazakh": "Kazakça", "Khmer": "Kmerce", "Korean": "Korece", @@ -258,10 +258,10 @@ "Macedonian": "Makedonca", "Malagasy": "Malgaşça", "Malay": "Malayca", - "Malayalam": "Malayalam dili", + "Malayalam": "Malayalam Dili", "Maltese": "Maltaca", - "Maori": "Maori dili", - "Marathi": "Marati dili", + "Maori": "Maori Dili", + "Marathi": "Marati Dili", "Mongolian": "Moğolca", "Nepali": "Nepalce", "Norwegian Bokmål": "Norveççe Bokmål", @@ -270,19 +270,19 @@ "Persian": "Farsça", "Polish": "Lehçe", "Portuguese": "Portekizce", - "Punjabi": "Pencap dili", + "Punjabi": "Pencap Dili", "Romanian": "Rumence", "Russian": "Rusça", - "Samoan": "Samoa dili", + "Samoan": "Samoa Dili", "Scottish Gaelic": "İskoç Galcesi", "Serbian": "Sırpça", - "Shona": "Şona dili", + "Shona": "Şona Dili", "Sindhi": "Sintçe", "Sinhala": "Seylanca", "Slovak": "Slovakça", "Slovenian": "Slovence", "Somali": "Somalice", - "Southern Sotho": "Güney Sotho dili", + "Southern Sotho": "Güney Sotho Dili", "Spanish": "İspanyolca", "Spanish (Latin America)": "İspanyolca (Latin Amerika)", "Sundanese": "Sundaca", @@ -290,7 +290,7 @@ "Swedish": "İsveççe", "Tajik": "Tacikçe", "Tamil": "Tamilce", - "Telugu": "Telugu dili", + "Telugu": "Telugu Dili", "Thai": "Tayca", "Turkish": "Türkçe", "Ukrainian": "Ukraynaca", @@ -299,178 +299,178 @@ "Vietnamese": "Vietnamca", "Welsh": "Galce", "Western Frisian": "Batı Frizcesi", - "Xhosa": "Xhosa dili", + "Xhosa": "Xhosa Dili", "Yiddish": "Yiddiş", - "Yoruba": "Yoruba dili", + "Yoruba": "Yoruba Dili", "Zulu": "Zuluca", - "Fallback comments: ": "Yedek yorumlar: ", + "Fallback comments: ": "Yedek Yorumlar: ", "Popular": "Popüler", "Search": "Ara", "Top": "Enler", "About": "Hakkında", "Rating: ": "Değerlendirme: ", "preferences_locale_label": "Dil: ", - "View as playlist": "Oynatma listesi olarak görüntüle", + "View as playlist": "Oynatma Listesi Olarak Görüntüle", "Default": "Öntanımlı", "Music": "Müzik", "Gaming": "Oyun", "News": "Haberler", "Movies": "Filmler", "Download": "İndir", - "Download as: ": "Şu şekilde indir: ", + "Download as: ": "Şu Şekilde İndir: ", "%A %B %-d, %Y": "%A %B %-d, %Y", - "(edited)": "(düzenlendi)", - "YouTube comment permalink": "YouTube yorumu kalıcı linki", - "permalink": "kalıcı link", - "`x` marked it with a ❤": "`x` ❤ ile işaretledi", - "Audio mode": "Ses modu", - "Video mode": "Video modu", + "(edited)": "(Düzenlendi)", + "YouTube comment permalink": "YouTube Yorumu Kalıcı Linki", + "permalink": "Kalıcı Link", + "`x` marked it with a ❤": "`x` ❤ İle İşaretledi", + "Audio mode": "Ses Modu", + "Video mode": "Video Modu", "Videos": "Videolar", - "Playlists": "Oynatma listeleri", + "Playlists": "Oynatma Listeleri", "Community": "Topluluk", "search_filters_sort_option_relevance": "İlgi", "search_filters_sort_option_rating": "Değerlendirme", - "search_filters_sort_option_date": "Yükleme tarihi", - "search_filters_sort_option_views": "Görüntüleme sayısı", + "search_filters_sort_option_date": "Yükleme Tarihi", + "search_filters_sort_option_views": "Görüntüleme Sayısı", "search_filters_type_label": "Tür", "search_filters_duration_label": "Süre", "search_filters_features_label": "Özellikler", "search_filters_sort_label": "Sıralama Ölçütü", "search_filters_date_option_hour": "Son Saat", "search_filters_date_option_today": "Bugün", - "search_filters_date_option_week": "Bu hafta", - "search_filters_date_option_month": "Bu ay", - "search_filters_date_option_year": "Bu yıl", + "search_filters_date_option_week": "Bu Hafta", + "search_filters_date_option_month": "Bu Ay", + "search_filters_date_option_year": "Bu Yıl", "search_filters_type_option_video": "Video", "search_filters_type_option_channel": "Kanal", - "search_filters_type_option_playlist": "Oynatma listesi", + "search_filters_type_option_playlist": "Oynatma Listesi", "search_filters_type_option_movie": "Film", "search_filters_type_option_show": "Gösteri", "search_filters_features_option_hd": "HD", - "search_filters_features_option_subtitles": "Alt yazılar", - "search_filters_features_option_c_commons": "Creative Commons", - "search_filters_features_option_three_d": "3B", + "search_filters_features_option_subtitles": "Alt Yazılar", + "search_filters_features_option_c_commons": "Yaratıcı", + "search_filters_features_option_three_d": "3D", "search_filters_features_option_live": "Canlı", "search_filters_features_option_four_k": "4K", "search_filters_features_option_location": "Konum", "search_filters_features_option_hdr": "HDR", - "Current version: ": "Şu anki sürüm: ", - "next_steps_error_message": "Bundan sonra şunları denemelisiniz: ", + "Current version: ": "Şu Anki Sürüm: ", + "next_steps_error_message": "Bundan Sonra Şunları Denemelisiniz: ", "next_steps_error_message_refresh": "Yenile", - "next_steps_error_message_go_to_youtube": "YouTube'a git", - "search_filters_duration_option_short": "Kısa (4 dakikadan az)", - "search_filters_duration_option_long": "Uzun (20 dakikadan fazla)", + "next_steps_error_message_go_to_youtube": "YouTube'a Git", + "search_filters_duration_option_short": "Kısa (4 Dakikadan Az)", + "search_filters_duration_option_long": "Uzun (20 Dakikadan Fazla)", "footer_documentation": "Belgelendirme", - "footer_source_code": "Kaynak kodları", - "footer_original_source_code": "Orijinal kaynak kodları", - "footer_modfied_source_code": "Değiştirilmiş kaynak kodları", - "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: ", + "footer_source_code": "Kaynak Kodları", + "footer_original_source_code": "Orijinal Kaynak Kodları", + "footer_modfied_source_code": "Değiştirilmiş Kaynak Kodları", + "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_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", + "preferences_quality_dash_option_best": "En İyi", + "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", + "none": "Yok", + "videoinfo_started_streaming_x_ago": "`x` Önce Yayına Başladı", + "videoinfo_youTube_embed_link": "Entegre Et", + "videoinfo_invidious_embed_link": "Bağlantıyı Entegre Et", + "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_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_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", - "search_filters_features_option_purchased": "Satın alınan", + "search_filters_features_option_purchased": "Satın Alınan", "search_filters_features_option_three_sixty": "360°", - "videoinfo_watch_on_youTube": "YouTube'da izle", - "download_subtitles": "Alt yazılar - `x` (.vtt)", - "preferences_save_player_pos_label": "Oynatma konumunu kaydet: ", - "generic_views_count": "{{count}} görüntüleme", - "generic_views_count_plural": "{{count}} görüntüleme", - "generic_subscribers_count": "{{count}} abone", - "generic_subscribers_count_plural": "{{count}} abone", - "generic_subscriptions_count": "{{count}} abonelik", - "generic_subscriptions_count_plural": "{{count}} abonelik", - "subscriptions_unseen_notifs_count": "{{count}} okunmamış bildirim", - "subscriptions_unseen_notifs_count_plural": "{{count}} okunmamış bildirim", - "comments_points_count": "{{count}} puan", - "comments_points_count_plural": "{{count}} puan", - "generic_count_hours": "{{count}} saat", - "generic_count_hours_plural": "{{count}} saat", - "generic_count_minutes": "{{count}} dakika", - "generic_count_minutes_plural": "{{count}} dakika", - "generic_count_seconds": "{{count}} saniye", - "generic_count_seconds_plural": "{{count}} saniye", - "generic_playlists_count": "{{count}} oynatma listesi", - "generic_playlists_count_plural": "{{count}} oynatma listesi", - "tokens_count": "{{count}} belirteç", - "tokens_count_plural": "{{count}} belirteç", - "comments_view_x_replies": "{{count}} yanıtı görüntüle", - "comments_view_x_replies_plural": "{{count}} yanıtı görüntüle", - "generic_count_years": "{{count}} yıl", - "generic_count_years_plural": "{{count}} yıl", - "generic_count_months": "{{count}} ay", - "generic_count_months_plural": "{{count}} ay", - "generic_count_days": "{{count}} gün", - "generic_count_days_plural": "{{count}} gün", - "generic_videos_count": "{{count}} video", - "generic_videos_count_plural": "{{count}} video", - "generic_count_weeks": "{{count}} hafta", - "generic_count_weeks_plural": "{{count}} hafta", + "videoinfo_watch_on_youTube": "YouTube'da İzle", + "download_subtitles": "Alt Yazılar - `x` (.vtt)", + "preferences_save_player_pos_label": "Oynatma Konumunu Kaydet: ", + "generic_views_count": "{{count}} Görüntüleme", + "generic_views_count_plural": "{{count}} Görüntüleme", + "generic_subscribers_count": "{{count}} Abone", + "generic_subscribers_count_plural": "{{count}} Abone", + "generic_subscriptions_count": "{{count}} Abonelik", + "generic_subscriptions_count_plural": "{{count}} Abonelik", + "subscriptions_unseen_notifs_count": "{{count}} Okunmamış Bildirim", + "subscriptions_unseen_notifs_count_plural": "{{count}} Okunmamış Bildirim", + "comments_points_count": "{{count}} Puan", + "comments_points_count_plural": "{{count}} Puan", + "generic_count_hours": "{{count}} Saat", + "generic_count_hours_plural": "{{count}} Saat", + "generic_count_minutes": "{{count}} Dakika", + "generic_count_minutes_plural": "{{count}} Dakika", + "generic_count_seconds": "{{count}} Saniye", + "generic_count_seconds_plural": "{{count}} Saniye", + "generic_playlists_count": "{{count}} Oynatma Listesi", + "generic_playlists_count_plural": "{{count}} Oynatma Listesi", + "tokens_count": "{{count}} Belirteç", + "tokens_count_plural": "{{count}} Belirteç", + "comments_view_x_replies": "{{count}} Yanıtı Görüntüle", + "comments_view_x_replies_plural": "{{count}} Yanıtı Görüntüle", + "generic_count_years": "{{count}} Yıl", + "generic_count_years_plural": "{{count}} Yıl", + "generic_count_months": "{{count}} Ay", + "generic_count_months_plural": "{{count}} Ay", + "generic_count_days": "{{count}} Gün", + "generic_count_days_plural": "{{count}} Gün", + "generic_videos_count": "{{count}} Video", + "generic_videos_count_plural": "{{count}} Video", + "generic_count_weeks": "{{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": "sayfayı yenilemeye çalıştınız", - "crash_page_switch_instance": "başka bir örnek kullanmaya çalıştınız", - "crash_page_read_the_faq": "Sık Sorulan Soruları (SSS) okudunuz", - "crash_page_search_issue": "GitHub'daki sorunlarda aradınız", - "crash_page_report_issue": "Yukarıdakilerin hiçbiri yardımcı olmadıysa, lütfen GitHub'da yeni bir sorun açın (tercihen İngilizce) ve mesajınıza aşağıdaki metni ekleyin (bu metni ÇEVİRMEYİN):", + "crash_page_refresh": "Sayfayı Yenilemeye Çalıştınız", + "crash_page_switch_instance": "Başka Bir Örnek Kullanmaya Çalıştınız", + "crash_page_read_the_faq": "Sık Sorulan Soruları (SSS) Okudunuz", + "crash_page_search_issue": "GitHub'daki Sorunlarda Aradınız", + "crash_page_report_issue": "Yukarıdakilerin hiçbiri yardımcı olmadıysa, lütfen GitHub'da yeni bir sorun açın (Tercihen İngilizce) ve mesajınıza aşağıdaki metni ekleyin (Bu metni ÇEVİRMEYİN):", "English (United Kingdom)": "İngilizce (Birleşik Krallık)", "Chinese": "Çince", "Interlingue": "İnterlingue", - "Italian (auto-generated)": "İtalyanca (otomatik oluşturuldu)", - "Japanese (auto-generated)": "Japonca (otomatik oluşturuldu)", + "Italian (auto-generated)": "İtalyanca (Otomatik Oluşturuldu)", + "Japanese (auto-generated)": "Japonca (Otomatik Oluşturuldu)", "Portuguese (Brazil)": "Portekizce (Brezilya)", - "Russian (auto-generated)": "Rusça (otomatik oluşturuldu)", - "Spanish (auto-generated)": "İspanyolca (otomatik oluşturuldu)", + "Russian (auto-generated)": "Rusça (Otomatik Oluşturuldu)", + "Spanish (auto-generated)": "İspanyolca (Otomatik Oluşturuldu)", "Spanish (Mexico)": "İspanyolca (Meksika)", "English (United States)": "İngilizce (ABD)", "Cantonese (Hong Kong)": "Kantonca (Hong Kong)", "Chinese (Taiwan)": "Çince (Tayvan)", - "Dutch (auto-generated)": "Felemenkçe (otomatik oluşturuldu)", - "Indonesian (auto-generated)": "Endonezyaca (otomatik oluşturuldu)", + "Dutch (auto-generated)": "Felemenkçe (Otomatik Oluşturuldu)", + "Indonesian (auto-generated)": "Endonezyaca (Otomatik Oluşturuldu)", "Chinese (Hong Kong)": "Çince (Hong Kong)", - "French (auto-generated)": "Fransızca (otomatik oluşturuldu)", - "Korean (auto-generated)": "Korece (otomatik oluşturuldu)", - "Turkish (auto-generated)": "Türkçe (otomatik oluşturuldu)", + "French (auto-generated)": "Fransızca (Otomatik Oluşturuldu)", + "Korean (auto-generated)": "Korece (Otomatik Oluşturuldu)", + "Turkish (auto-generated)": "Türkçe (Otomatik Oluşturuldu)", "Chinese (China)": "Çince (Çin)", - "German (auto-generated)": "Almanca (otomatik oluşturuldu)", - "Portuguese (auto-generated)": "Portekizce (otomatik oluşturuldu)", + "German (auto-generated)": "Almanca (Otomatik Oluşturuldu)", + "Portuguese (auto-generated)": "Portekizce (Otomatik Oluşturuldu)", "Spanish (Spain)": "İspanyolca (İspanya)", - "Vietnamese (auto-generated)": "Vietnamca (otomatik oluşturuldu)", - "preferences_watch_history_label": "İzleme geçmişini etkinleştir: ", + "Vietnamese (auto-generated)": "Vietnamca (Otomatik Oluşturuldu)", + "preferences_watch_history_label": "İzleme Geçmişini Etkinleştir: ", "search_message_use_another_instance": " Ayrıca başka bir örnekte arayabilirsiniz.", - "search_filters_type_option_all": "Herhangi bir tür", - "search_filters_duration_option_none": "Herhangi bir süre", + "search_filters_type_option_all": "Herhangi Bir Tür", + "search_filters_duration_option_none": "Herhangi Bir Süre", "search_message_no_results": "Sonuç bulunamadı.", - "search_filters_date_label": "Yükleme tarihi", - "search_filters_apply_button": "Seçili filtreleri uygula", - "search_filters_date_option_none": "Herhangi bir tarih", - "search_filters_duration_option_medium": "Orta (4 - 20 dakika)", + "search_filters_date_label": "Yükleme Tarihi", + "search_filters_apply_button": "Seçili Filtreleri Uygula", + "search_filters_date_option_none": "Herhangi Bir Tarih", + "search_filters_duration_option_medium": "Orta (4 - 20 Dakika)", "search_filters_features_option_vr180": "VR180", "search_filters_title": "Filtreler", "search_message_change_filters_or_query": "Arama sorgunuzu genişletmeyi ve/veya filtreleri değiştirmeyi deneyin.", - "Popular enabled: ": "Popüler etkin: ", + "Popular enabled: ": "Popüler Etkin: ", "error_video_not_in_playlist": "İstenen video bu oynatma listesinde yok. Oynatma listesi ana sayfası için buraya tıklayın." } From e0275d090869392e945c1c93902cb517bd60f478 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:11 +0100 Subject: [PATCH 55/73] Update Japanese translation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 田島翔太 --- locales/ja.json | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/locales/ja.json b/locales/ja.json index 7918fe95..4971c472 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -403,7 +403,7 @@ "none": "なし", "download_subtitles": "字幕 - `x` (.vtt)", "search_filters_features_option_purchased": "購入済み", - "preferences_quality_option_dash": "DASH (適切な品質)", + "preferences_quality_option_dash": "DASH (適応品質)", "preferences_quality_dash_option_worst": "最悪", "preferences_quality_dash_option_best": "最高", "videoinfo_started_streaming_x_ago": "`x`分前に配信を開始", @@ -438,5 +438,20 @@ "search_message_no_results": "一致する検索結果はありませんでした", "English (United States)": "英語 (アメリカ)", "search_filters_date_label": "アップロード日", - "search_filters_features_option_vr180": "VR180" + "search_filters_features_option_vr180": "VR180", + "crash_page_switch_instance": "別のインスタンスを使用しようとしました", + "crash_page_read_the_faq": "よくある質問 (FAQ) を読む", + "Popular enabled: ": "人気動画を有効化 ", + "search_message_use_another_instance": " 別のインスタンスで検索することもできます。", + "search_filters_apply_button": "選択したフィルターを適用", + "user_saved_playlists": "`x` 個の保存済みプレイリスト", + "crash_page_you_found_a_bug": "Invidious でバグを見つけたようです。", + "crash_page_refresh": "ページを更新しようとしました", + "preferences_watch_history_label": "視聴履歴を有効化 ", + "search_filters_date_option_none": "任意の日付", + "search_filters_type_option_all": "いかなるタイプ", + "search_filters_duration_option_none": "任意の期間", + "search_filters_duration_option_medium": "ミディアム (4 ~ 20 分)", + "preferences_save_player_pos_label": "再生位置を保存: ", + "crash_page_before_reporting": "バグを報告する前に、次のことを確認してください。" } From 16140f8b3fb0b332daf9a9c77ded4bd34b63e4e4 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:11 +0100 Subject: [PATCH 56/73] Update Portuguese (Portugal) translation Update Portuguese (Portugal) translation Co-authored-by: Hosted Weblate Co-authored-by: Samantaz Fox Co-authored-by: ssantos --- locales/pt-PT.json | 82 ++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/locales/pt-PT.json b/locales/pt-PT.json index 5313915b..1bee2807 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -22,14 +22,14 @@ "Import and Export Data": "Importar e exportar dados", "Import": "Importar", "Import Invidious data": "Importar dados JSON do Invidious", - "Import YouTube subscriptions": "Importar subscrições OPML ou do YouTube", + "Import YouTube subscriptions": "Importar subscrições do YouTube/OPML", "Import FreeTube subscriptions (.db)": "Importar subscrições do FreeTube (.db)", "Import NewPipe subscriptions (.json)": "Importar subscrições do NewPipe (.json)", "Import NewPipe data (.zip)": "Importar dados do NewPipe (.zip)", "Export": "Exportar", "Export subscriptions as OPML": "Exportar subscrições como OPML", "Export subscriptions as OPML (for NewPipe & FreeTube)": "Exportar subscrições como OPML (para NewPipe e FreeTube)", - "Export data as JSON": "Exportar dados do Invidious como JSON", + "Export data as JSON": "Exportar dados Invidious como JSON", "Delete account?": "Eliminar conta?", "History": "Histórico", "An alternative front-end to YouTube": "Uma interface alternativa ao YouTube", @@ -379,24 +379,24 @@ "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_subscriptions_count": "{{count}} subscrição", - "generic_subscriptions_count_plural": "{{count}} subscrições", + "generic_subscriptions_count": "{{count}} inscrição", + "generic_subscriptions_count_plural": "{{count}} inscrições", "generic_views_count": "{{count}} visualização", "generic_views_count_plural": "{{count}} visualizações", - "generic_subscribers_count": "{{count}} subscritor", - "generic_subscribers_count_plural": "{{count}} subscritores", + "generic_subscribers_count": "{{count}} inscrito", + "generic_subscribers_count_plural": "{{count}} inscritos", "preferences_quality_dash_option_4320p": "4320p", - "preferences_quality_dash_label": "Qualidade de vídeo DASH preferencial ", + "preferences_quality_dash_label": "Qualidade de vídeo DASH preferida: ", "preferences_quality_dash_option_2160p": "2160p", - "subscriptions_unseen_notifs_count": "{{count}} notificação por ver", - "subscriptions_unseen_notifs_count_plural": "{{count}} notificações por ver", - "Popular enabled: ": "Página \"Popular\" ativada: ", + "subscriptions_unseen_notifs_count": "{{count}} notificação não vista", + "subscriptions_unseen_notifs_count_plural": "{{count}} notificações não vistas", + "Popular enabled: ": "Página \"popular\" ativada: ", "search_message_no_results": "Nenhum resultado encontrado.", - "preferences_quality_dash_option_auto": "Automática", - "preferences_region_label": "País para o conteúdo: ", + "preferences_quality_dash_option_auto": "Automático", + "preferences_region_label": "País do conteúdo: ", "preferences_quality_dash_option_1440p": "1440p", "preferences_quality_dash_option_720p": "720p", - "preferences_watch_history_label": "Ativar histórico de visualizações ", + "preferences_watch_history_label": "Ativar histórico de reprodução: ", "preferences_quality_dash_option_best": "Melhor", "preferences_quality_dash_option_worst": "Pior", "preferences_quality_dash_option_144p": "144p", @@ -404,13 +404,13 @@ "preferences_quality_option_hd720": "HD720", "preferences_quality_option_dash": "DASH (qualidade adaptativa)", "preferences_quality_option_medium": "Média", - "preferences_quality_option_small": "Pequena", + "preferences_quality_option_small": "Baixa", "preferences_quality_dash_option_1080p": "1080p", "preferences_quality_dash_option_480p": "480p", "preferences_quality_dash_option_360p": "360p", "preferences_quality_dash_option_240p": "240p", - "Video unavailable": "Vídeo indisponível", - "Russian (auto-generated)": "Russo (geradas automaticamente)", + "Video unavailable": "Vídeo não disponível", + "Russian (auto-generated)": "Russo (gerado automaticamente)", "comments_view_x_replies": "Ver {{count}} resposta", "comments_view_x_replies_plural": "Ver {{count}} respostas", "comments_points_count": "{{count}} ponto", @@ -418,18 +418,18 @@ "English (United Kingdom)": "Inglês (Reino Unido)", "Chinese (Hong Kong)": "Chinês (Hong Kong)", "Chinese (Taiwan)": "Chinês (Taiwan)", - "Dutch (auto-generated)": "Holandês (geradas automaticamente)", - "French (auto-generated)": "Francês (geradas automaticamente)", - "German (auto-generated)": "Alemão (geradas automaticamente)", - "Indonesian (auto-generated)": "Indonésio (geradas automaticamente)", - "Interlingue": "Interlingue", - "Italian (auto-generated)": "Italiano (geradas automaticamente)", - "Japanese (auto-generated)": "Japonês (geradas automaticamente)", - "Korean (auto-generated)": "Coreano (geradas automaticamente)", - "Portuguese (auto-generated)": "Português (geradas automaticamente)", + "Dutch (auto-generated)": "Holandês (gerado automaticamente)", + "French (auto-generated)": "Francês (gerado automaticamente)", + "German (auto-generated)": "Alemão (gerado automaticamente)", + "Indonesian (auto-generated)": "Indonésio (gerado automaticamente)", + "Interlingue": "Interlíngua", + "Italian (auto-generated)": "Italiano (gerado automaticamente)", + "Japanese (auto-generated)": "Japonês (gerado automaticamente)", + "Korean (auto-generated)": "Coreano (gerado automaticamente)", + "Portuguese (auto-generated)": "Português (gerado automaticamente)", "Portuguese (Brazil)": "Português (Brasil)", "Spanish (Spain)": "Espanhol (Espanha)", - "Vietnamese (auto-generated)": "Vietnamita (geradas automaticamente)", + "Vietnamese (auto-generated)": "Vietnamita (gerado automaticamente)", "search_filters_type_option_all": "Qualquer tipo", "search_filters_duration_option_none": "Qualquer duração", "search_filters_duration_option_short": "Curto (< 4 minutos)", @@ -438,29 +438,39 @@ "search_filters_features_option_purchased": "Comprado", "search_filters_apply_button": "Aplicar filtros selecionados", "videoinfo_watch_on_youTube": "Ver no YouTube", - "videoinfo_youTube_embed_link": "Embutir", - "adminprefs_modified_source_code_url_label": "URL do repositório do código-fonte modificado", - "videoinfo_invidious_embed_link": "Ligação embutida", + "videoinfo_youTube_embed_link": "Incorporar", + "adminprefs_modified_source_code_url_label": "URL do repositório do código-fonte alterado", + "videoinfo_invidious_embed_link": "Incorporar hiperligação", "none": "nenhum", - "videoinfo_started_streaming_x_ago": "Entrou em direto há `x`", + "videoinfo_started_streaming_x_ago": "Iniciou a transmissão há `x`", "download_subtitles": "Legendas - `x` (.vtt)", "user_created_playlists": "`x` listas de reprodução criadas", "user_saved_playlists": "`x` listas de reprodução guardadas", - "preferences_save_player_pos_label": "Guardar posição de reprodução: ", - "Turkish (auto-generated)": "Turco (geradas automaticamente)", + "preferences_save_player_pos_label": "Guardar a posição de reprodução atual do vídeo: ", + "Turkish (auto-generated)": "Turco (gerado automaticamente)", "Cantonese (Hong Kong)": "Cantonês (Hong Kong)", "Chinese (China)": "Chinês (China)", - "Spanish (auto-generated)": "Espanhol (geradas automaticamente)", + "Spanish (auto-generated)": "Espanhol (gerado automaticamente)", "Spanish (Mexico)": "Espanhol (México)", "English (United States)": "Inglês (Estados Unidos)", "footer_donate_page": "Doar", "footer_documentation": "Documentação", "footer_source_code": "Código-fonte", "footer_original_source_code": "Código-fonte original", - "footer_modfied_source_code": "Código-fonte modificado", + "footer_modfied_source_code": "Código-fonte alterado", "Chinese": "Chinês", - "search_filters_date_label": "Data de carregamento", + "search_filters_date_label": "Data de publicação", "search_filters_date_option_none": "Qualquer data", "search_filters_features_option_three_sixty": "360°", - "search_filters_features_option_vr180": "VR180" + "search_filters_features_option_vr180": "VR180", + "search_message_use_another_instance": " Também pode pesquisar noutra instância.", + "crash_page_you_found_a_bug": "Parece que encontrou um erro no Invidious!", + "crash_page_before_reporting": "Antes de reportar um erro, verifique se:", + "crash_page_read_the_faq": "leia as Perguntas frequentes (FAQ)", + "crash_page_search_issue": "procurou se o erro já foi reportado no GitHub", + "crash_page_report_issue": "Se nenhuma opção acima ajudou, por favor abra um novo problema no Github (preferencialmente em inglês) e inclua o seguinte texto tal qual (NÃO o traduza):", + "search_message_change_filters_or_query": "Tente alargar os termos genéricos da pesquisa e/ou alterar os filtros.", + "crash_page_refresh": "tentou recarregar a página", + "crash_page_switch_instance": "tentou usar outra instância", + "error_video_not_in_playlist": "O vídeo pedido não existe nesta lista de reprodução. Clique aqui para a página inicial da lista de reprodução." } From 62b8f8ac80bfd4c58f8f746d3e50480536efa67d Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:11 +0100 Subject: [PATCH 57/73] Update Persian translation Co-authored-by: Hosted Weblate Co-authored-by: Parsa Abbasi --- locales/fa.json | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/locales/fa.json b/locales/fa.json index 5ea976f5..3a8f547f 100644 --- a/locales/fa.json +++ b/locales/fa.json @@ -411,5 +411,18 @@ "search_filters_duration_option_long": "بلند (> 20 دقیقه)", "adminprefs_modified_source_code_url_label": "URL مخزن کد منبع ویریش شده", "search_filters_duration_option_short": "کوتاه (< 4 دقیقه)", - "search_filters_title": "پالایه" + "search_filters_title": "پالایه", + "Chinese (Hong Kong)": "چینی (هنگ‌کنگ)", + "Dutch (auto-generated)": "هلندی (تولید خودکار)", + "preferences_watch_history_label": "فعال‌سازی تاریخچه‌ی پخش ", + "Indonesian (auto-generated)": "اندونزیایی (تولید خودکار)", + "English (United States)": "انگلیسی (ایالات متحده)", + "Chinese": "چینی", + "Chinese (Taiwan)": "چینی (تایوان)", + "French (auto-generated)": "فرانسوی (تولید خودکار)", + "English (United Kingdom)": "انگلیسی (ایالات بریتانیا)", + "search_message_no_results": "نتیجه‌ای یافت نشد.", + "search_message_change_filters_or_query": "سعی کنید جست‌و‌جوی خود را وسیع‌تر کنید و/یا فیلترها را تغییر دهید.", + "Chinese (China)": "چینی (چین)", + "German (auto-generated)": "آلمانی (تولید خودکار)" } From 7f0f40f81180bfa9a1c652c29c63d449151232c9 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 1 Jan 2023 19:42:11 +0100 Subject: [PATCH 58/73] Update Korean translation Co-authored-by: Hosted Weblate Co-authored-by: xrfmkrh --- locales/ko.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locales/ko.json b/locales/ko.json index 8d79c456..28b518a2 100644 --- a/locales/ko.json +++ b/locales/ko.json @@ -25,7 +25,7 @@ "preferences_quality_label": "선호하는 비디오 품질: ", "preferences_speed_label": "기본 속도: ", "preferences_local_label": "비디오를 프록시: ", - "preferences_listen_label": "라디오 모드 활성화: ", + "preferences_listen_label": "라디오 모드: ", "preferences_continue_autoplay_label": "다음 동영상 자동재생 ", "preferences_continue_label": "다음 동영상으로 이동: ", "preferences_autoplay_label": "자동재생: ", @@ -415,7 +415,7 @@ "Spanish (auto-generated)": "스페인어 (자동 생성됨)", "preferences_quality_dash_option_1080p": "1080p", "preferences_quality_dash_option_worst": "최저", - "preferences_watch_history_label": "시청 기록 활성화: ", + "preferences_watch_history_label": "시청 기록 저장: ", "invidious": "인비디어스", "preferences_quality_option_small": "낮음", "preferences_quality_dash_option_auto": "자동", @@ -439,7 +439,7 @@ "footer_donate_page": "기부하기", "preferences_quality_option_dash": "DASH (다양한 화질)", "preferences_quality_dash_option_360p": "360p", - "preferences_save_player_pos_label": "이어서 보기 활성화: ", + "preferences_save_player_pos_label": "이어서 보기: ", "none": "없음", "videoinfo_started_streaming_x_ago": "`x` 전에 스트리밍을 시작했습니다", "crash_page_you_found_a_bug": "Invidious에서 버그를 찾은 것 같습니다!", From ed8f02ef015f333d52b848632000d60e0e6fcf3d Mon Sep 17 00:00:00 2001 From: Brackets Date: Sat, 7 Jan 2023 18:31:42 +0100 Subject: [PATCH 59/73] Update default.css pointer on hover on label for descexpansionbutton --- assets/css/default.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/css/default.css b/assets/css/default.css index a61beaaf..80bf6a20 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -504,15 +504,15 @@ hr { height: 100%; } -#descexpansionbutton:hover { - cursor: pointer; -} - #descexpansionbutton ~ label { order: 1; margin-top: 20px; } +label[for="descexpansionbutton"]:hover { + cursor: pointer; +} + /* Bidi (bidirectional text) support */ h1, h2, From a37522a03dc12f61386fc0529a9136ad296b1228 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sun, 8 Jan 2023 13:50:52 +0100 Subject: [PATCH 60/73] Implement workaround for broken shorts objects --- src/invidious/channels/videos.cr | 30 ++++++++++++++++++++++---- src/invidious/exceptions.cr | 5 +++++ src/invidious/yt_backend/extractors.cr | 26 ++++++++++++---------- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/invidious/channels/videos.cr b/src/invidious/channels/videos.cr index bea406c1..befec03d 100644 --- a/src/invidious/channels/videos.cr +++ b/src/invidious/channels/videos.cr @@ -127,16 +127,38 @@ module Invidious::Channel::Tabs # Shorts # ------------------- - def get_shorts(channel : AboutChannel, continuation : String? = nil) + private def fetch_shorts_data(ucid : String, continuation : String? = nil) if continuation.nil? # EgZzaG9ydHPyBgUKA5oBAA%3D%3D is the protobuf object to load "shorts" # TODO: try to extract the continuation tokens that allows other sorting options - initial_data = YoutubeAPI.browse(channel.ucid, params: "EgZzaG9ydHPyBgUKA5oBAA%3D%3D") + return YoutubeAPI.browse(ucid, params: "EgZzaG9ydHPyBgUKA5oBAA%3D%3D") else - initial_data = YoutubeAPI.browse(continuation: continuation) + return YoutubeAPI.browse(continuation: continuation) end + end - return extract_items(initial_data, channel.author, channel.ucid) + def get_shorts(channel : AboutChannel, continuation : String? = nil) + initial_data = self.fetch_shorts_data(channel.ucid, continuation) + + begin + # Try to parse the initial data fetched above + return extract_items(initial_data, channel.author, channel.ucid) + rescue ex : RetryOnceException + # Sometimes, for a completely unknown reason, the "reelItemRenderer" + # object is missing some critical information (it happens once in about + # 20 subsequent requests). Refreshing the page is required to properly + # show the "shorts" tab. + # + # In order to make the experience smoother for the user, we simulate + # said page refresh by fetching again the JSON. If that still doesn't + # work, we raise a BrokenTubeException, as something is really broken. + begin + initial_data = self.fetch_shorts_data(channel.ucid, continuation) + return extract_items(initial_data, channel.author, channel.ucid) + rescue ex : RetryOnceException + raise BrokenTubeException.new "reelPlayerHeaderSupportedRenderers" + end + end end # ------------------- diff --git a/src/invidious/exceptions.cr b/src/invidious/exceptions.cr index 425c08da..690db907 100644 --- a/src/invidious/exceptions.cr +++ b/src/invidious/exceptions.cr @@ -33,3 +33,8 @@ end class VideoNotAvailableException < Exception end + +# Exception used to indicate that the JSON response from YT is missing +# some important informations, and that the query should be sent again. +class RetryOnceException < Exception +end diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index bca0dcbd..65d107b2 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -408,19 +408,23 @@ private module Parsers private def self.parse(item_contents, author_fallback) video_id = item_contents["videoId"].as_s - begin - video_details_container = item_contents.dig( - "navigationEndpoint", "reelWatchEndpoint", - "overlay", "reelPlayerOverlayRenderer", - "reelPlayerHeaderSupportedRenderers", - "reelPlayerHeaderRenderer" - ) - rescue ex : KeyError - # Extract key name from original message - key = /"([^"]+)"/.match(ex.message || "").try &.[1]? - raise BrokenTubeException.new(key || "reelPlayerOverlayRenderer") + reel_player_overlay = item_contents.dig( + "navigationEndpoint", "reelWatchEndpoint", + "overlay", "reelPlayerOverlayRenderer" + ) + + # Sometimes, the "reelPlayerOverlayRenderer" object is missing the + # important part of the response. We use this exception to tell + # the calling function to fetch the content again. + if !reel_player_overlay.as_h.has_key?("reelPlayerHeaderSupportedRenderers") + raise RetryOnceException.new end + video_details_container = reel_player_overlay.dig( + "reelPlayerHeaderSupportedRenderers", + "reelPlayerHeaderRenderer" + ) + # Author infos author = video_details_container From 692166bd644f9806ce474d099c90fef794f7dc43 Mon Sep 17 00:00:00 2001 From: marc <50554893+marcxm@users.noreply.github.com> Date: Mon, 9 Jan 2023 16:41:59 +0100 Subject: [PATCH 61/73] Update chart dependency for postgresql MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update Chart.yaml Set postgresql Chart version to 12.1.6. Bitnami deleted 11.1.3. * Force postgresql image tag version Co-authored-by: Émilien Devos --- kubernetes/Chart.yaml | 2 +- kubernetes/values.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/kubernetes/Chart.yaml b/kubernetes/Chart.yaml index ca44f4b7..4e4295ba 100644 --- a/kubernetes/Chart.yaml +++ b/kubernetes/Chart.yaml @@ -17,6 +17,6 @@ maintainers: email: mail@leonklingele.de dependencies: - name: postgresql - version: ~11.1.3 + version: ~12.1.6 repository: "https://charts.bitnami.com/bitnami/" engine: gotpl diff --git a/kubernetes/values.yaml b/kubernetes/values.yaml index 7f371f72..5000c2b6 100644 --- a/kubernetes/values.yaml +++ b/kubernetes/values.yaml @@ -34,6 +34,8 @@ securityContext: # See https://github.com/bitnami/charts/tree/master/bitnami/postgresql postgresql: + image: + tag: 13 auth: username: kemal password: kemal From 1fb0a495925a60b2d4839b98440e220b7f95d10e Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Fri, 13 Jan 2023 12:05:01 -0500 Subject: [PATCH 62/73] Make DASH absolute urls when local --- src/invidious/routes/api/manifest.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/routes/api/manifest.cr b/src/invidious/routes/api/manifest.cr index ae65f10d..f5d8e5de 100644 --- a/src/invidious/routes/api/manifest.cr +++ b/src/invidious/routes/api/manifest.cr @@ -42,7 +42,7 @@ module Invidious::Routes::API::Manifest if local adaptive_fmts.each do |fmt| - fmt["url"] = JSON::Any.new(URI.parse(fmt["url"].as_s).request_target) + fmt["url"] = JSON::Any.new("#{HOST_URL}#{URI.parse(fmt["url"].as_s).request_target}") end end From 04b97ec261091c8f4f0816335a4b198ffc5efb9e Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sat, 14 Jan 2023 19:56:15 +0100 Subject: [PATCH 63/73] make shell scripts executable (chmod 755) --- scripts/deploy-database.sh | 0 scripts/fetch-player-dependencies.cr | 0 scripts/install-dependencies.sh | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/deploy-database.sh mode change 100644 => 100755 scripts/fetch-player-dependencies.cr mode change 100644 => 100755 scripts/install-dependencies.sh diff --git a/scripts/deploy-database.sh b/scripts/deploy-database.sh old mode 100644 new mode 100755 diff --git a/scripts/fetch-player-dependencies.cr b/scripts/fetch-player-dependencies.cr old mode 100644 new mode 100755 diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh old mode 100644 new mode 100755 From 4ee483282e072473b618df1ce9a96668c2905cf5 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sat, 14 Jan 2023 20:00:46 +0100 Subject: [PATCH 64/73] Video proxy: always include the 'range' header --- src/invidious/routes/video_playback.cr | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/invidious/routes/video_playback.cr b/src/invidious/routes/video_playback.cr index 560f9c19..a0216cce 100644 --- a/src/invidious/routes/video_playback.cr +++ b/src/invidious/routes/video_playback.cr @@ -35,6 +35,13 @@ module Invidious::Routes::VideoPlayback end end + # See: https://github.com/iv-org/invidious/issues/3302 + range_header = env.request.headers["Range"]? + if range_header.nil? + range_for_head = query_params["range"]? || "0-640" + headers["Range"] = "bytes=#{range_for_head}" + end + client = make_client(URI.parse(host), region) response = HTTP::Client::Response.new(500) error = "" @@ -70,6 +77,9 @@ module Invidious::Routes::VideoPlayback end end + # Remove the Range header added previously. + headers.delete("Range") if range_header.nil? + if response.status_code >= 400 env.response.content_type = "text/plain" haltf env, response.status_code From d6087fac472711376762cfb2c5f7672f84f6d4fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Devos?= Date: Sun, 15 Jan 2023 12:07:58 +0000 Subject: [PATCH 65/73] Don't continue when LOGIN_REQUIRED and no videoDetails --- src/invidious/videos/parser.cr | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr index 5df49286..5c323975 100644 --- a/src/invidious/videos/parser.cr +++ b/src/invidious/videos/parser.cr @@ -66,8 +66,10 @@ def extract_video_info(video_id : String, proxy_region : String? = nil) reason ||= subreason.try &.[]("runs").as_a.map(&.[]("text")).join("") reason ||= player_response.dig("playabilityStatus", "reason").as_s - # Stop here if video is not a scheduled livestream - if !{"LIVE_STREAM_OFFLINE", "LOGIN_REQUIRED"}.any?(playability_status) + # Stop here if video is not a scheduled livestream or + # for LOGIN_REQUIRED when videoDetails element is not found because retrying won't help + if !{"LIVE_STREAM_OFFLINE", "LOGIN_REQUIRED"}.any?(playability_status) || + playability_status == "LOGIN_REQUIRED" && !player_response.dig?("videoDetails") return { "version" => JSON::Any.new(Video::SCHEMA_VERSION.to_i64), "reason" => JSON::Any.new(reason), From 1af846e58c3df98a589fe8fdda3e45f2745e69bc Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sun, 15 Jan 2023 17:04:04 +0100 Subject: [PATCH 66/73] API: make /api/v1/videos respect the 'local' parameter --- src/invidious.cr | 1 + src/invidious/http_server/utils.cr | 20 ++++++++++++++++++++ src/invidious/jsonify/api_v1/video_json.cr | 11 +++++++++-- src/invidious/routes/api/v1/videos.cr | 5 ++++- src/invidious/routes/video_playback.cr | 10 ++-------- 5 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 src/invidious/http_server/utils.cr diff --git a/src/invidious.cr b/src/invidious.cr index 5064f0b8..d4f8e0fb 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -34,6 +34,7 @@ require "protodec/utils" require "./invidious/database/*" require "./invidious/database/migrations/*" +require "./invidious/http_server/*" require "./invidious/helpers/*" require "./invidious/yt_backend/*" require "./invidious/frontend/*" diff --git a/src/invidious/http_server/utils.cr b/src/invidious/http_server/utils.cr new file mode 100644 index 00000000..e3f1fa0f --- /dev/null +++ b/src/invidious/http_server/utils.cr @@ -0,0 +1,20 @@ +module Invidious::HttpServer + module Utils + extend self + + def proxy_video_url(raw_url : String, *, region : String? = nil, absolute : Bool = false) + url = URI.parse(raw_url) + + # Add some URL parameters + params = url.query_params + params["host"] = url.host.not_nil! # Should never be nil, in theory + params["region"] = region if !region.nil? + + if absolute + return "#{HOST_URL}#{url.request_target}?#{params}" + else + return "#{url.request_target}?#{params}" + end + end + end +end diff --git a/src/invidious/jsonify/api_v1/video_json.cr b/src/invidious/jsonify/api_v1/video_json.cr index 642789aa..a2b1a35c 100644 --- a/src/invidious/jsonify/api_v1/video_json.cr +++ b/src/invidious/jsonify/api_v1/video_json.cr @@ -3,7 +3,7 @@ require "json" module Invidious::JSONify::APIv1 extend self - def video(video : Video, json : JSON::Builder, *, locale : String?) + def video(video : Video, json : JSON::Builder, *, locale : String?, proxy : Bool = false) json.object do json.field "type", video.video_type @@ -89,7 +89,14 @@ module Invidious::JSONify::APIv1 # Not available on MPEG-4 Timed Text (`text/mp4`) streams (livestreams only) json.field "bitrate", fmt["bitrate"].as_i.to_s if fmt["bitrate"]? - json.field "url", fmt["url"] + if proxy + json.field "url", Invidious::HttpServer::Utils.proxy_video_url( + fmt["url"].to_s, absolute: true + ) + else + json.field "url", fmt["url"] + end + json.field "itag", fmt["itag"].as_i.to_s json.field "type", fmt["mimeType"] json.field "clen", fmt["contentLength"]? || "-1" diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr index a6b2eb4e..79f7bd3f 100644 --- a/src/invidious/routes/api/v1/videos.cr +++ b/src/invidious/routes/api/v1/videos.cr @@ -6,6 +6,7 @@ module Invidious::Routes::API::V1::Videos id = env.params.url["id"] region = env.params.query["region"]? + proxy = {"1", "true"}.any? &.== env.params.query["local"]? begin video = get_video(id, region: region) @@ -15,7 +16,9 @@ module Invidious::Routes::API::V1::Videos return error_json(500, ex) end - video.to_json(locale, nil) + return JSON.build do |json| + Invidious::JSONify::APIv1.video(video, json, locale: locale, proxy: proxy) + end end def self.captions(env) diff --git a/src/invidious/routes/video_playback.cr b/src/invidious/routes/video_playback.cr index 560f9c19..04b13630 100644 --- a/src/invidious/routes/video_playback.cr +++ b/src/invidious/routes/video_playback.cr @@ -91,14 +91,8 @@ module Invidious::Routes::VideoPlayback env.response.headers["Access-Control-Allow-Origin"] = "*" if location = resp.headers["Location"]? - location = URI.parse(location) - location = "#{location.request_target}&host=#{location.host}" - - if region - location += "®ion=#{region}" - end - - return env.redirect location + url = Invidious::HttpServer::Utils.proxy_video_url(location, region: region) + return env.redirect url end IO.copy(resp.body_io, env.response) From aacf83c06ee5d4f5b940dcd9510613afaf56696b Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sun, 15 Jan 2023 18:15:31 +0100 Subject: [PATCH 67/73] locales: Update translation keys for Videos/Community tabs --- locales/ar.json | 4 ++-- locales/ca.json | 2 +- locales/cs.json | 4 ++-- locales/da.json | 4 ++-- locales/de.json | 4 ++-- locales/el.json | 4 ++-- locales/eo.json | 4 ++-- locales/es.json | 4 ++-- locales/et.json | 4 ++-- locales/fa.json | 4 ++-- locales/fi.json | 4 ++-- locales/fr.json | 4 ++-- locales/he.json | 4 ++-- locales/hi.json | 4 ++-- locales/hr.json | 4 ++-- locales/hu-HU.json | 4 ++-- locales/id.json | 4 ++-- locales/is.json | 4 ++-- locales/it.json | 4 ++-- locales/ja.json | 4 ++-- locales/ko.json | 4 ++-- locales/lt.json | 4 ++-- locales/nb-NO.json | 4 ++-- locales/nl.json | 4 ++-- locales/pl.json | 4 ++-- locales/pt-BR.json | 4 ++-- locales/pt-PT.json | 4 ++-- locales/pt.json | 4 ++-- locales/ro.json | 4 ++-- locales/ru.json | 4 ++-- locales/sl.json | 4 ++-- locales/sq.json | 4 ++-- locales/sr.json | 4 ++-- locales/sr_Cyrl.json | 4 ++-- locales/sv-SE.json | 4 ++-- locales/tr.json | 4 ++-- locales/uk.json | 4 ++-- locales/vi.json | 4 ++-- locales/zh-CN.json | 4 ++-- locales/zh-TW.json | 4 ++-- 40 files changed, 79 insertions(+), 79 deletions(-) diff --git a/locales/ar.json b/locales/ar.json index 2a746e5d..e31a0e28 100644 --- a/locales/ar.json +++ b/locales/ar.json @@ -325,9 +325,9 @@ "`x` marked it with a ❤": "`x` أعجب بهذا", "Audio mode": "الوضع الصوتي", "Video mode": "وضع الفيديو", - "Videos": "الفيديوهات", + "channel_tab_videos_label": "الفيديوهات", "Playlists": "قوائم التشغيل", - "Community": "المجتمع", + "channel_tab_community_label": "المجتمع", "search_filters_sort_option_relevance": "ملائمة", "search_filters_sort_option_rating": "تقييم", "search_filters_sort_option_date": "التاريخ", diff --git a/locales/ca.json b/locales/ca.json index 741414d2..2ba6ae39 100644 --- a/locales/ca.json +++ b/locales/ca.json @@ -51,7 +51,7 @@ "Movies": "Películes", "Download": "Descarrega", "Download as: ": "Descarrega com: ", - "Videos": "Vídeos", + "channel_tab_videos_label": "Vídeos", "search_filters_type_label": "Tipus", "search_filters_duration_label": "Duració", "search_filters_sort_label": "Ordena per", diff --git a/locales/cs.json b/locales/cs.json index 7538365a..466a3058 100644 --- a/locales/cs.json +++ b/locales/cs.json @@ -260,8 +260,8 @@ "`x` marked it with a ❤": "`x` to označil(a) se ❤", "Audio mode": "Audiový režim", "Video mode": "Videový režim", - "Videos": "Videa", - "Community": "Komunita", + "channel_tab_videos_label": "Videa", + "channel_tab_community_label": "Komunita", "search_filters_sort_option_rating": "Hodnocení", "search_filters_sort_option_date": "Datum nahrání", "search_filters_sort_option_views": "Počet zhlédnutí", diff --git a/locales/da.json b/locales/da.json index 4816c2c9..2bee6c80 100644 --- a/locales/da.json +++ b/locales/da.json @@ -187,7 +187,7 @@ "Esperanto": "Esperanto", "Czech": "Tjekkisk", "Danish": "Dansk", - "Community": "Samfund", + "channel_tab_community_label": "Samfund", "Afrikaans": "Afrikansk", "Portuguese": "Portugisisk", "Ukrainian": "Ukrainsk", @@ -267,7 +267,7 @@ "search_filters_sort_option_rating": "Bedømmelse", "Yoruba": "Yoruba", "Erroneous token": "Fejlagtig token", - "Videos": "Videoer", + "channel_tab_videos_label": "Videoer", "search_filters_type_option_show": "Vis", "Luxembourgish": "Luxemboursk", "Vietnamese": "Vietnamesisk", diff --git a/locales/de.json b/locales/de.json index a2070cf5..55c40905 100644 --- a/locales/de.json +++ b/locales/de.json @@ -325,9 +325,9 @@ "`x` marked it with a ❤": "`x` markierte es mit einem ❤", "Audio mode": "Audiomodus", "Video mode": "Videomodus", - "Videos": "Videos", + "channel_tab_videos_label": "Videos", "Playlists": "Wiedergabelisten", - "Community": "Gemeinschaft", + "channel_tab_community_label": "Gemeinschaft", "search_filters_sort_option_relevance": "Relevanz", "search_filters_sort_option_rating": "Bewertung", "search_filters_sort_option_date": "Datum", diff --git a/locales/el.json b/locales/el.json index d91d64fc..3448a4dc 100644 --- a/locales/el.json +++ b/locales/el.json @@ -315,9 +315,9 @@ "`x` marked it with a ❤": "Ο χρηστης `x` έβαλε ❤", "Audio mode": "Λειτουργία ήχου", "Video mode": "Λειτουργία βίντεο", - "Videos": "Βίντεο", + "channel_tab_videos_label": "Βίντεο", "Playlists": "Λίστες Αναπαραγωγής", - "Community": "Κοινότητα", + "channel_tab_community_label": "Κοινότητα", "Current version: ": "Τρέχουσα έκδοση: ", "generic_playlists_count": "{{count}} λίστα αναπαραγωγής", "generic_playlists_count_plural": "{{count}} λίστες αναπαραγωγής", diff --git a/locales/eo.json b/locales/eo.json index 5aa2bbc6..1a5d9938 100644 --- a/locales/eo.json +++ b/locales/eo.json @@ -325,9 +325,9 @@ "`x` marked it with a ❤": "`x` markis ĝin per ❤", "Audio mode": "Aŭda reĝimo", "Video mode": "Videa reĝimo", - "Videos": "Filmetoj", + "channel_tab_videos_label": "Filmetoj", "Playlists": "Ludlistoj", - "Community": "Komunumo", + "channel_tab_community_label": "Komunumo", "search_filters_sort_option_relevance": "rilateco", "search_filters_sort_option_rating": "takso", "search_filters_sort_option_date": "dato", diff --git a/locales/es.json b/locales/es.json index 8603e9fe..dc63619e 100644 --- a/locales/es.json +++ b/locales/es.json @@ -325,9 +325,9 @@ "`x` marked it with a ❤": "`x` lo ha marcado con un ❤", "Audio mode": "Modo de audio", "Video mode": "Modo de vídeo", - "Videos": "Vídeos", + "channel_tab_videos_label": "Vídeos", "Playlists": "Listas de reproducción", - "Community": "Comunidad", + "channel_tab_community_label": "Comunidad", "search_filters_sort_option_relevance": "relevancia", "search_filters_sort_option_rating": "valoración", "search_filters_sort_option_date": "fecha", diff --git a/locales/et.json b/locales/et.json index 7beb1749..74338aba 100644 --- a/locales/et.json +++ b/locales/et.json @@ -296,8 +296,8 @@ "Corsican": "Korsika", "Javanese": "Jaava", "Lithuanian": "Leedu", - "Videos": "Videod", - "Community": "Kogukond", + "channel_tab_videos_label": "Videod", + "channel_tab_community_label": "Kogukond", "CAPTCHA is a required field": "CAPTCHA on kohustuslik väli", "comments_points_count": "{{count}} punkt", "comments_points_count_plural": "{{count}} punkti", diff --git a/locales/fa.json b/locales/fa.json index 3a8f547f..f2ca2745 100644 --- a/locales/fa.json +++ b/locales/fa.json @@ -341,9 +341,9 @@ "`x` marked it with a ❤": "`x` نشان گذاری شده با یک ❤", "Audio mode": "حالت صدا", "Video mode": "حالت ویدیو", - "Videos": "ویدیو ها", + "channel_tab_videos_label": "ویدیو ها", "Playlists": "سیاهه‌های پخش", - "Community": "اجتماع", + "channel_tab_community_label": "اجتماع", "search_filters_sort_option_relevance": "مرتبط بودن", "search_filters_sort_option_rating": "امتیاز", "search_filters_sort_option_date": "تاریخ بارگذاری", diff --git a/locales/fi.json b/locales/fi.json index bef9027f..366a2739 100644 --- a/locales/fi.json +++ b/locales/fi.json @@ -324,9 +324,9 @@ "`x` marked it with a ❤": "`x` merkkasi ❤:llä", "Audio mode": "Äänitila", "Video mode": "Videotila", - "Videos": "Videot", + "channel_tab_videos_label": "Videot", "Playlists": "Soittolistat", - "Community": "Yhteisö", + "channel_tab_community_label": "Yhteisö", "search_filters_sort_option_relevance": "Osuvuus", "search_filters_sort_option_rating": "Arvostelu", "search_filters_sort_option_date": "Latauspäivämäärä", diff --git a/locales/fr.json b/locales/fr.json index 2f384eb1..59a960d0 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -358,9 +358,9 @@ "`x` marked it with a ❤": "`x` l'a marqué d'un ❤", "Audio mode": "Mode audio", "Video mode": "Mode vidéo", - "Videos": "Vidéos", + "channel_tab_videos_label": "Vidéos", "Playlists": "Listes de lecture", - "Community": "Communauté", + "channel_tab_community_label": "Communauté", "search_filters_sort_option_relevance": "Pertinence", "search_filters_sort_option_rating": "Notation", "search_filters_sort_option_date": "Date d'ajout", diff --git a/locales/he.json b/locales/he.json index 384b2657..ab42313b 100644 --- a/locales/he.json +++ b/locales/he.json @@ -271,9 +271,9 @@ "`x` marked it with a ❤": "סומנה ב־❤ על ידי `x`", "Audio mode": "Audio mode", "Video mode": "Video mode", - "Videos": "סרטונים", + "channel_tab_videos_label": "סרטונים", "Playlists": "פלייליסטים", - "Community": "קהילה", + "channel_tab_community_label": "קהילה", "search_filters_sort_option_relevance": "רלוונטיות", "search_filters_sort_option_rating": "דירוג", "search_filters_sort_option_date": "תאריך העלאה", diff --git a/locales/hi.json b/locales/hi.json index 32ae7823..e576080f 100644 --- a/locales/hi.json +++ b/locales/hi.json @@ -401,12 +401,12 @@ "(edited)": "(संपादित)", "YouTube comment permalink": "YouTube पर टिप्पणी की स्थायी कड़ी", "permalink": "स्थायी कड़ी", - "Videos": "वीडियो", + "channel_tab_videos_label": "वीडियो", "`x` marked it with a ❤": "`x` ने इसे एक ❤ से चिह्नित किया", "Audio mode": "ऑडियो मोड", "Playlists": "प्लेलिस्ट्स", "Video mode": "वीडियो मोड", - "Community": "समुदाय", + "channel_tab_community_label": "समुदाय", "search_filters_title": "फ़िल्टर", "search_filters_date_label": "अपलोड करने का समय", "search_filters_date_option_none": "कोई भी समय", diff --git a/locales/hr.json b/locales/hr.json index e42cc4f5..c8414322 100644 --- a/locales/hr.json +++ b/locales/hr.json @@ -325,9 +325,9 @@ "`x` marked it with a ❤": "Označeno sa ❤ od `x`", "Audio mode": "Audio modus", "Video mode": "Videomodus", - "Videos": "Videa", + "channel_tab_videos_label": "Videa", "Playlists": "Zbirke", - "Community": "Zajednica", + "channel_tab_community_label": "Zajednica", "search_filters_sort_option_relevance": "Značaj", "search_filters_sort_option_rating": "Ocjena", "search_filters_sort_option_date": "Datum prijenosa", diff --git a/locales/hu-HU.json b/locales/hu-HU.json index 19ada1d8..f93930e0 100644 --- a/locales/hu-HU.json +++ b/locales/hu-HU.json @@ -348,9 +348,9 @@ "`x` marked it with a ❤": "`x` ❤ jelet adott a hozzászóláshoz", "Audio mode": "Csak hanggal", "Video mode": "Hanggal és képpel", - "Videos": "Videói", + "channel_tab_videos_label": "Videói", "Playlists": "Lejátszási listái", - "Community": "Közösség", + "channel_tab_community_label": "Közösség", "Current version: ": "Jelenlegi verzió: ", "preferences_quality_option_medium": "Közepes", "preferences_quality_dash_option_auto": "Automatikus", diff --git a/locales/id.json b/locales/id.json index a30f0ad4..51d6d55c 100644 --- a/locales/id.json +++ b/locales/id.json @@ -341,9 +341,9 @@ "`x` marked it with a ❤": "`x` telah ditandai dengan ❤", "Audio mode": "Mode audio", "Video mode": "Mode video", - "Videos": "Video", + "channel_tab_videos_label": "Video", "Playlists": "Daftar putar", - "Community": "Komunitas", + "channel_tab_community_label": "Komunitas", "search_filters_sort_option_relevance": "Relevansi", "search_filters_sort_option_rating": "Penilaian", "search_filters_sort_option_date": "Tanggal Unggah", diff --git a/locales/is.json b/locales/is.json index 99bd6574..3282eb50 100644 --- a/locales/is.json +++ b/locales/is.json @@ -315,9 +315,9 @@ "`x` marked it with a ❤": "`x` merkti það með ❤", "Audio mode": "Hljóð ham", "Video mode": "Myndband ham", - "Videos": "Myndbönd", + "channel_tab_videos_label": "Myndbönd", "Playlists": "Spilunarlistar", - "Community": "Samfélag", + "channel_tab_community_label": "Samfélag", "Current version: ": "Núverandi útgáfa: ", "preferences_watch_history_label": "Virkja áhorfssögu: " } diff --git a/locales/it.json b/locales/it.json index c195f3b9..1a0d8efc 100644 --- a/locales/it.json +++ b/locales/it.json @@ -344,9 +344,9 @@ "`x` marked it with a ❤": "`x` l'ha contrassegnato con un ❤", "Audio mode": "Modalità audio", "Video mode": "Modalità video", - "Videos": "Video", + "channel_tab_videos_label": "Video", "Playlists": "Playlist", - "Community": "Comunità", + "channel_tab_community_label": "Comunità", "search_filters_sort_option_relevance": "Pertinenza", "search_filters_sort_option_rating": "Valutazione", "search_filters_sort_option_date": "Data di caricamento", diff --git a/locales/ja.json b/locales/ja.json index 4971c472..a392abfe 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -341,9 +341,9 @@ "`x` marked it with a ❤": "`x` が❤を込めてマークしました", "Audio mode": "オーディオモード", "Video mode": "ビデオモード", - "Videos": "動画", + "channel_tab_videos_label": "動画", "Playlists": "プレイリスト", - "Community": "コミュニティ", + "channel_tab_community_label": "コミュニティ", "search_filters_sort_option_relevance": "関連", "search_filters_sort_option_rating": "評価", "search_filters_sort_option_date": "時刻", diff --git a/locales/ko.json b/locales/ko.json index 28b518a2..ff6db61a 100644 --- a/locales/ko.json +++ b/locales/ko.json @@ -347,8 +347,8 @@ "search_filters_sort_option_date": "업로드 날짜", "search_filters_sort_option_rating": "평점", "search_filters_sort_option_relevance": "관련성", - "Community": "커뮤니티", - "Videos": "동영상", + "channel_tab_community_label": "커뮤니티", + "channel_tab_videos_label": "동영상", "Video mode": "비디오 모드", "Audio mode": "오디오 모드", "permalink": "퍼머링크", diff --git a/locales/lt.json b/locales/lt.json index 35ababee..9bfcfdba 100644 --- a/locales/lt.json +++ b/locales/lt.json @@ -325,9 +325,9 @@ "`x` marked it with a ❤": "`x` pažymėjo tai su ❤", "Audio mode": "Garso rėžimas", "Video mode": "Vaizdo rėžimas", - "Videos": "Vaizdo įrašai", + "channel_tab_videos_label": "Vaizdo įrašai", "Playlists": "Grojaraiščiai", - "Community": "Bendruomenė", + "channel_tab_community_label": "Bendruomenė", "search_filters_sort_option_relevance": "Aktualumas", "search_filters_sort_option_rating": "Reitingas", "search_filters_sort_option_date": "Įkėlimo data", diff --git a/locales/nb-NO.json b/locales/nb-NO.json index f4c2021b..d29cca43 100644 --- a/locales/nb-NO.json +++ b/locales/nb-NO.json @@ -325,9 +325,9 @@ "`x` marked it with a ❤": "`x` levnet et ❤", "Audio mode": "Lydmodus", "Video mode": "Video-modus", - "Videos": "Videoer", + "channel_tab_videos_label": "Videoer", "Playlists": "Spillelister", - "Community": "Gemenskap", + "channel_tab_community_label": "Gemenskap", "search_filters_sort_option_relevance": "relevans", "search_filters_sort_option_rating": "vurdering", "search_filters_sort_option_date": "dato", diff --git a/locales/nl.json b/locales/nl.json index 17057553..dfc68671 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -320,9 +320,9 @@ "`x` marked it with a ❤": "`x` heeft dit gemarkeerd met ❤", "Audio mode": "Audiomodus", "Video mode": "Videomodus", - "Videos": "Video's", + "channel_tab_videos_label": "Video's", "Playlists": "Afspeellijsten", - "Community": "Gemeenschap", + "channel_tab_community_label": "Gemeenschap", "search_filters_sort_option_relevance": "relevantie", "search_filters_sort_option_rating": "beoordeling", "search_filters_sort_option_date": "datum", diff --git a/locales/pl.json b/locales/pl.json index f1a07490..6c642475 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -324,9 +324,9 @@ "`x` marked it with a ❤": "`x` oznaczonych ❤", "Audio mode": "Tryb audio", "Video mode": "Tryb wideo", - "Videos": "Filmy", + "channel_tab_videos_label": "Filmy", "Playlists": "Playlisty", - "Community": "Społeczność", + "channel_tab_community_label": "Społeczność", "search_filters_sort_option_relevance": "Trafność", "search_filters_sort_option_rating": "Ocena", "search_filters_sort_option_date": "Data przesłania", diff --git a/locales/pt-BR.json b/locales/pt-BR.json index 41b457bb..112ed4b7 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -341,9 +341,9 @@ "`x` marked it with a ❤": "`x` foi marcado como ❤", "Audio mode": "Modo de áudio", "Video mode": "Modo de vídeo", - "Videos": "Vídeos", + "channel_tab_videos_label": "Vídeos", "Playlists": "Listas de reprodução", - "Community": "Comunidade", + "channel_tab_community_label": "Comunidade", "search_filters_sort_option_relevance": "relevância", "search_filters_sort_option_rating": "avaliação", "search_filters_sort_option_date": "data", diff --git a/locales/pt-PT.json b/locales/pt-PT.json index 1bee2807..1788deb1 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -341,9 +341,9 @@ "`x` marked it with a ❤": "`x` foi marcado como ❤", "Audio mode": "Modo de áudio", "Video mode": "Modo de vídeo", - "Videos": "Vídeos", + "channel_tab_videos_label": "Vídeos", "Playlists": "Listas de reprodução", - "Community": "Comunidade", + "channel_tab_community_label": "Comunidade", "search_filters_sort_option_relevance": "Relevância", "search_filters_sort_option_rating": "Avaliação", "search_filters_sort_option_date": "Data de envio", diff --git a/locales/pt.json b/locales/pt.json index b550bc87..2facba94 100644 --- a/locales/pt.json +++ b/locales/pt.json @@ -267,9 +267,9 @@ "Next page": "Próxima página", "last": "últimos", "Current version: ": "Versão atual: ", - "Community": "Comunidade", + "channel_tab_community_label": "Comunidade", "Playlists": "Listas de reprodução", - "Videos": "Vídeos", + "channel_tab_videos_label": "Vídeos", "Video mode": "Modo de vídeo", "Audio mode": "Modo de áudio", "`x` marked it with a ❤": "`x` foi marcado como ❤", diff --git a/locales/ro.json b/locales/ro.json index 342f5f37..0f6407d6 100644 --- a/locales/ro.json +++ b/locales/ro.json @@ -315,9 +315,9 @@ "`x` marked it with a ❤": "`x` l-a marcat cu o ❤", "Audio mode": "Mod audio", "Video mode": "Mod video", - "Videos": "Videoclipuri", + "channel_tab_videos_label": "Videoclipuri", "Playlists": "Liste de redare", - "Community": "Comunitate", + "channel_tab_community_label": "Comunitate", "Current version: ": "Versiunea actuală: ", "crash_page_read_the_faq": "citit lista Întrebărilor Frecvente (FAQ)", "generic_count_days_0": "{{count}} zi", diff --git a/locales/ru.json b/locales/ru.json index 93c9cbec..e54937a6 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -325,9 +325,9 @@ "`x` marked it with a ❤": "❤ от автора канала \"`x`\"", "Audio mode": "Аудио режим", "Video mode": "Видео режим", - "Videos": "Видео", + "channel_tab_videos_label": "Видео", "Playlists": "Плейлисты", - "Community": "Сообщество", + "channel_tab_community_label": "Сообщество", "search_filters_sort_option_relevance": "по актуальности", "search_filters_sort_option_rating": "по рейтингу", "search_filters_sort_option_date": "по дате загрузки", diff --git a/locales/sl.json b/locales/sl.json index 5994ca1a..f27bb20d 100644 --- a/locales/sl.json +++ b/locales/sl.json @@ -222,7 +222,7 @@ "About": "O aplikaciji", "%A %B %-d, %Y": "%A %-d %B %Y", "Audio mode": "Avdio način", - "Videos": "Videoposnetki", + "channel_tab_videos_label": "Videoposnetki", "search_filters_date_label": "Datum nalaganja", "search_filters_date_option_today": "Danes", "search_filters_date_option_week": "Ta teden", @@ -455,7 +455,7 @@ "Download": "Prenesi", "permalink": "stalna povezava", "`x` marked it with a ❤": "`x` ga je označil/a z ❤", - "Community": "Skupnost", + "channel_tab_community_label": "Skupnost", "search_filters_features_option_three_sixty": "360°", "Video mode": "Video način", "search_filters_features_option_c_commons": "Creative Commons", diff --git a/locales/sq.json b/locales/sq.json index 76dfd1b7..b8651316 100644 --- a/locales/sq.json +++ b/locales/sq.json @@ -259,10 +259,10 @@ "YouTube comment permalink": "Permalidhje komenti YouTube", "Audio mode": "Mënyrë për audion", "Playlists": "Luajlista", - "Community": "Bashkësi", + "channel_tab_community_label": "Bashkësi", "search_filters_sort_option_relevance": "Rëndësi", "Video mode": "Mënyrë video", - "Videos": "Video", + "channel_tab_videos_label": "Video", "search_filters_sort_option_rating": "Vlerësim", "search_filters_sort_option_date": "Datë ngarkimi", "search_filters_sort_option_views": "Numër parjesh", diff --git a/locales/sr.json b/locales/sr.json index d2f990ae..fd19c493 100644 --- a/locales/sr.json +++ b/locales/sr.json @@ -257,7 +257,7 @@ "preferences_volume_label": "Jačina zvuka: ", "preferences_locale_label": "Jezik: ", "adminprefs_modified_source_code_url_label": "URL veza do skladišta sa Izmenjenom Izvornom Kodom", - "Community": "Zajednica", + "channel_tab_community_label": "Zajednica", "Video mode": "Video mod", "Fallback captions: ": "Titl u slučaju da glavni nije dostupan: ", "Private": "Privatno", @@ -289,7 +289,7 @@ "Erroneous token": "Pogrešan žeton", "Czech": "Češki", "Latin": "Latinski", - "Videos": "Video klipovi", + "channel_tab_videos_label": "Video klipovi", "search_filters_features_option_four_k": "4К", "footer_donate_page": "Doniraj", "English": "Engleski", diff --git a/locales/sr_Cyrl.json b/locales/sr_Cyrl.json index c0f1224f..bef9915d 100644 --- a/locales/sr_Cyrl.json +++ b/locales/sr_Cyrl.json @@ -245,7 +245,7 @@ "(edited)": "(измењено)", "`x` marked it with a ❤": "`x` је означио/ла ово са ❤", "Audio mode": "Аудио мод", - "Videos": "Видео клипови", + "channel_tab_videos_label": "Видео клипови", "search_filters_sort_option_views": "Број прегледа", "search_filters_features_label": "Карактеристике", "search_filters_date_option_today": "Данас", @@ -298,7 +298,7 @@ "Ukrainian": "Украјински", "permalink": "трајна веза", "Pashto": "Паштунски", - "Community": "Заједница", + "channel_tab_community_label": "Заједница", "Sindhi": "Синди", "Could not fetch comments": "Узимање коментара није успело", "Bangla": "Бангла/Бенгалски", diff --git a/locales/sv-SE.json b/locales/sv-SE.json index 777899d0..39e94fd3 100644 --- a/locales/sv-SE.json +++ b/locales/sv-SE.json @@ -323,9 +323,9 @@ "`x` marked it with a ❤": "`x` lämnade ett ❤", "Audio mode": "Ljudläge", "Video mode": "Videoläge", - "Videos": "Videor", + "channel_tab_videos_label": "Videor", "Playlists": "Spellistor", - "Community": "Gemenskap", + "channel_tab_community_label": "Gemenskap", "search_filters_sort_option_relevance": "Relevans", "search_filters_sort_option_rating": "Rankning", "search_filters_sort_option_date": "Datum", diff --git a/locales/tr.json b/locales/tr.json index 17db1cf1..7dc256a9 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -325,9 +325,9 @@ "`x` marked it with a ❤": "`x` ❤ İle İşaretledi", "Audio mode": "Ses Modu", "Video mode": "Video Modu", - "Videos": "Videolar", + "channel_tab_videos_label": "Videolar", "Playlists": "Oynatma Listeleri", - "Community": "Topluluk", + "channel_tab_community_label": "Topluluk", "search_filters_sort_option_relevance": "İlgi", "search_filters_sort_option_rating": "Değerlendirme", "search_filters_sort_option_date": "Yükleme Tarihi", diff --git a/locales/uk.json b/locales/uk.json index b6994c56..d063799e 100644 --- a/locales/uk.json +++ b/locales/uk.json @@ -315,9 +315,9 @@ "`x` marked it with a ❤": "❤ цьому від каналу `x`", "Audio mode": "Аудіорежим", "Video mode": "Відеорежим", - "Videos": "Відео", + "channel_tab_videos_label": "Відео", "Playlists": "Плейлисти", - "Community": "Спільнота", + "channel_tab_community_label": "Спільнота", "Current version: ": "Поточна версія: ", "generic_views_count_0": "{{count}} перегляд", "generic_views_count_1": "{{count}} перегляди", diff --git a/locales/vi.json b/locales/vi.json index 07fcf52f..3f7125c4 100644 --- a/locales/vi.json +++ b/locales/vi.json @@ -311,9 +311,9 @@ "`x` marked it with a ❤": "` x` đã đánh dấu nó bằng một ❤", "Audio mode": "Chế độ âm thanh", "Video mode": "Chế độ quay", - "Videos": "Video", + "channel_tab_videos_label": "Video", "Playlists": "Danh sách phát", - "Community": "Cộng đồng", + "channel_tab_community_label": "Cộng đồng", "search_filters_sort_option_relevance": "liên quan", "search_filters_sort_option_rating": "Xếp hạng", "search_filters_sort_option_date": "ngày", diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 7e749dc9..385f16bd 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -341,9 +341,9 @@ "`x` marked it with a ❤": "`x` 为此加 ❤", "Audio mode": "音频模式", "Video mode": "视频模式", - "Videos": "视频", + "channel_tab_videos_label": "视频", "Playlists": "播放列表", - "Community": "社区", + "channel_tab_community_label": "社区", "search_filters_sort_option_relevance": "相关度", "search_filters_sort_option_rating": "评分", "search_filters_sort_option_date": "上传日期", diff --git a/locales/zh-TW.json b/locales/zh-TW.json index 54933701..584d4a0a 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -341,9 +341,9 @@ "`x` marked it with a ❤": "`x` 為此標記 ❤", "Audio mode": "音訊模式", "Video mode": "視訊模式", - "Videos": "影片", + "channel_tab_videos_label": "影片", "Playlists": "播放清單", - "Community": "社群", + "channel_tab_community_label": "社群", "search_filters_sort_option_relevance": "關聯", "search_filters_sort_option_rating": "評分", "search_filters_sort_option_date": "日期", From c02ae66bb1f64b9d2e400a59766a2c5bd3217e1b Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 15 Jan 2023 18:20:15 +0100 Subject: [PATCH 68/73] Update Korean translation Co-authored-by: Hosted Weblate Co-authored-by: xrfmkrh Translate-URL: https://hosted.weblate.org/projects/invidious/translations/ Translation: Invidious/Invidious Translations --- locales/ko.json | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/locales/ko.json b/locales/ko.json index ff6db61a..af19fd02 100644 --- a/locales/ko.json +++ b/locales/ko.json @@ -2,7 +2,7 @@ "preferences_sort_label": "동영상 정렬 기준: ", "preferences_max_results_label": "피드에 표시된 동영상 수: ", "Redirect homepage to feed: ": "피드로 홈페이지 리디렉션: ", - "preferences_annotations_subscribed_label": "구독한 채널에 기본적으로 특수효과를 표시하시겠습니까? ", + "preferences_annotations_subscribed_label": "구독한 채널에 기본으로 주석 표시: ", "preferences_category_subscription": "구독 설정", "preferences_automatic_instance_redirect_label": "자동 인스턴스 리디렉션 (redirect.invidious.io로 대체): ", "preferences_thin_mode_label": "단순 모드: ", @@ -26,7 +26,7 @@ "preferences_speed_label": "기본 속도: ", "preferences_local_label": "비디오를 프록시: ", "preferences_listen_label": "라디오 모드: ", - "preferences_continue_autoplay_label": "다음 동영상 자동재생 ", + "preferences_continue_autoplay_label": "다음 동영상 자동재생: ", "preferences_continue_label": "다음 동영상으로 이동: ", "preferences_autoplay_label": "자동재생: ", "preferences_video_loop_label": "항상 반복: ", @@ -37,8 +37,8 @@ "Register": "회원가입", "Sign In": "로그인", "preferences_category_misc": "기타 설정", - "Image CAPTCHA": "이미지 CAPTCHA", - "Text CAPTCHA": "텍스트 CAPTCHA", + "Image CAPTCHA": "이미지 캡차", + "Text CAPTCHA": "텍스트 캡차", "Time (h:mm:ss):": "시각 (h:mm:ss):", "Password": "비밀번호", "User ID": "사용자 ID", @@ -50,15 +50,15 @@ "An alternative front-end to YouTube": "유튜브의 프론트엔드 대안", "History": "역사", "Delete account?": "계정을 삭제 하시겠습니까?", - "Export data as JSON": "데이터를 JSON으로 내보내기", - "Export subscriptions as OPML (for NewPipe & FreeTube)": "구독을 OPML로 내보내기 (NewPipe 및 FreeTube 용)", - "Export subscriptions as OPML": "구독을 OPML로 내보내기", + "Export data as JSON": "JSON으로 데이터 내보내기", + "Export subscriptions as OPML (for NewPipe & FreeTube)": "OPML로 구독 내보내기 (뉴파이프 및 프리튜브)", + "Export subscriptions as OPML": "OPML로 구독 내보내기", "Export": "내보내기", - "Import NewPipe data (.zip)": "NewPipe 데이터 가져오기 (.zip)", - "Import NewPipe subscriptions (.json)": "NewPipe 구독을 가져오기 (.json)", - "Import FreeTube subscriptions (.db)": "FreeTube 구독 가져오기 (.db)", + "Import NewPipe data (.zip)": "뉴파이프 데이터 가져오기 (.zip)", + "Import NewPipe subscriptions (.json)": "뉴파이프 구독 가져오기 (.json)", + "Import FreeTube subscriptions (.db)": "프리튜브 구독 가져오기 (.db)", "Import YouTube subscriptions": "유튜브 구독 가져오기", - "Import Invidious data": "인비디어스 JSON 데이터 가져오기", + "Import Invidious data": "인비디어스 데이터 가져오기 (.json)", "Import": "가져오기", "Import and Export Data": "데이터 가져오기 및 내보내기", "No": "아니요", @@ -152,7 +152,7 @@ "Report statistics: ": "통계 보고: ", "Registration enabled: ": "등록 활성화: ", "Login enabled: ": "로그인 활성화: ", - "CAPTCHA enabled: ": "CAPTCHA 활성화: ", + "CAPTCHA enabled: ": "캡차 활성화: ", "Top enabled: ": "Top 활성화: ", "preferences_show_nick_label": "상단에 닉네임 표시: ", "preferences_feed_menu_label": "피드 메뉴: ", @@ -284,10 +284,10 @@ "Password cannot be empty": "비밀번호는 비워둘 수 없습니다", "Please sign in using 'Log in with Google'": "'구글로 로그인'을 사용하여 로그인하세요", "Wrong username or password": "잘못된 사용자 이름 또는 비밀번호", - "Password is a required field": "비밀번호는 필수 필드입니다", - "User ID is a required field": "사용자 ID는 필수 필드입니다", - "CAPTCHA is a required field": "CAPTCHA는 필수 필드입니다", - "Erroneous CAPTCHA": "잘못된 CAPTCHA", + "Password is a required field": "비밀번호는 필수 입력란입니다", + "User ID is a required field": "사용자 ID는 필수 입력란입니다", + "CAPTCHA is a required field": "캡차는 필수 입력란입니다", + "Erroneous CAPTCHA": "잘못된 캡차", "Login failed. This may be because two-factor authentication is not turned on for your account.": "로그인 실패. 계정에 이중 인증이 설정되어 있지 않기 때문일 수 있습니다.", "Blacklisted regions: ": "차단된 지역: ", "Playlists": "재생목록", @@ -297,7 +297,7 @@ "Empty playlist": "재생목록 비어 있음", "Show annotations": "주석 보이기", "Hide annotations": "주석 숨기기", - "Switch Invidious Instance": "Invidious 인스턴스 변경", + "Switch Invidious Instance": "인비디어스 인스턴스 변경", "Spanish": "스페인어", "Southern Sotho": "소토어", "Somali": "소말리어", @@ -383,7 +383,7 @@ "adminprefs_modified_source_code_url_label": "수정된 소스 코드 저장소의 URL", "search_filters_title": "필터", "preferences_quality_dash_option_4320p": "4320p", - "Popular enabled: ": "인기 급상승 활성화: ", + "Popular enabled: ": "인기 활성화: ", "Dutch (auto-generated)": "네덜란드어 (자동 생성됨)", "Chinese (Hong Kong)": "중국어 (홍콩)", "Chinese (Taiwan)": "중국어 (대만)", From 215446e638fdfcb18b92ec5f1e55464c99d39693 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sun, 15 Jan 2023 23:16:42 +0100 Subject: [PATCH 69/73] Docker: Also add tini to ARM64 dockerfile --- docker/Dockerfile.arm64 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 index ef3284b1..10135efb 100644 --- a/docker/Dockerfile.arm64 +++ b/docker/Dockerfile.arm64 @@ -42,7 +42,7 @@ RUN if [[ "${release}" == 1 && "${disable_quic}" == 1 ]] ; then \ fi FROM alpine:3.16 -RUN apk add --no-cache librsvg ttf-opensans +RUN apk add --no-cache librsvg ttf-opensans tini WORKDIR /invidious RUN addgroup -g 1000 -S invidious && \ adduser -u 1000 -S invidious -G invidious @@ -57,4 +57,5 @@ RUN chmod o+rX -R ./assets ./config ./locales EXPOSE 3000 USER invidious +ENTRYPOINT ["/sbin/tini", "--"] CMD [ "/invidious/invidious" ] From 910809f1eb185328fa94b5d8baff9ba7756ade48 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Mon, 16 Jan 2023 08:33:34 -0500 Subject: [PATCH 70/73] Handle case with included manifest --- src/invidious/routes/api/manifest.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/routes/api/manifest.cr b/src/invidious/routes/api/manifest.cr index f5d8e5de..662d1002 100644 --- a/src/invidious/routes/api/manifest.cr +++ b/src/invidious/routes/api/manifest.cr @@ -29,7 +29,7 @@ module Invidious::Routes::API::Manifest if local uri = URI.parse(url) - url = "#{uri.request_target}host/#{uri.host}/" + url = "#{HOST_URL}#{uri.request_target}host/#{uri.host}/" end "#{url}" From 35099998927f7bf605f66ac0a2effb9ceb06811c Mon Sep 17 00:00:00 2001 From: hippogriffin <40152338+hippogriffin@users.noreply.github.com> Date: Fri, 20 Jan 2023 20:42:38 +0000 Subject: [PATCH 71/73] update chart.lock --- kubernetes/Chart.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kubernetes/Chart.lock b/kubernetes/Chart.lock index 37fcdbbd..cc76e920 100644 --- a/kubernetes/Chart.lock +++ b/kubernetes/Chart.lock @@ -1,6 +1,6 @@ dependencies: - name: postgresql repository: https://charts.bitnami.com/bitnami/ - version: 11.1.3 -digest: sha256:79061645472b6fb342d45e8e5b3aacd018ef5067193e46a060bccdc99fe7f6e1 -generated: "2022-03-02T05:57:20.081432389+13:00" + version: 12.1.9 +digest: sha256:71ff342a6c0a98bece3d7fe199983afb2113f8db65a3e3819de875af2c45add7 +generated: "2023-01-20T20:42:32.757707004Z" From cf93c94fc43bdb19160555747409b0a59b0c5f6b Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sat, 21 Jan 2023 15:23:15 +0100 Subject: [PATCH 72/73] Formatting fix for Crystal nightly Changes added by https://github.com/crystal-lang/crystal/pull/12951 --- src/invidious/helpers/json_filter.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/invidious/helpers/json_filter.cr b/src/invidious/helpers/json_filter.cr index b8e8f96d..3f4080ba 100644 --- a/src/invidious/helpers/json_filter.cr +++ b/src/invidious/helpers/json_filter.cr @@ -20,7 +20,7 @@ module JSONFilter /^\(|\(\(|\/\(/ end - def self.parse_fields(fields_text : String) : Nil + def self.parse_fields(fields_text : String, &) : Nil if fields_text.empty? raise FieldsParser::ParseError.new "Fields is empty" end @@ -42,7 +42,7 @@ module JSONFilter parse_nest_groups(fields_text) { |nest_list| yield nest_list } end - def self.parse_single_nests(fields_text : String) : Nil + def self.parse_single_nests(fields_text : String, &) : Nil single_nests = remove_nest_groups(fields_text) if !single_nests.empty? @@ -60,7 +60,7 @@ module JSONFilter end end - def self.parse_nest_groups(fields_text : String) : Nil + def self.parse_nest_groups(fields_text : String, &) : Nil nest_stack = [] of NamedTuple(group_name: String, closing_bracket_index: Int64) bracket_pairs = get_bracket_pairs(fields_text, true) From f47d4f88cc6d7a1f0e92cabd5767e39e0596b63f Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sat, 21 Jan 2023 19:52:14 +0100 Subject: [PATCH 73/73] Deps: Use the right source path when copying .min.css files Thanks to therealresonix for the catch! --- scripts/fetch-player-dependencies.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/fetch-player-dependencies.cr b/scripts/fetch-player-dependencies.cr index ed658b51..813e4ce4 100755 --- a/scripts/fetch-player-dependencies.cr +++ b/scripts/fetch-player-dependencies.cr @@ -129,7 +129,7 @@ dependencies_to_install.each do |dep| dep = "videojs.markers" if dep == "videojs-markers" if File.exists?("#{download_path}/package/dist/#{dep}.css") - if minified && File.exists?("#{tmp_dir_path}/#{dep}/package/dist/#{dep}.min.css") + if minified && File.exists?("#{download_path}/package/dist/#{dep}.min.css") `mv #{download_path}/package/dist/#{dep}.min.css #{dest_path}/#{dep}.css` else `mv #{download_path}/package/dist/#{dep}.css #{dest_path}/#{dep}.css`