Documentation
¶
Overview ¶
Package api provides a complete GraphQL client for banned.video API
Index ¶
- Constants
- func Example()
- func ExampleBatchProcessing()
- type API
- func (a *API) BulkFetchChannelData(ctx context.Context, channelIDs []string, videoLimit int) (map[string]*Channel, error)
- func (a *API) GetAPIInfo() map[string]interface{}
- func (a *API) Ping(ctx context.Context) error
- func (a *API) SearchChannels(ctx context.Context, query string) ([]Channel, error)
- func (a *API) SetTimeout(timeout time.Duration)
- func (a *API) SetUserAgent(userAgent string)
- type AdminUser
- type Channel
- type ChannelLinks
- type ChannelService
- func (s *ChannelService) FetchAllChannelVideos(ctx context.Context, channelID string, batchSize int) ([]Video, error)
- func (s *ChannelService) FetchAllChannelVideosWithLimit(ctx context.Context, channelID string, maxVideos, batchSize int) ([]Video, error)
- func (s *ChannelService) GetAllChannels(ctx context.Context, offset, limit int) ([]Channel, error)
- func (s *ChannelService) GetChannel(ctx context.Context, channelID string) (*Channel, error)
- func (s *ChannelService) GetChannelHotVideos(ctx context.Context, channelID string, offset, limit int) ([]Video, error)
- func (s *ChannelService) GetChannelVideos(ctx context.Context, channelID string, offset, limit int) ([]Video, error)
- func (s *ChannelService) GetChannelWithVideos(ctx context.Context, params ChannelVideosParams) (*Channel, error)
- type ChannelVideosParams
- type ChannelsResponse
- type Client
- type Comment
- type GraphQLError
- type GraphQLErrorLocation
- type GraphQLRequest
- type GraphQLResponse
- type Pagination
- type Playlist
- type ShowInfo
- type Tag
- type Upload
- type User
- type Video
- type VideoService
- func (s *VideoService) FetchAllHotVideos(ctx context.Context, batchSize int) ([]Video, error)
- func (s *VideoService) FetchAllHotVideosWithLimit(ctx context.Context, maxVideos, batchSize int) ([]Video, error)
- func (s *VideoService) FetchAllNewVideos(ctx context.Context, batchSize int) ([]Video, error)
- func (s *VideoService) GetHotVideos(ctx context.Context, offset, limit int) ([]Video, error)
- func (s *VideoService) GetNewVideos(ctx context.Context, offset, limit int) ([]Video, error)
- func (s *VideoService) GetVideo(ctx context.Context, videoID string) (*Video, error)
- func (s *VideoService) GetVideoAudioURL(video *Video) string
- func (s *VideoService) GetVideoDownloadURL(video *Video) string
- func (s *VideoService) GetVideoPosterURL(video *Video) string
- func (s *VideoService) GetVideos(ctx context.Context, videoIDs []string) ([]Video, error)
- type VideoView
- type VideosResponse
- type Vote
- type VoteCount
Constants ¶
const GetAllChannelsQuery = `` /* 377-byte string literal not displayed */
const GetChannelHotVideosQuery = `` /* 362-byte string literal not displayed */
const GetChannelQuery = `` /* 407-byte string literal not displayed */
const GetChannelWithVideosQuery = `` /* 629-byte string literal not displayed */
const GetChannelsQuery = `` /* 218-byte string literal not displayed */
const GetHotVideosQuery = `` /* 284-byte string literal not displayed */
const GetNewVideosQuery = `` /* 284-byte string literal not displayed */
const GetVideoQuery = `` /* 236-byte string literal not displayed */
const GetVideosQuery = `` /* 244-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func ExampleBatchProcessing ¶
func ExampleBatchProcessing()
ExampleBatchProcessing shows how to process large amounts of data efficiently
Types ¶
type API ¶
type API struct {
Client *Client
Channels *ChannelService
Videos *VideoService
}
API provides a high-level interface to the banned.video GraphQL API
func NewWithConfig ¶
NewWithConfig creates a new API instance with custom configuration
func (*API) BulkFetchChannelData ¶
func (a *API) BulkFetchChannelData(ctx context.Context, channelIDs []string, videoLimit int) (map[string]*Channel, error)
BulkFetchChannelData fetches multiple channels with their videos in parallel
func (*API) GetAPIInfo ¶
GetAPIInfo returns information about the API client
func (*API) SearchChannels ¶
SearchChannels searches for channels by title (basic implementation) Note: This might need to be adjusted based on actual search capabilities in the API
func (*API) SetTimeout ¶
SetTimeout updates the HTTP timeout for API requests
func (*API) SetUserAgent ¶
SetUserAgent updates the user agent for API requests
type AdminUser ¶
type AdminUser struct {
ID string `json:"_id"`
Email string `json:"email"`
DisplayName string `json:"displayName"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
AdminUser represents an admin user
type Channel ¶
type Channel struct {
ID string `json:"_id"`
Title string `json:"title"`
Summary string `json:"summary"`
TextInfo string `json:"textInfo"`
FeaturedVideo *Video `json:"featuredVideo"`
LiveStreamVideo *Video `json:"liveStreamVideo"`
AlwaysLive bool `json:"alwaysLive"`
IsLive bool `json:"isLive"`
Avatar string `json:"avatar"`
CoverImage string `json:"coverImage"`
Creator *AdminUser `json:"creator"`
TotalVideoViews float64 `json:"totalVideoViews"`
TotalLikes float64 `json:"totalLikes"`
Playlists []Playlist `json:"playlists"`
PlaylistOrder []string `json:"playlistOrder"`
TotalVideos float64 `json:"totalVideos"`
TotalPlaylists float64 `json:"totalPlaylists"`
Links *ChannelLinks `json:"links"`
LastUpload *time.Time `json:"lastUpload"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
Videos []Video `json:"videos,omitempty"`
}
Channel represents a banned.video channel
type ChannelLinks ¶
type ChannelLinks struct {
Website string `json:"website"`
Facebook string `json:"facebook"`
Twitter string `json:"twitter"`
Gab string `json:"gab"`
Minds string `json:"minds"`
Telegram string `json:"telegram"`
SubscribeStar string `json:"subscribeStar"`
}
ChannelLinks represents channel social links
type ChannelService ¶
type ChannelService struct {
// contains filtered or unexported fields
}
ChannelService provides methods for interacting with channels
func NewChannelService ¶
func NewChannelService(client *Client) *ChannelService
NewChannelService creates a new channel service
func (*ChannelService) FetchAllChannelVideos ¶
func (s *ChannelService) FetchAllChannelVideos(ctx context.Context, channelID string, batchSize int) ([]Video, error)
FetchAllChannelVideos recursively fetches all videos from a channel with pagination
func (*ChannelService) FetchAllChannelVideosWithLimit ¶
func (s *ChannelService) FetchAllChannelVideosWithLimit(ctx context.Context, channelID string, maxVideos, batchSize int) ([]Video, error)
FetchAllChannelVideosWithLimit recursively fetches videos with a maximum limit
func (*ChannelService) GetAllChannels ¶
GetAllChannels fetches all channels with pagination
func (*ChannelService) GetChannel ¶
GetChannel fetches a specific channel by ID
func (*ChannelService) GetChannelHotVideos ¶
func (s *ChannelService) GetChannelHotVideos(ctx context.Context, channelID string, offset, limit int) ([]Video, error)
GetChannelHotVideos fetches hot/trending videos from a specific channel
func (*ChannelService) GetChannelVideos ¶
func (s *ChannelService) GetChannelVideos(ctx context.Context, channelID string, offset, limit int) ([]Video, error)
GetChannelVideos fetches videos from a specific channel (convenience method)
func (*ChannelService) GetChannelWithVideos ¶
func (s *ChannelService) GetChannelWithVideos(ctx context.Context, params ChannelVideosParams) (*Channel, error)
GetChannelWithVideos fetches a channel with its videos
type ChannelVideosParams ¶
type ChannelVideosParams struct {
ChannelID string
IncludeUnlisted bool
IncludeUnpublished bool
IncludeLive bool
Offset int
Limit int
}
ChannelVideosParams represents parameters for fetching channel videos
type ChannelsResponse ¶
type ChannelsResponse struct {
Channels []Channel `json:"channels"`
TotalCount int `json:"totalCount,omitempty"`
HasMore bool `json:"hasMore,omitempty"`
}
ChannelsResponse represents a response containing channels
type Client ¶
Client represents the GraphQL API client
func NewClientWithConfig ¶
NewClientWithConfig creates a new API client with custom configuration
func (*Client) Execute ¶
func (c *Client) Execute(ctx context.Context, req *GraphQLRequest) (*GraphQLResponse, error)
Execute performs a GraphQL query and returns the response
func (*Client) ExecuteWithResult ¶
func (c *Client) ExecuteWithResult(ctx context.Context, req *GraphQLRequest, result interface{}) error
ExecuteWithResult performs a GraphQL query and unmarshals the result
type Comment ¶
type Comment struct {
ID string `json:"_id"`
Name string `json:"name"`
User *User `json:"user"`
Video *Video `json:"video"`
Parent *Comment `json:"parent"`
Replies []Comment `json:"replies"`
LikeCount float64 `json:"likeCount"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
Comment represents a video comment
type GraphQLError ¶
type GraphQLError struct {
Message string `json:"message"`
Locations []GraphQLErrorLocation `json:"locations,omitempty"`
Path []interface{} `json:"path,omitempty"`
Extensions map[string]interface{} `json:"extensions,omitempty"`
}
GraphQLError represents a GraphQL error
func (GraphQLError) Error ¶
func (e GraphQLError) Error() string
Error implements the error interface for GraphQLError
type GraphQLErrorLocation ¶
GraphQLErrorLocation represents the location of a GraphQL error
type GraphQLRequest ¶
type GraphQLRequest struct {
Query string `json:"query"`
Variables map[string]interface{} `json:"variables,omitempty"`
}
GraphQLRequest represents a GraphQL request
type GraphQLResponse ¶
type GraphQLResponse struct {
Data json.RawMessage `json:"data"`
Errors []GraphQLError `json:"errors,omitempty"`
}
GraphQLResponse represents a GraphQL response
type Pagination ¶
Pagination represents pagination parameters
type Playlist ¶
type Playlist struct {
ID string `json:"_id"`
Title string `json:"title"`
Summary string `json:"summary"`
Image string `json:"image"`
Channel *Channel `json:"channel"`
Creator *AdminUser `json:"creator"`
Videos []Video `json:"videos"`
TotalVideos float64 `json:"totalVideos"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
Playlist represents a playlist
type Tag ¶
type Tag struct {
ID string `json:"_id"`
Name string `json:"name"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
Tag represents a video tag
type Upload ¶
type Upload struct {
ID string `json:"_id"`
Name string `json:"name"`
Mimetype string `json:"mimetype"`
Encoding string `json:"encoding"`
OriginalFilename string `json:"originalFilename"`
Size int64 `json:"size"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
Upload represents an uploaded file
type User ¶
type User struct {
ID string `json:"_id"`
DisplayName string `json:"displayName"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
User represents a regular user
type Video ¶
type Video struct {
ID string `json:"_id"`
Title string `json:"title"`
Summary string `json:"summary"`
Published bool `json:"published"`
Unlisted bool `json:"unlisted"`
Creator *AdminUser `json:"creator"`
Channel *Channel `json:"channel"`
Tags []Tag `json:"tags"`
VideoDuration float64 `json:"videoDuration"`
AudioUpload *Upload `json:"audioUpload"`
PosterUpload *Upload `json:"posterUpload"`
VideoUpload *Upload `json:"videoUpload"`
Live bool `json:"live"`
DisableComment bool `json:"disableComment"`
LiveStreamUrl string `json:"liveStreamUrl"`
TimeWatched float64 `json:"timeWatched"`
IsInWatchLater bool `json:"isInWatchLater"`
LargeImage string `json:"largeImage"`
PlayCount float64 `json:"playCount"`
LikeCount float64 `json:"likeCount"`
AngerCount float64 `json:"angerCount"`
ShowInfo *ShowInfo `json:"showInfo"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
PublishedAt *time.Time `json:"publishedAt"`
LastCommentAt *time.Time `json:"lastCommentAt"`
DirectURL string `json:"directUrl"`
EmbedURL string `json:"embedUrl"`
}
Video represents a banned.video video
type VideoService ¶
type VideoService struct {
// contains filtered or unexported fields
}
VideoService provides methods for interacting with videos
func NewVideoService ¶
func NewVideoService(client *Client) *VideoService
NewVideoService creates a new video service
func (*VideoService) FetchAllHotVideos ¶
FetchAllHotVideos recursively fetches all hot videos with pagination
func (*VideoService) FetchAllHotVideosWithLimit ¶
func (s *VideoService) FetchAllHotVideosWithLimit(ctx context.Context, maxVideos, batchSize int) ([]Video, error)
FetchAllHotVideosWithLimit recursively fetches hot videos with a maximum limit
func (*VideoService) FetchAllNewVideos ¶
FetchAllNewVideos recursively fetches all new videos with pagination
func (*VideoService) GetHotVideos ¶
GetHotVideos fetches trending/hot videos
func (*VideoService) GetNewVideos ¶
GetNewVideos fetches the newest videos
func (*VideoService) GetVideoAudioURL ¶
func (s *VideoService) GetVideoAudioURL(video *Video) string
GetVideoAudioURL returns the audio URL for a video (if available)
func (*VideoService) GetVideoDownloadURL ¶
func (s *VideoService) GetVideoDownloadURL(video *Video) string
GetVideoDownloadURL returns the best download URL for a video
func (*VideoService) GetVideoPosterURL ¶
func (s *VideoService) GetVideoPosterURL(video *Video) string
GetVideoPosterURL returns the poster/thumbnail URL for a video
type VideoView ¶
type VideoView struct {
ID string `json:"_id"`
Video *Video `json:"video"`
User *User `json:"user"`
Channel *Channel `json:"channel"`
ViewDuration float64 `json:"viewDuration"`
UserAgent string `json:"userAgent"`
IPAddress string `json:"ipAddress"`
CreatedAt *time.Time `json:"createdAt"`
}
VideoView represents a video view record
type VideosResponse ¶
type VideosResponse struct {
Videos []Video `json:"videos"`
TotalCount int `json:"totalCount,omitempty"`
HasMore bool `json:"hasMore,omitempty"`
}
VideosResponse represents a response containing videos with pagination info
type Vote ¶
type Vote struct {
ID string `json:"_id"`
User *User `json:"user"`
Video *Video `json:"video"`
Comment *Comment `json:"comment"`
Type string `json:"type"` // "like", "dislike", "angry"
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
Vote represents a vote (like/dislike)