mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-04-11.git
synced 2024-08-15 00:43:26 +00:00
Simplify 'published' extraction
This commit is contained in:
parent
0bb1da6bfd
commit
965a399492
1 changed files with 2 additions and 23 deletions
|
@ -271,29 +271,8 @@ def fetch_video(id, client)
|
|||
|
||||
wilson_score = ci_lower_bound(likes, likes + dislikes)
|
||||
|
||||
published = html.xpath_node(%q(//strong[contains(@class,"watch-time-text")]))
|
||||
if published
|
||||
published = published.content
|
||||
else
|
||||
raise "Could not find date published"
|
||||
end
|
||||
|
||||
published = published.split(" ")
|
||||
published = published[-3..-1].join(" ")
|
||||
if !published.includes?("ago")
|
||||
published = Time.parse(published, "%b %-d, %Y", Time::Location.local)
|
||||
else
|
||||
# Time matches format "20 hours ago", "40 minutes ago"...
|
||||
delta = published.split(" ")[0].to_i
|
||||
case published
|
||||
when .includes? "minute"
|
||||
published = Time.now - delta.minutes
|
||||
when .includes? "hour"
|
||||
published = Time.now - delta.hours
|
||||
else
|
||||
raise "Could not parse #{published}"
|
||||
end
|
||||
end
|
||||
published = html.xpath_node(%q(//meta[@itemprop="datePublished"])).not_nil!["content"]
|
||||
published = Time.parse(published, "%Y-%m-%d", Time::Location.local)
|
||||
|
||||
video = Video.new(id, info, Time.now, title, views, likes, dislikes, wilson_score, published, description, nil, author, ucid)
|
||||
|
||||
|
|
Loading…
Reference in a new issue