Documentation
¶
Overview ¶
Package xtreamcodes provides a Golang interface to the Xtream-Codes IPTV Server API.
Index ¶
- type AuthenticationResponse
- type Base64Value
- type Category
- type ConvertibleBoolean
- type Disposition
- type EPGInfo
- type FFMPEGStreamInfo
- type FlexFloat
- type FlexInt
- type Format
- type JSONStringSlice
- type ProbeInfo
- type Series
- type SeriesEpisode
- type SeriesInfo
- type ServerInfo
- type SideData
- type Stream
- type StreamType
- type Tags
- type Timestamp
- type UserInfo
- type VideoOnDemandInfo
- type XtreamClient
- func (c *XtreamClient) GetCategories(catType string) ([]Category, error)
- func (c *XtreamClient) GetEPG(streamID string) ([]EPGInfo, error)
- func (c *XtreamClient) GetLiveCategories() ([]Category, error)
- func (c *XtreamClient) GetLiveStreams(categoryID string) ([]Stream, error)
- func (c *XtreamClient) GetSeries(categoryID string) ([]SeriesInfo, error)
- func (c *XtreamClient) GetSeriesCategories() ([]Category, error)
- func (c *XtreamClient) GetSeriesInfo(seriesID string) (*Series, error)
- func (c *XtreamClient) GetShortEPG(streamID string, limit int) ([]EPGInfo, error)
- func (c *XtreamClient) GetStreamURL(streamID int, wantedFormat string) (string, error)
- func (c *XtreamClient) GetStreams(streamAction, categoryID string) ([]Stream, error)
- func (c *XtreamClient) GetVideoOnDemandCategories() ([]Category, error)
- func (c *XtreamClient) GetVideoOnDemandInfo(vodID string) (*VideoOnDemandInfo, error)
- func (c *XtreamClient) GetVideoOnDemandStreams(categoryID string) ([]Stream, error)
- func (c *XtreamClient) GetXMLTV() ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthenticationResponse ¶
type AuthenticationResponse struct {
ServerInfo ServerInfo `json:"server_info"`
UserInfo UserInfo `json:"user_info"`
}
AuthenticationResponse is a container for what the server returns after the initial authentication.
type Base64Value ¶
type Base64Value []byte
Base64Value is a base64url encoded json object,
func New ¶
func New(b []byte) *Base64Value
New returns a pointer to a Base64Value, cast from the given byte slice. This is a convenience function, handling the address creation that a direct cast would not allow.
func NewFromString ¶
func NewFromString(encoded string) (*Base64Value, error)
NewFromString returns a Base64Value containing the decoded data in encoded.
func (*Base64Value) MarshalJSON ¶
func (bv *Base64Value) MarshalJSON() ([]byte, error)
MarshalJSON returns the ba64url encoding of bv for JSON representation.
func (*Base64Value) String ¶
func (bv *Base64Value) String() string
func (*Base64Value) UnmarshalJSON ¶
func (bv *Base64Value) UnmarshalJSON(b []byte) error
UnmarshalJSON sets bv to the bytes represented in the base64url encoding b.
type Category ¶
type Category struct {
ID FlexInt `json:"category_id,string"`
Name string `json:"category_name"`
Parent FlexInt `json:"parent_id"`
// Set by us, not Xtream.
Type string `json:"-"`
}
Category describes a grouping of Stream.
type ConvertibleBoolean ¶
type ConvertibleBoolean struct {
// contains filtered or unexported fields
}
ConvertibleBoolean is a helper type to allow JSON documents using 0/1 or "true" and "false" be converted to bool.
func (ConvertibleBoolean) MarshalJSON ¶
func (bit ConvertibleBoolean) MarshalJSON() ([]byte, error)
MarshalJSON returns a 0 or 1 depending on bool state.
func (*ConvertibleBoolean) UnmarshalJSON ¶
func (bit *ConvertibleBoolean) UnmarshalJSON(data []byte) error
UnmarshalJSON converts a 0, 1, true or false into a bool
type Disposition ¶
type Disposition struct {
AttachedPic int `json:"attached_pic"`
CleanEffects int `json:"clean_effects"`
Comment int `json:"comment"`
Default int `json:"default"`
Dub int `json:"dub"`
Forced int `json:"forced"`
HearingImpaired int `json:"hearing_impaired"`
Karaoke int `json:"karaoke"`
Lyrics int `json:"lyrics"`
Original int `json:"original"`
VisualImpaired int `json:"visual_impaired"`
}
Disposition of FFMPEGStreamInfo
type EPGInfo ¶
type EPGInfo struct {
ChannelID string `json:"channel_id"`
Description Base64Value `json:"description"`
End string `json:"end"`
EPGID FlexInt `json:"epg_id,string"`
HasArchive ConvertibleBoolean `json:"has_archive"`
ID FlexInt `json:"id,string"`
Lang string `json:"lang"`
NowPlaying ConvertibleBoolean `json:"now_playing"`
Start string `json:"start"`
StartTimestamp Timestamp `json:"start_timestamp"`
StopTimestamp Timestamp `json:"stop_timestamp"`
Title Base64Value `json:"title"`
}
EPGInfo describes electronic programming guide information of a stream.
type FFMPEGStreamInfo ¶
type FFMPEGStreamInfo struct {
AvgFrameRate string `json:"avg_frame_rate"`
BitRate string `json:"bit_rate"`
BitsPerRawSample string `json:"bits_per_raw_sample"`
BitsPerSample int `json:"bits_per_sample"`
ChannelLayout string `json:"channel_layout"`
Channels int `json:"channels"`
ChromaLocation string `json:"chroma_location"`
CodecLongName string `json:"codec_long_name"`
CodecName string `json:"codec_name"`
CodecTag string `json:"codec_tag"`
CodecTagString string `json:"codec_tag_string"`
CodecTimeBase string `json:"codec_time_base"`
CodecType StreamType `json:"codec_type"`
CodedHeight int `json:"coded_height"`
CodedWidth int `json:"coded_width"`
ColorPrimaries string `json:"color_primaries"`
ColorRange string `json:"color_range"`
ColorSpace string `json:"color_space"`
ColorTransfer string `json:"color_transfer"`
DisplayAspectRatio string `json:"display_aspect_ratio"`
DivxPacked string `json:"divx_packed"`
DmixMode string `json:"dmix_mode"`
Duration string `json:"duration"`
DurationTs int `json:"duration_ts"`
HasBFrames int `json:"has_b_frames"`
Height int `json:"height"`
ID string `json:"id"`
Index int `json:"index"`
IsAvc string `json:"is_avc"`
Level int `json:"level"`
LoroCmixlev string `json:"loro_cmixlev"`
LoroSurmixlev string `json:"loro_surmixlev"`
LtrtCmixlev string `json:"ltrt_cmixlev"`
LtrtSurmixlev string `json:"ltrt_surmixlev"`
MaxBitRate string `json:"max_bit_rate"`
NalLengthSize string `json:"nal_length_size"`
NumFrames string `json:"nb_frames"`
PixFmt string `json:"pix_fmt"`
Profile string `json:"profile"`
QuarterSample string `json:"quarter_sample"`
FrameRate string `json:"r_frame_rate"`
Refs int `json:"refs"`
SampleAspectRatio string `json:"sample_aspect_ratio"`
SampleFmt string `json:"sample_fmt"`
SampleRate string `json:"sample_rate"`
StartPts int `json:"start_pts"`
StartTime string `json:"start_time"`
TimeBase string `json:"time_base"`
Timecode string `json:"timecode"`
Width int `json:"width"`
Tags Tags `json:"tags"`
Disposition Disposition `json:"disposition"`
SideDataList []SideData `json:"side_data_list"`
}
FFMPEGStreamInfo represents any kind of stream (Audio, Video, etc)
func (FFMPEGStreamInfo) IsRotated ¶
func (s FFMPEGStreamInfo) IsRotated() (bool, error)
IsRotated returns true if the stream is rotated.
func (FFMPEGStreamInfo) Rotation ¶
func (s FFMPEGStreamInfo) Rotation() (int, error)
Rotation gets the rotation value of video stream, either from stream side-data, or tags. Returns 0 if it's not rotated, or if we can't figure it out.
type FlexInt ¶
type FlexInt int64
FlexInt is a int64 which unmarshals from JSON as either unquoted or quoted (with any amount of internal leading/trailing whitespace). Originally found at https://bit.ly/2NkJ0SK and https://play.golang.org/p/KNPxDL1yqL
func (FlexInt) MarshalJSON ¶
func (*FlexInt) UnmarshalJSON ¶
type Format ¶
type Format struct {
BitRate string `json:"bit_rate"`
Duration string `json:"duration"`
Filename string `json:"filename"`
LongName string `json:"format_long_name"`
Name string `json:"format_name"`
NumPrograms int `json:"nb_programs"`
NumStreams int `json:"nb_streams"`
ProbeScore int `json:"probe_score"`
Size string `json:"size"`
StartTime string `json:"start_time"`
Tags Tags `json:"tags"`
}
Format describes container format info.
type JSONStringSlice ¶
JSONStringSlice is a struct containing a slice of strings. It is needed for cases in which we may get an array or may get a single string in a JSON response.
func (JSONStringSlice) MarshalJSON ¶
func (b JSONStringSlice) MarshalJSON() ([]byte, error)
MarshalJSON returns b as the JSON encoding of b.
func (*JSONStringSlice) UnmarshalJSON ¶
func (b *JSONStringSlice) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *b to a copy of data.
type ProbeInfo ¶
type ProbeInfo struct {
Format Format `json:"format"`
Streams []FFMPEGStreamInfo `json:"streams"`
}
ProbeInfo is just a nice structure that represents the JSON data returned by ffprobe. Mostly auto-generated with http://mholt.github.io/json-to-go
func (ProbeInfo) FilterStreams ¶
func (info ProbeInfo) FilterStreams(t StreamType) []FFMPEGStreamInfo
FilterStreams filters out streams of the given StreamType. Returns a []FFMPEGStreamInfo slice, even if it's empty
type Series ¶
type Series struct {
Episodes map[string][]SeriesEpisode `json:"episodes"`
Info SeriesInfo `json:"info"`
Seasons []interface{} `json:"seasons"`
}
type SeriesEpisode ¶
type SeriesEpisode struct {
Added string `json:"added"`
ContainerExtension string `json:"container_extension"`
CustomSid string `json:"custom_sid"`
DirectSource string `json:"direct_source"`
EpisodeNum FlexInt `json:"episode_num"`
ID string `json:"id"`
Info struct {
Audio FFMPEGStreamInfo `json:"audio"`
Bitrate FlexInt `json:"bitrate"`
Duration string `json:"duration"`
DurationSecs FlexInt `json:"duration_secs"`
MovieImage string `json:"movie_image"`
Name string `json:"name"`
Plot string `json:"plot"`
Rating FlexFloat `json:"rating"`
ReleaseDate string `json:"releasedate"`
Video FFMPEGStreamInfo `json:"video"`
} `json:"info"`
Season FlexInt `json:"season"`
Title string `json:"title"`
}
type SeriesInfo ¶
type SeriesInfo struct {
BackdropPath *JSONStringSlice `json:"backdrop_path,omitempty"`
Cast string `json:"cast"`
CategoryID *FlexInt `json:"category_id,string"`
Cover string `json:"cover"`
Director string `json:"director"`
EpisodeRunTime string `json:"episode_run_time"`
Genre string `json:"genre"`
LastModified *Timestamp `json:"last_modified,omitempty"`
Name string `json:"name"`
Num FlexInt `json:"num"`
Plot string `json:"plot"`
Rating FlexInt `json:"rating,string"`
Rating5 FlexFloat `json:"rating_5based"`
ReleaseDate string `json:"releaseDate"`
SeriesID FlexInt `json:"series_id"`
StreamType string `json:"stream_type"`
YoutubeTrailer string `json:"youtube_trailer"`
}
SeriesInfo contains information about a TV series.
type ServerInfo ¶
type ServerInfo struct {
HTTPSPort FlexInt `json:"https_port,string"`
Port FlexInt `json:"port,string"`
Process bool `json:"process"`
RTMPPort FlexInt `json:"rtmp_port,string"`
Protocol string `json:"server_protocol"`
TimeNow string `json:"time_now"`
TimestampNow Timestamp `json:"timestamp_now,string"`
Timezone string `json:"timezone"`
URL string `json:"url"`
}
ServerInfo describes the state of the Xtream-Codes server.
type SideData ¶
type SideData struct {
Displaymatrix string `json:"displaymatrix"`
Rotation int `json:"rotation"`
Size int `json:"side_data_size"`
Type string `json:"side_data_type"`
}
SideData describes metadata. More fields may be added later as needed.
type Stream ¶
type Stream struct {
Added *Timestamp `json:"added"`
CategoryID FlexInt `json:"category_id,string"`
CategoryName string `json:"category_name"`
ContainerExtension string `json:"container_extension"`
CustomSid string `json:"custom_sid"`
DirectSource string `json:"direct_source,omitempty"`
EPGChannelID string `json:"epg_channel_id"`
Icon string `json:"stream_icon"`
ID FlexInt `json:"stream_id"`
Name string `json:"name"`
Number FlexInt `json:"num"`
Rating FlexFloat `json:"rating"`
Rating5based FlexFloat `json:"rating_5based"`
TVArchive FlexInt `json:"tv_archive"`
TVArchiveDuration *FlexInt `json:"tv_archive_duration"`
Type string `json:"stream_type"`
}
Stream is a streamble video source.
type StreamType ¶
type StreamType string
StreamType is used for enumerating the CodecType field in FFMPEGStreamInfo.
const ( // VideoStream is the constant for video streams. VideoStream StreamType = "video" // AudioStream is the constant for audio streams. AudioStream = "audio" )
type Tags ¶
type Tags map[string]interface{}
Tags represents either Format or FFMPEGStreamInfo tags embedded in the file.
type Timestamp ¶
Timestamp is a helper struct to convert unix timestamp ints and strings to time.Time.
func (Timestamp) MarshalJSON ¶
MarshalJSON returns the Unix timestamp as a string.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON converts the int or string to a Unix timestamp.
type UserInfo ¶
type UserInfo struct {
ActiveConnections FlexInt `json:"active_cons,string"`
AllowedOutputFormats []string `json:"allowed_output_formats"`
Auth ConvertibleBoolean `json:"auth"`
CreatedAt Timestamp `json:"created_at"`
ExpDate *Timestamp `json:"exp_date"`
IsTrial ConvertibleBoolean `json:"is_trial,string"`
MaxConnections FlexInt `json:"max_connections,string"`
Message string `json:"message"`
Password string `json:"password"`
Status string `json:"status"`
Username string `json:"username"`
}
UserInfo is the current state of the user as it relates to the Xtream-Codes server.
type VideoOnDemandInfo ¶
type VideoOnDemandInfo struct {
Info struct {
Audio FFMPEGStreamInfo `json:"audio"`
BackdropPath []string `json:"backdrop_path"`
Bitrate FlexInt `json:"bitrate"`
Cast string `json:"cast"`
Director string `json:"director"`
Duration string `json:"duration"`
DurationSecs FlexInt `json:"duration_secs"`
Genre string `json:"genre"`
MovieImage string `json:"movie_image"`
Plot string `json:"plot"`
Rating FlexFloat `json:"rating"`
ReleaseDate string `json:"releasedate"`
TmdbID FlexInt `json:"tmdb_id"`
Video FFMPEGStreamInfo `json:"video"`
YoutubeTrailer string `json:"youtube_trailer"`
} `json:"info"`
MovieData struct {
Added Timestamp `json:"added"`
CategoryID FlexInt `json:"category_id,string"`
ContainerExtension string `json:"container_extension"`
CustomSid string `json:"custom_sid"`
DirectSource string `json:"direct_source"`
Name string `json:"name"`
StreamID FlexInt `json:"stream_id"`
} `json:"movie_data"`
}
VideoOnDemandInfo contains information about a video on demand stream.
type XtreamClient ¶
type XtreamClient struct {
Username string
Password string
BaseURL string
UserAgent string
ServerInfo ServerInfo
UserInfo UserInfo
// Our HTTP client to communicate with Xtream
HTTP *http.Client
Context context.Context
// contains filtered or unexported fields
}
XtreamClient is the client used to communicate with a Xtream-Codes server.
func NewClient ¶
func NewClient(username, password, baseURL string) (*XtreamClient, error)
NewClient returns an initialized XtreamClient with the given values.
func NewClientWithContext ¶
func NewClientWithContext(ctx context.Context, username, password, baseURL string) (*XtreamClient, error)
NewClientWithContext returns an initialized XtreamClient with the given values.
func NewClientWithUserAgent ¶
func NewClientWithUserAgent(ctx context.Context, username, password, baseURL, userAgent string) (*XtreamClient, error)
NewClientWithUserAgent returns an initialized XtreamClient with the given values.
func (*XtreamClient) GetCategories ¶
func (c *XtreamClient) GetCategories(catType string) ([]Category, error)
GetCategories is a helper function used by GetLiveCategories, GetVideoOnDemandCategories and GetSeriesCategories to reduce duplicate code.
func (*XtreamClient) GetEPG ¶
func (c *XtreamClient) GetEPG(streamID string) ([]EPGInfo, error)
GetEPG returns the full EPG for the given streamID.
func (*XtreamClient) GetLiveCategories ¶
func (c *XtreamClient) GetLiveCategories() ([]Category, error)
GetLiveCategories will return a slice of categories for live streams.
func (*XtreamClient) GetLiveStreams ¶
func (c *XtreamClient) GetLiveStreams(categoryID string) ([]Stream, error)
GetLiveStreams will return a slice of live streams. You can also optionally provide a categoryID to limit the output to members of that category.
func (*XtreamClient) GetSeries ¶
func (c *XtreamClient) GetSeries(categoryID string) ([]SeriesInfo, error)
GetSeries will return a slice of all available Series. You can also optionally provide a categoryID to limit the output to members of that category.
func (*XtreamClient) GetSeriesCategories ¶
func (c *XtreamClient) GetSeriesCategories() ([]Category, error)
GetSeriesCategories will return a slice of categories for series streams.
func (*XtreamClient) GetSeriesInfo ¶
func (c *XtreamClient) GetSeriesInfo(seriesID string) (*Series, error)
GetSeriesInfo will return a series info for the given seriesID.
func (*XtreamClient) GetShortEPG ¶
func (c *XtreamClient) GetShortEPG(streamID string, limit int) ([]EPGInfo, error)
GetShortEPG returns a short version of the EPG for the given streamID. If no limit is provided, the next 4 items in the EPG will be returned.
func (*XtreamClient) GetStreamURL ¶
func (c *XtreamClient) GetStreamURL(streamID int, wantedFormat string) (string, error)
GetStreamURL will return a stream URL string for the given streamID and wantedFormat.
func (*XtreamClient) GetStreams ¶
func (c *XtreamClient) GetStreams(streamAction, categoryID string) ([]Stream, error)
GetStreams is a helper function used by GetLiveStreams and GetVideoOnDemandStreams to reduce duplicate code.
func (*XtreamClient) GetVideoOnDemandCategories ¶
func (c *XtreamClient) GetVideoOnDemandCategories() ([]Category, error)
GetVideoOnDemandCategories will return a slice of categories for VOD streams.
func (*XtreamClient) GetVideoOnDemandInfo ¶
func (c *XtreamClient) GetVideoOnDemandInfo(vodID string) (*VideoOnDemandInfo, error)
GetVideoOnDemandInfo will return VOD info for the given vodID.
func (*XtreamClient) GetVideoOnDemandStreams ¶
func (c *XtreamClient) GetVideoOnDemandStreams(categoryID string) ([]Stream, error)
GetVideoOnDemandStreams will return a slice of VOD streams. You can also optionally provide a categoryID to limit the output to members of that category.
func (*XtreamClient) GetXMLTV ¶
func (c *XtreamClient) GetXMLTV() ([]byte, error)
GetXMLTV will return a slice of bytes for the XMLTV EPG file available from the provider.