Skip to content

Commit e8a96a6

Browse files
committed
Allow listing of all files for a video.
1 parent 7fcada4 commit e8a96a6

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/teletube/cli.cr

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ module Teletube
7171
@client.create_file
7272
when "upload"
7373
@client.upload_file
74+
else
75+
@client.get_files
7476
end
7577
when "videos"
7678
case context.command

src/teletube/client.cr

+4
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ module Teletube
150150
@context.params["upload_id"] = JSON::Any.new(upload.id)
151151
end
152152

153+
def get_files
154+
handle_response(@http.get(path: "/api/v1/videos/#{@context.params["video_id"]}/files"))
155+
end
156+
153157
def get_videos
154158
handle_response(@http.get(path: "/api/v1/channels/#{@context.params["channel_id"]}/videos"))
155159
end

src/teletube/option_parser.cr

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ module Teletube
8282

8383
parser.on("files", "Interact with files.") do
8484
context.resource = "files"
85+
parser.on("list", "List all files uploaded for a video.") do
86+
context.command = "list"
87+
parser.on("--video-id ID", "The identifier of the video.") do |video_id|
88+
context.params["video_id"] = JSON::Any.new(video_id)
89+
end
90+
end
8591
parser.on("create", "Create a file.") do
8692
context.command = "create"
8793
end

0 commit comments

Comments
 (0)