Class: Tavus::Resources::Videos
- Inherits:
-
Object
- Object
- Tavus::Resources::Videos
- Defined in:
- lib/tavus/resources/videos.rb
Instance Method Summary collapse
-
#create(replica_id:, **options) ⇒ Hash
Generate a new video.
-
#delete(video_id, hard: false) ⇒ Hash
Delete a video.
-
#generate_from_audio(replica_id:, audio_url:, **options) ⇒ Hash
Convenient method to generate video from audio.
-
#generate_from_text(replica_id:, script:, **options) ⇒ Hash
Convenient method to generate video from text.
-
#get(video_id, verbose: false) ⇒ Hash
Get a single video by ID.
-
#initialize(client) ⇒ Videos
constructor
A new instance of Videos.
-
#list(**options) ⇒ Hash
List all videos.
-
#rename(video_id, video_name) ⇒ Hash
Rename a video.
Constructor Details
#initialize(client) ⇒ Videos
6 7 8 |
# File 'lib/tavus/resources/videos.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#create(replica_id:, **options) ⇒ Hash
Generate a new video
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tavus/resources/videos.rb', line 24 def create(replica_id:, **) body = .merge(replica_id: replica_id) # Validate that either script or audio_url is provided unless body[:script] || body[:audio_url] raise ArgumentError, "Either :script or :audio_url must be provided" end @client.post("/v2/videos", body: body) end |
#delete(video_id, hard: false) ⇒ Hash
Delete a video
75 76 77 78 |
# File 'lib/tavus/resources/videos.rb', line 75 def delete(video_id, hard: false) params = hard ? { hard: true } : {} @client.delete("/v2/videos/#{video_id}", params: params) end |
#generate_from_audio(replica_id:, audio_url:, **options) ⇒ Hash
Convenient method to generate video from audio
49 50 51 |
# File 'lib/tavus/resources/videos.rb', line 49 def generate_from_audio(replica_id:, audio_url:, **) create(replica_id: replica_id, audio_url: audio_url, **) end |
#generate_from_text(replica_id:, script:, **options) ⇒ Hash
Convenient method to generate video from text
40 41 42 |
# File 'lib/tavus/resources/videos.rb', line 40 def generate_from_text(replica_id:, script:, **) create(replica_id: replica_id, script: script, **) end |
#get(video_id, verbose: false) ⇒ Hash
Get a single video by ID
57 58 59 60 |
# File 'lib/tavus/resources/videos.rb', line 57 def get(video_id, verbose: false) params = verbose ? { verbose: true } : {} @client.get("/v2/videos/#{video_id}", params: params) end |
#list(**options) ⇒ Hash
List all videos
67 68 69 |
# File 'lib/tavus/resources/videos.rb', line 67 def list(**) @client.get("/v2/videos", params: ) end |
#rename(video_id, video_name) ⇒ Hash
Rename a video
84 85 86 |
# File 'lib/tavus/resources/videos.rb', line 84 def rename(video_id, video_name) @client.patch("/v2/videos/#{video_id}/name", body: { video_name: video_name }) end |