xtream_codes_go

package module
v0.0.0-...-12ae270 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 16 Imported by: 0

README

Xtream Codes GO

golang xtream codes api client for fetching data from server and creting stream urls.


package main

import (
	"context"
	"fmt"

	xtream_codes "github.com/pbergman/xtream-codes-go"
)

func main() {

	config, err := xtream_codes.NewApiClientConfig("http://example.com", "username", "password")

	if err != nil {
		panic(err)
	}

	client, err := xtream_codes.NewApiClient(config, nil, nil, nil)

	if err != nil {
		panic(err)
	}

	categories, err := client.GetLiveCategories(context.Background())

	if err != nil {
		panic(err)
	}

	for _, category := range categories {
		fmt.Printf("%-4d %s", category.GetId(), category.GetName())
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiClient

type ApiClient struct {
	// contains filtered or unexported fields
}

func NewApiClient

func NewApiClient(config ApiClientConfig, logger *logger.Logger, client *http.Client, dumper io.Writer) (*ApiClient, error)

func (*ApiClient) GetLiveCategories

func (a *ApiClient) GetLiveCategories(ctx context.Context) ([]CategoryInterface, error)

func (*ApiClient) GetLiveStreamUri

func (a *ApiClient) GetLiveStreamUri(streamId int, extension string) string

func (*ApiClient) GetLiveStreams

func (a *ApiClient) GetLiveStreams(ctx context.Context, category int) ([]*LiveStream, error)

func (*ApiClient) GetSeries

func (a *ApiClient) GetSeries(ctx context.Context, category int) ([]*Series, error)

func (*ApiClient) GetSeriesCategories

func (a *ApiClient) GetSeriesCategories(ctx context.Context) ([]CategoryInterface, error)

func (*ApiClient) GetSeriesInfo

func (a *ApiClient) GetSeriesInfo(ctx context.Context, id int) (*SeriesInfo, error)

func (*ApiClient) GetSeriesUri

func (a *ApiClient) GetSeriesUri(id int, extension string) string

GetSeriesUri build serie url

var serie *Serie ... client.GetSeriesUri(serie.Id, serie.ContainerExtension)

func (*ApiClient) GetShortEpg

func (a *ApiClient) GetShortEpg(ctx context.Context, streamId int) (*EpgListening, error)

func (*ApiClient) GetSimpleDataTable

func (a *ApiClient) GetSimpleDataTable(ctx context.Context, streamId int) (*EpgListening, error)

func (*ApiClient) GetVodCategories

func (a *ApiClient) GetVodCategories(ctx context.Context) ([]CategoryInterface, error)

func (*ApiClient) GetVodInfo

func (a *ApiClient) GetVodInfo(ctx context.Context, id int) (*VodInfo, error)

func (*ApiClient) GetVodStreams

func (a *ApiClient) GetVodStreams(ctx context.Context, category int) ([]*VodStream, error)

func (*ApiClient) GetVodUri

func (a *ApiClient) GetVodUri(id int, extension string) string

func (*ApiClient) Login

func (a *ApiClient) Login(ctx context.Context) (*LoginInfo, error)

type ApiClientConfig

type ApiClientConfig interface {
	GetHost() *url.URL
	GetUsername() string
	GetPassword() string
}

func NewApiClientConfig

func NewApiClientConfig(host, username, password string) (ApiClientConfig, error)

type ApiTransport

type ApiTransport struct {
	// contains filtered or unexported fields
}

func (*ApiTransport) RoundTrip

func (t *ApiTransport) RoundTrip(request *http.Request) (*http.Response, error)

type Audio

type Audio struct {
	Index          int          `json:"index"`
	CodecName      string       `json:"codec_name"`
	CodecLongName  string       `json:"codec_long_name"`
	CodecType      string       `json:"codec_type"`
	CodecTagString string       `json:"codec_tag_string"`
	CodecTag       string       `json:"codec_tag"`
	SampleFmt      string       `json:"sample_fmt"`
	SampleRate     string       `json:"sample_rate"`
	Channels       int          `json:"channels"`
	ChannelLayout  string       `json:"channel_layout"`
	BitsPerSample  int          `json:"bits_per_sample"`
	RFrameRate     string       `json:"r_frame_rate"`
	AvgFrameRate   string       `json:"avg_frame_rate"`
	TimeBase       string       `json:"time_base"`
	StartPts       int          `json:"start_pts"`
	StartTime      string       `json:"start_time"`
	Disposition    *Disposition `json:"disposition"`
	Tags           Tags         `json:"tags"`
	// Vod
	Profile       string `json:"profile"`
	CodecTimeBase string `json:"codec_time_base"`
	// Series
	BitRate string `json:"bit_rate"`
}

type CategoryInterface

type CategoryInterface interface {
	GetId() int
	GetName() string
	GetParentId() int
}

type CategoryType

type CategoryType string
const (
	CategoryTypeLive   CategoryType = "live"
	CategoryTypeVod    CategoryType = "vod"
	CategoryTypeSeries CategoryType = "series"
)

type Disposition

type Disposition struct {
	Default         int `json:"default"`
	Dub             int `json:"dub"`
	Original        int `json:"original"`
	Comment         int `json:"comment"`
	Lyrics          int `json:"lyrics"`
	Karaoke         int `json:"karaoke"`
	Forced          int `json:"forced"`
	HearingImpaired int `json:"hearing_impaired"`
	VisualImpaired  int `json:"visual_impaired"`
	CleanEffects    int `json:"clean_effects"`
	AttachedPic     int `json:"attached_pic"`
	TimedThumbnails int `json:"timed_thumbnails"`
	// Series...
	Captions     int `json:"captions,omitempty"`
	Descriptions int `json:"descriptions,omitempty"`
	Metadata     int `json:"metadata,omitempty"`
	Dependent    int `json:"dependent,omitempty"`
	StillImage   int `json:"still_image,omitempty"`
}

type EpgListening

type EpgListening struct {
	EpgListings []*EpgListing `json:"epg_listings"`
}

type EpgListing

type EpgListing struct {
	EpgId          int          `json:"epg_id,string"`
	Title          base64string `json:"title"`
	Lang           string       `json:"lang"`
	Start          date         `json:"start"`
	End            date         `json:"end"`
	Description    base64string `json:"description"`
	ChannelId      string       `json:"channel_id"`
	StartTimestamp int          `json:"start_timestamp,string"`
	StopTimestamp  int          `json:"stop_timestamp,string"`
	//short
	StreamId int `json:"stream_id,string"`
	// long
	Id         int     `json:"id,string"`
	NowPlaying boolean `json:"now_playing"`
	HasArchive boolean `json:"has_archive"`
}

type Episode

type Episode struct {
	Id                 int          `json:"id,string"`
	EpisodeNum         int          `json:"episode_num"`
	Title              string       `json:"title"`
	ContainerExtension string       `json:"container_extension"`
	Info               *EpisodeInfo `json:"info"`
}

type EpisodeInfo

type EpisodeInfo struct {
	AirDate      string   `json:"air_date"`
	Crew         string   `json:"crew"`
	Rating       float    `json:"rating"`
	Id           nummeric `json:"id"`
	MovieImage   string   `json:"movie_image"`
	DurationSecs int      `json:"duration_secs"`
	Duration     string   `json:"duration"`
	Bitrate      int      `json:"bitrate"`
	Video        *Video   `json:"video"`
	Audio        *Video   `json:"audio"`
}

type Error

type Error struct {
	// contains filtered or unexported fields
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type LiveStream

type LiveStream struct {
	EpgChannelId      string   `json:"epg_channel_id"`
	TvArchive         boolean  `json:"tv_archive"`
	TvArchiveDuration nummeric `json:"tv_archive_duration"`
	// contains filtered or unexported fields
}

type LoginInfo

type LoginInfo struct {
	UserInfo   *UserInfo   `json:"user_info"`
	ServerInfo *ServerInfo `json:"server_info"`
}

type Movie

type Movie struct {
	TmdbUrl              string   `json:"tmdb_url"`
	TmdbId               string   `json:"tmdb_id"`
	Name                 string   `json:"name"`
	OName                string   `json:"o_name"`
	CoverBig             string   `json:"cover_big"`
	MovieImage           string   `json:"movie_image"`
	Releasedate          string   `json:"releasedate"`
	EpisodeRunTime       string   `json:"episode_run_time"`
	YoutubeTrailer       string   `json:"youtube_trailer"`
	Director             string   `json:"director"`
	Actors               string   `json:"actors"`
	Cast                 string   `json:"cast"`
	Description          string   `json:"description"`
	Plot                 string   `json:"plot"`
	Age                  string   `json:"age"`
	MpaaRating           string   `json:"mpaa_rating"`
	RatingCountKinopoisk int      `json:"rating_count_kinopoisk"`
	Country              string   `json:"country"`
	Genre                string   `json:"genre"`
	BackdropPath         []string `json:"backdrop_path"`
	DurationSecs         int      `json:"duration_secs"`
	Duration             string   `json:"duration"`
	Video                *Video   `json:"video"`
	Audio                *Audio   `json:"audio"`
	Bitrate              int      `json:"bitrate"`
	Rating               string   `json:"rating"`
}

type MovieData

type MovieData struct {
	StreamId           int    `json:"stream_id"`
	Name               string `json:"name"`
	Added              string `json:"added"`
	CategoryId         string `json:"category_id"`
	CategoryIds        []int  `json:"category_ids"`
	ContainerExtension string `json:"container_extension"`
	CustomSid          string `json:"custom_sid"`
	DirectSource       string `json:"direct_source"`
}

type Season

type Season struct {
	Name         string   `json:"name"`
	EpisodeCount nummeric `json:"episode_count"`
	Overview     string   `json:"overview"`
	AirDate      string   `json:"air_date"`
	Cover        string   `json:"cover"`
	CoverTmdb    string   `json:"cover_tmdb"`
	SeasonNumber nummeric `json:"season_number"`
	CoverBig     string   `json:"cover_big"`
	ReleaseDate  string   `json:"releaseDate"`
	Duration     string   `json:"duration"`
}

type Series

type Series struct {
	SeriesId       int      `json:"series_id"`
	Cover          string   `json:"cover"`
	Plot           string   `json:"plot"`
	Cast           string   `json:"cast"`
	Director       string   `json:"director"`
	Genre          string   `json:"genre"`
	ReleaseDate    string   `json:"releaseDate"`
	LastModified   string   `json:"last_modified"`
	BackdropPath   []string `json:"backdrop_path"`
	YoutubeTrailer string   `json:"youtube_trailer"`
	EpisodeRunTime int      `json:"episode_run_time"`
	// contains filtered or unexported fields
}

func (*Series) UnmarshalJSON

func (s *Series) UnmarshalJSON(data []byte) error

type SeriesInfo

type SeriesInfo struct {
	Seasons  []*Season          `json:"seasons"`
	Info     Series             `json:"info"`
	Episodes map[int][]*Episode `json:"episodes"` // indexed by season
}

type ServerInfo

type ServerInfo struct {
	Url            string  `json:"url"`
	Port           int     `json:"port,string"`
	HttpsPort      int     `json:"https_port,string"`
	ServerProtocol string  `json:"server_protocol"`
	RtmpPort       int     `json:"rtmp_port,string"`
	Timezone       string  `json:"timezone"`
	TimestampNow   int     `json:"timestamp_now"`
	TimeNow        string  `json:"time_now"`
	Process        boolean `json:"process"`
}

type Tags

type Tags map[string]string

type UserInfo

type UserInfo struct {
	Username             string   `json:"username"`
	Password             string   `json:"password"`
	Message              string   `json:"message"`
	Auth                 boolean  `json:"auth"`
	Status               string   `json:"status"`
	ExpDate              int      `json:"exp_date,string"`
	IsTrial              boolean  `json:"is_trial"`
	ActiveCons           int      `json:"active_cons,string"`
	CreatedAt            int      `json:"created_at,string"`
	MaxConnections       int      `json:"max_connections,string"`
	AllowedOutputFormats []string `json:"allowed_output_formats"`
}

type Video

type Video struct {
	Index              int          `json:"index"`
	CodecName          string       `json:"codec_name"`
	CodecLongName      string       `json:"codec_long_name"`
	Profile            string       `json:"profile"`
	CodecType          string       `json:"codec_type"`
	CodecTagString     string       `json:"codec_tag_string"`
	CodecTag           string       `json:"codec_tag"`
	Width              int          `json:"width"`
	Height             int          `json:"height"`
	CodedWidth         int          `json:"coded_width"`
	CodedHeight        int          `json:"coded_height"`
	ClosedCaptions     int          `json:"closed_captions"`
	FilmGrain          int          `json:"film_grain"`
	HasBFrames         int          `json:"has_b_frames"`
	SampleAspectRatio  string       `json:"sample_aspect_ratio"`
	DisplayAspectRatio string       `json:"display_aspect_ratio"`
	PixFmt             string       `json:"pix_fmt"`
	Level              int          `json:"level"`
	ChromaLocation     string       `json:"chroma_location"`
	FieldOrder         string       `json:"field_order"`
	Refs               int          `json:"refs"`
	IsAvc              string       `json:"is_avc"`
	NalLengthSize      string       `json:"nal_length_size"`
	RFrameRate         string       `json:"r_frame_rate"`
	AvgFrameRate       string       `json:"avg_frame_rate"`
	TimeBase           string       `json:"time_base"`
	StartPts           int          `json:"start_pts"`
	StartTime          string       `json:"start_time"`
	BitsPerRawSample   string       `json:"bits_per_raw_sample"`
	Disposition        *Disposition `json:"disposition"`
	Tags               Tags         `json:"tags"`
	Bitrate            int          `json:"bitrate"`
	Rating             string       `json:"rating"`
	// Series
	ExtradataSize int `json:"extradata_size"`
	// Video
	ColorRange     string `json:"color_range"`
	ColorSpace     string `json:"color_space"`
	ColorTransfer  string `json:"color_transfer"`
	ColorPrimaries string `json:"color_primaries"`
}

type VodInfo

type VodInfo struct {
	Info      *Movie     `json:"info"`
	MovieData *MovieData `json:"movie_data"`
}

type VodStream

type VodStream struct {
	Trailer            string `json:"trailer"`
	ContainerExtension string `json:"container_extension"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL