forked from midou/invidious
videos: Fix some bugs
This commit is contained in:
parent
83795c245a
commit
db91d3af66
@ -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"])
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user