Documentation
¶
Index ¶
- Variables
- type CaptionsFormat
- type Client
- func (c *Client) AddTag(fileID uint, tag string) ([]string, error)
- func (c *Client) GetCaptions(opts GetCaptionsOptions) ([]byte, error)
- func (c *Client) GetCaptionsByVideoID(id string, format CaptionsFormat) ([]byte, error)
- func (c *Client) GetFile(id uint) (*File, error)
- func (c *Client) GetFiles(params, filters url.Values) (*FilesPage, error)
- func (c *Client) GetTags(fileID uint) ([]string, error)
- func (c *Client) GetTranscript(fileID uint) (*Transcript, error)
- func (c *Client) GetTranscriptByVideoID(videoID string) (*Transcript, error)
- func (c *Client) GetTranscriptByVideoIDWithFormat(id string, format TranscriptFormat) ([]byte, error)
- func (c *Client) GetTranscriptWithFormat(id uint, format TranscriptFormat) ([]byte, error)
- func (c *Client) RemoveTag(fileID uint, tag string) ([]string, error)
- func (c *Client) UpdateFile(fileID uint, data url.Values) error
- func (c *Client) UploadFileFromURL(fileURL string, options url.Values) (uint, error)
- type Error
- type File
- type FilesPage
- type GetCaptionsOptions
- type Summary
- type Transcript
- type TranscriptFormat
- type Word
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnauthorized = errors.New("401: API Error") // ErrNotFound represents a 404 error on API ErrNotFound = errors.New("404: API Error") )
Functions ¶
This section is empty.
Types ¶
type CaptionsFormat ¶
type CaptionsFormat string
CaptionsFormat is supported output format for captions
const ( // SRT format for captions file SRT CaptionsFormat = "srt" // WebVTT format for captions file WebVTT CaptionsFormat = "vtt" // DFX format for captions file DFX CaptionsFormat = "pdfxp" // SMI format for captions file SMI CaptionsFormat = "smi" // STL format for captions file STL CaptionsFormat = "stl" // QT format for captions file QT CaptionsFormat = "qt" // QTXML format for captions file QTXML CaptionsFormat = "qtxml" // CPTXML format for captions file CPTXML CaptionsFormat = "cptxml" // ADBE format for captions file ADBE CaptionsFormat = "adbe" )
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 3Play Media API client
func NewClientWithHTTPClient ¶
NewClientWithHTTPClient returns a 3Play Media client with a custom http client
func (*Client) GetCaptions ¶
func (c *Client) GetCaptions(opts GetCaptionsOptions) ([]byte, error)
GetCaptions retrieves caption files according to the given options.
func (*Client) GetCaptionsByVideoID ¶
func (c *Client) GetCaptionsByVideoID(id string, format CaptionsFormat) ([]byte, error)
GetCaptionsByVideoID get captions by video ID with specific format current supported formats are srt, dfxp, smi, stl, qt, qtxml, cptxml, adbe
func (*Client) GetFiles ¶
GetFiles returns a list of files, supports pagination through params and filters. For a full list of supported filtering parameters check http://support.3playmedia.com/hc/en-us/articles/227729828-Files-API-Methods
Example ¶
package main
import (
"fmt"
"net/url"
"github.com/NYTimes/threeplay"
)
func main() {
client := threeplay.NewClient("api-key", "secret")
filesPage, _ := client.GetFiles(nil, nil)
fmt.Println(filesPage.Files)
pagination, _ := url.ParseQuery("page=2&per_page=10")
filesPage, _ = client.GetFiles(pagination, nil)
fmt.Println(filesPage.Files)
}
Output:
func (*Client) GetTranscript ¶
func (c *Client) GetTranscript(fileID uint) (*Transcript, error)
GetTranscript get json transcript by file ID
func (*Client) GetTranscriptByVideoID ¶
func (c *Client) GetTranscriptByVideoID(videoID string) (*Transcript, error)
GetTranscriptByVideoID get json transcript by video ID
func (*Client) GetTranscriptByVideoIDWithFormat ¶
func (c *Client) GetTranscriptByVideoIDWithFormat(id string, format TranscriptFormat) ([]byte, error)
GetTranscriptByVideoIDWithFormat get transcript by video ID with specific format current supported formats are json, text and html
func (*Client) GetTranscriptWithFormat ¶
func (c *Client) GetTranscriptWithFormat(id uint, format TranscriptFormat) ([]byte, error)
GetTranscriptWithFormat get transcript by file ID with supported formats current supported formats are json, text and html
Example ¶
package main
import (
"fmt"
"github.com/NYTimes/threeplay"
)
func main() {
client := threeplay.NewClient("api-key", "secret")
transcript, _ := client.GetTranscriptWithFormat(123, threeplay.JSON)
fmt.Println(transcript)
}
Output:
func (*Client) UpdateFile ¶
UpdateFile updates a File metadata
Example ¶
package main
import (
"fmt"
"net/url"
"github.com/NYTimes/threeplay"
)
func main() {
client := threeplay.NewClient("api-key", "api-secret")
data, _ := url.ParseQuery("name=another-name")
err := client.UpdateFile(1687446, data)
if err != nil {
fmt.Println(err)
}
}
Output:
func (*Client) UploadFileFromURL ¶
UploadFileFromURL uploads a file to threeplay using the file's URL and returns the file ID.
Example ¶
package main
import (
"fmt"
"net/url"
"github.com/NYTimes/threeplay"
)
func main() {
client := threeplay.NewClient("api-key", "secret")
data, _ := url.ParseQuery("video_id=123&attribute1=abc")
fileID, _ := client.UploadFileFromURL("http://somewhere.com/video.mp4", data)
fmt.Println(fileID)
}
Output:
type File ¶
type File struct {
ID uint `json:"id"`
ProjectID uint `json:"project_id"`
BatchID uint `json:"batch_id"`
Duration uint `json:"duration"`
Attribute1 string `json:"attribute1"`
Attribute2 string `json:"attribute2"`
Attribute3 string `json:"attribute3"`
VideoID string `json:"video_id"`
Name string `json:"name"`
CallbackURL string `json:"callback_url"`
Description string `json:"description"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
WordCount uint `json:"word_count"`
ThumbnailURL string `json:"thumbnail_url"`
LanguageID int `json:"language_id"`
DefaultServiceTypeID int `json:"default_service_type_id"`
Downloaded bool `json:"downloaded"`
State string `json:"state"`
TurnaroundLevelID int `json:"turnaround_level_id"`
Deadline string `json:"deadline"`
BatchName string `json:"batch_name"`
ErrorDescription string `json:"error_description"`
}
File representation
type GetCaptionsOptions ¶
type GetCaptionsOptions struct {
// FileID should be specified to download the captions file by its ID.
// This option is mutually exclusive with VideoID.
FileID uint
// VideoID should be specified to download the captions file specifying
// the video ID. This option is mutually exclusive with FileID.
VideoID string
// Format specifies the standard format that should be used. Please
// refer to the constants exported by this package to see the available
// formats. This option is mutually exclusive with Outputformat.
Format CaptionsFormat
// OutputFormat specifies the custom format that should be used.
// This option is mutually exclusive with Format.
OutputFormat string
}
GetCaptionsOptions represents the set of options that can be provided when obtaining a captions file.
type Summary ¶
type Summary struct {
CurrentPage json.Number `json:"current_page"`
PerPage json.Number `json:"per_page"`
TotalEntries json.Number `json:"total_entries"`
TotalPages json.Number `json:"total_pages"`
}
Summary representation
type Transcript ¶
type Transcript struct {
Words []Word `json:"words"`
Paragraphs []int `json:"paragraphs"`
Speakers map[string]string `json:"speakers"`
}
Transcript video transcript
type TranscriptFormat ¶
type TranscriptFormat string
TranscriptFormat supported output formats for transcripts
const ( // JSON format for transcripted file JSON TranscriptFormat = "json" // TXT format output for transcripted file TXT TranscriptFormat = "txt" // HTML format output for transcripted file HTML TranscriptFormat = "html" )