mirror of
https://github.com/iv-org/invidious.git
synced 2025-04-22 16:29:10 -04:00
Don't use extract_text for video length extraction
The extract_text function attempts to extract from both the simpleText and the runs route. This is typically what we'd want for text extraction as it could appear in both locations. However, while this still holds true, the thumbnailOverlayTimeStatusRenderer writes a numerical length (when present on the video) to the simpleText route and uses runs for a text overlay like "LIVE" or "PREMIERE". Therefore, when a video has a text overlay instead of a numerical one, Invidious still passes it onto decode_length_seconds, which obviously raises since it cannot be converted into integers. In the future, if more routes requires one text route over the other, we should go ahead and add an argument to extract_text itself. Though for now, this is sufficient.
This commit is contained in:
parent
65279a08ba
commit
57754d69e1
@ -76,10 +76,10 @@ private module Parsers
|
||||
elsif length_container = item_contents["thumbnailOverlays"]?.try &.as_a.find(&.["thumbnailOverlayTimeStatusRenderer"]?)
|
||||
# This needs to only go down the `simpleText` path (if possible). If more situations came up that requires
|
||||
# a specific pathway then we should add an argument to extract_text that'll make this possible
|
||||
length_seconds = extract_text(length_container["thumbnailOverlayTimeStatusRenderer"]["text"])
|
||||
length_seconds = length_container.dig?("thumbnailOverlayTimeStatusRenderer", "text", "simpleText")
|
||||
|
||||
if length_seconds && length_seconds != "LIVE"
|
||||
length_seconds = decode_length_seconds(length_seconds)
|
||||
if length_seconds
|
||||
length_seconds = decode_length_seconds(length_seconds.as_s)
|
||||
else
|
||||
length_seconds = 0
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user