diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-07-28 21:00:19 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-07-28 21:00:19 -0500 |
| commit | 573e909785c6228633b3f5635cbaed0fd220ac3b (patch) | |
| tree | 4b0986fa4e3a1613a0365dbe36eece61b005e35c | |
| parent | 7060c67328064d491b9a7825af70585a5027c4df (diff) | |
| download | invidious-573e909785c6228633b3f5635cbaed0fd220ac3b.tar.gz invidious-573e909785c6228633b3f5635cbaed0fd220ac3b.tar.bz2 invidious-573e909785c6228633b3f5635cbaed0fd220ac3b.zip | |
Add 'lengthSeconds' to /channels/:ucid/videos
| -rw-r--r-- | src/invidious.cr | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 9f971482..5fd852b5 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1145,6 +1145,11 @@ get "/api/v1/channels/:ucid/videos" do |env| published = published.content published = decode_date(published) + length_seconds = item.xpath_node(%q(.//span[@class="video-time"]/span)).not_nil!.content + length_seconds = length_seconds.split(":").map { |a| a.to_i } + length_seconds = [0] * (3 - length_seconds.size) + length_seconds + length_seconds = Time::Span.new(length_seconds[0], length_seconds[1], length_seconds[2]) + json.object do json.field "title", title json.field "videoId", video_id @@ -1172,6 +1177,7 @@ get "/api/v1/channels/:ucid/videos" do |env| json.field "viewCount", view_count json.field "published", published.epoch + json.field "lengthSeconds", length_seconds.total_seconds.to_i end end end |
