mirror of
https://github.com/iv-org/invidious.git
synced 2025-10-22 00:38:30 -05:00
Merge 7064f4898e28791a6af5c2adeec3ab5370d0b901 into 5cfe294063c9317928d8da3387004e3eaddc991a
This commit is contained in:
commit
71827ad74c
@ -144,10 +144,14 @@ def translate(locale : String?, key : String, text : String | Hash(String, Strin
|
||||
return translation
|
||||
end
|
||||
|
||||
def translate_count(locale : String, key : String, count : Int, format = NumberFormatting::None) : String
|
||||
def translate_count(locale : String, key : String, count : Int | String, format = NumberFormatting::None) : String
|
||||
# Fallback on english if locale doesn't exist
|
||||
locale = "en-US" if !LOCALES.has_key?(locale)
|
||||
|
||||
if count.is_a?(String)
|
||||
return translate(locale, count)
|
||||
end
|
||||
|
||||
# Retrieve suffix
|
||||
suffix = I18next::Plurals::RESOLVER.get_suffix(locale, count)
|
||||
plural_key = key + suffix
|
||||
|
@ -167,7 +167,7 @@ struct SearchPlaylist
|
||||
property id : String
|
||||
property author : String
|
||||
property ucid : String
|
||||
property video_count : Int32
|
||||
property video_count : Int32 | String
|
||||
property videos : Array(SearchPlaylistVideo)
|
||||
property thumbnail : String?
|
||||
property author_verified : Bool
|
||||
|
@ -674,9 +674,17 @@ private module Parsers
|
||||
.compact_map(&.dig?("thumbnailOverlayBadgeViewModel", "thumbnailBadges").try &.as_a)
|
||||
.flatten
|
||||
.find(nil, &.dig?("thumbnailBadgeViewModel", "text").try { |node|
|
||||
{"episodes", "videos"}.any? { |str| node.as_s.ends_with?(str) }
|
||||
{"episodes", "videos", "video", "Mix"}.any? { |str| node.as_s.ends_with?(str) }
|
||||
})
|
||||
.try &.dig("thumbnailBadgeViewModel", "text").as_s.to_i(strict: false)
|
||||
.try &.dig("thumbnailBadgeViewModel", "text").to_s
|
||||
|
||||
if video_count
|
||||
# Tries to convert it to a number, video_count_n will be nil
|
||||
# if `video_count` equals to `"Mix"`.
|
||||
if video_count_n = video_count.to_i?(strict: false)
|
||||
video_count = video_count_n
|
||||
end
|
||||
end
|
||||
|
||||
metadata = item_contents.dig("metadata", "lockupMetadataViewModel")
|
||||
title = metadata.dig("title", "content").as_s
|
||||
@ -695,7 +703,7 @@ private module Parsers
|
||||
id: playlist_id,
|
||||
author: author_fallback.name,
|
||||
ucid: author_fallback.id,
|
||||
video_count: video_count || -1,
|
||||
video_count: video_count || -1, # -1 if a fallback value in case video count is nil
|
||||
videos: [] of SearchPlaylistVideo,
|
||||
thumbnail: thumbnail,
|
||||
author_verified: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user