From 078f71ab1f91c035735b5f3d3a02dce7ad31b041 Mon Sep 17 00:00:00 2001 From: Manfred Stienstra Date: Thu, 22 Aug 2024 11:35:08 +0200 Subject: [PATCH] Allow users to browse chapter markers for a video. --- src/teletube/cli.cr | 2 ++ src/teletube/client.cr | 4 ++++ src/teletube/option_parser.cr | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/teletube/cli.cr b/src/teletube/cli.cr index e689fe6..0c47ca4 100644 --- a/src/teletube/cli.cr +++ b/src/teletube/cli.cr @@ -50,6 +50,8 @@ module Teletube @client.get_browsable_audio_variants when "waveform" @client.get_browsable_waveform + when "chapter-markers" + @client.get_browsable_chapter_markers end when "config" @config.attributes = { diff --git a/src/teletube/client.cr b/src/teletube/client.cr index 67714e2..33d6075 100644 --- a/src/teletube/client.cr +++ b/src/teletube/client.cr @@ -288,6 +288,10 @@ module Teletube handle_response(@http.get(path: "/api/v1/browse/videos/#{@context.params["video_id"]}/waveform")) end + def get_browsable_chapter_markers + handle_response(@http.get(path: "/api/v1/browse/videos/#{@context.params["video_id"]}/chapter_markers")) + end + def handle_response(response) STDERR.puts "⚡️ #{response.status} (#{response.status_code})" puts response.body unless response.body.blank? diff --git a/src/teletube/option_parser.cr b/src/teletube/option_parser.cr index cb6b069..602356d 100644 --- a/src/teletube/option_parser.cr +++ b/src/teletube/option_parser.cr @@ -289,6 +289,12 @@ module Teletube context.params["video_id"] = JSON::Any.new(id) end end + parser.on("chapter-markers", "Show details about the chapter markers for a video.") do + context.command = "chapter-markers" + parser.on("--video-id ID", "The public identifier of the video.") do |id| + context.params["video_id"] = JSON::Any.new(id) + end + end end parser.separator "Other options:"