summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/invidious.cr5
-rw-r--r--src/invidious/channels.cr6
-rw-r--r--src/invidious/users.cr2
-rw-r--r--src/invidious/videos.cr31
-rw-r--r--src/invidious/views/components/item.ecr6
5 files changed, 42 insertions, 8 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 8707461e..0ff28e11 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -2899,6 +2899,11 @@ get "/api/v1/videos/:id" do |env|
json.field "rating", video.info["avg_rating"].to_f32
json.field "isListed", video.is_listed
json.field "liveNow", video.live_now
+ json.field "isUpcoming", video.is_upcoming
+
+ if video.is_upcoming
+ json.field "premiereTimestamp", video.premiere_timestamp
+ end
if video.player_response["streamingData"]?.try &.["hlsManifestUrl"]?
host_url = make_host_url(config, Kemal.config)
diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr
index ef1bfc5e..57820c49 100644
--- a/src/invidious/channels.cr
+++ b/src/invidious/channels.cr
@@ -118,10 +118,12 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
author = entry.xpath_node("author/name").not_nil!.content
ucid = entry.xpath_node("channelid").not_nil!.content
- length_seconds = videos.select { |video| video.id == video_id }[0]?.try &.length_seconds
+ channel_video = videos.select { |video| video.id == video_id }[0]?
+
+ length_seconds = channel_video.try &.length_seconds
length_seconds ||= 0
- live_now = videos.select { |video| video.id == video_id }[0]?.try &.live_now
+ live_now = channel_video.try &.live_now
live_now ||= false
video = ChannelVideo.new(video_id, title, published, Time.now, ucid, author, length_seconds, live_now)
diff --git a/src/invidious/users.cr b/src/invidious/users.cr
index d7b0e14c..5d0c66b2 100644
--- a/src/invidious/users.cr
+++ b/src/invidious/users.cr
@@ -257,7 +257,7 @@ def validate_response(challenge, token, user_id, operation, key, db, locale)
if nonce = db.query_one?("SELECT * FROM nonces WHERE nonce = $1", nonce, as: {String, Time})
if nonce[1] > Time.now
- db.exec("UPDATE nonces SET expire = $1 WHERE nonce = $2", Time.new(1990, 1, 1), nonce[0])
+ db.exec("UPDATE nonces SET expire = $1 WHERE nonce = $2", Time.new(1990, 1, 1), nonce[0])
else
raise translate(locale, "Invalid token")
end
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index 75f7417f..9ba9c2a1 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -253,7 +253,7 @@ class Video
def allow_ratings
allow_ratings = player_response["videoDetails"].try &.["allowRatings"]?.try &.as_bool
- if !allow_ratings
+ if allow_ratings.nil?
return true
end
@@ -263,7 +263,7 @@ class Video
def live_now
live_now = self.player_response["videoDetails"]?.try &.["isLive"]?.try &.as_bool
- if !live_now
+ if live_now.nil?
return false
end
@@ -273,13 +273,38 @@ class Video
def is_listed
is_listed = player_response["videoDetails"].try &.["isCrawlable"]?.try &.as_bool
- if !is_listed
+ if is_listed.nil?
return true
end
return is_listed
end
+ def is_upcoming
+ is_upcoming = player_response["videoDetails"].try &.["isUpcoming"]?.try &.as_bool
+
+ if is_upcoming.nil?
+ return false
+ end
+
+ return is_upcoming
+ end
+
+ def premiere_timestamp
+ if self.is_upcoming
+ premiere_timestamp = player_response["playabilityStatus"]?
+ .try &.["liveStreamability"]?
+ .try &.["liveStreamabilityRenderer"]?
+ .try &.["offlineSlate"]?
+ .try &.["liveStreamOfflineSlateRenderer"]?
+ .try &.["scheduledStartTime"].as_s.to_i64
+
+ return premiere_timestamp
+ else
+ return nil
+ end
+ end
+
def keywords
keywords = self.player_response["videoDetails"]?.try &.["keywords"]?.try &.as_a
keywords ||= [] of String
diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr
index fe48834f..cd457324 100644
--- a/src/invidious/views/components/item.ecr
+++ b/src/invidious/views/components/item.ecr
@@ -39,7 +39,9 @@
<% else %>
<div class="thumbnail">
<img class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
+ <% if item.length_seconds != 0 %>
<p class="length"><%= recode_length_seconds(item.length_seconds) %></p>
+ <% end %>
</div>
<% end %>
<p><%= item.title %></p>
@@ -55,7 +57,7 @@
<img class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
<% if item.responds_to?(:live_now) && item.live_now %>
<p class="length"><i class="icon ion-ios-play-circle"></i> <%= translate(locale, "LIVE") %></p>
- <% else %>
+ <% elsif item.length_seconds != 0 %>
<p class="length"><%= recode_length_seconds(item.length_seconds) %></p>
<% end %>
</div>
@@ -90,7 +92,7 @@
<% end %>
<% if item.responds_to?(:live_now) && item.live_now %>
<p class="length"><i class="icon ion-ios-play-circle"></i> <%= translate(locale, "LIVE") %></p>
- <% else %>
+ <% elsif item.length_seconds != 0 %>
<p class="length"><%= recode_length_seconds(item.length_seconds) %></p>
<% end %>
</div>
d.it: pass - libreddit.spike.codes: pass - libreddit.kavin.rocks: pass - libreddit.insanity.wtf: fail (site doesn't work in general) - libreddit.dothq.co: pass - teddit.net: mostly fail - teddit.ggc-project.de: mostly fail - teddit.kavin.rocks: mostly fail - old.reddit.com: fail - i.reddit.com: fail - snew.notabug.io: fail (site doesn't work in general) Teddit image urls have two issues. First, the links almost never work (404) if the image url is visited directly before visiting the main page. Once the main page is visited, however, the image url starts working. I'm guessing this is an issue with teddit instances not fetching images unless the main page is accessed. Second, some image links are different/incompatible for some reason. For example, <https://i.redd.it/htg3owj12ok21.png> turns into <https://teddit.net/pics/w:null_TpEyuHnjif6578pV0lBuM-kNW1bXqxbvqbOHjhRZVr0.png>. Libreddit seems to not have this issue. 2021-04-08feat: add img prefix for i.redd.itJason Kim "i.redd.it/<imgfile>" redirects "libredd.it/<imgfile>". Make it redirect to "libredd.it/img/<imgfile>". Tested only for "libredd.it". 2021-04-08feat: add i.redd.it to reddit targetsJason Kim Add "i.redd.it" to list of urls to redirect for Reddit. Although the redirect works, the link should be invalid because it still needs an "img" path prefix. 2021-04-07Update Bibliogram instances listCadence Ember Set it to match the list of actually working instances. https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md 2021-04-05Update manifest.jsonHarsh Barsaiyan 2021-03-30Add ViewTubeHarsh Barsaiyan 2021-03-20Add Ecosia search engineCamille019 2021-03-11Add Whoogle SearchHarsh Barsaiyan 2021-03-02Disable SimplyTranslate redirects by defaultfattalion 2021-02-25Add SimplyTranslate supportfattalion 2021-02-24add invidious instanceAndrew Zhao