cmd

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Copyright © 2025 NAME HERE <EMAIL ADDRESS>

Copyright © 2025 NAME HERE <EMAIL ADDRESS>

Copyright © 2025 NAME HERE <EMAIL ADDRESS>

Copyright © 2025 NAME HERE <EMAIL ADDRESS>

Copyright © 2025 NAME ExaExamples:

  %s install           # Install using symlink method
  %s install --profile # Force install by modifying shell profile", AppName, AppName),es:

	%s app install           # Install using symlink method
	%s app install --profile # Force install by modifying shell profile", AppName, AppName, AppName),E <EMAIL ADDRESS>

Copyright © 2025 NAME HERE <EMAIL ADDRESS>

Copyright © 2025 NAME HERE <EMAIL ADDRESS>

Copyright © 2025 NAME HERE <EMAIL ADDRESS>

Copyright © 2025 NAME HERE <EMAIL ADDRESS>

Copyright © 2025 NAME HERE <EMAIL ADDRESS>

Index

Constants

View Source
const (
	// DefaultModulePath is the Go module path for updates (when published)
	DefaultModulePath = "github.com/daniel-le97/banned-cli"
	APIEndpoint       = "https://api.banned.video/graphql"

	// AppDescription is the short description shown in help
	AppDescription = "tool for downloading from https://banned.video"

	// AppLongDescription is the detailed description
	AppLongDescription = "a tool for downloading from https://banned.video"

	// Default torrent configuration
	DefaultTrackerURL  = "udp://tracker.openbittorrent.com:80/announce"
	DefaultPieceLength = 256 // KB
)

Application configuration - change these values to customize the application

View Source
const (
	GitHubOwner = "daniel-le97"
	GitHubRepo  = "banned-cli"
)

Variables

View Source
var (
	// AppName is the application name (binary name)
	AppName = "banned"

	// ConfigFileName is the default config file name (without extension)
	ConfigFileName = "." + AppName
)
View Source
var (
	// Global database instance
	DB *sql.DB
)
View Source
var DefaultTrackers = []string{
	"udp://tracker.openbittorrent.com:80/announce",
	"udp://tracker.publicbt.com:80/announce",
	"udp://tracker.ccc.de:80/announce",
	"udp://exodus.desync.com:6969/announce",
}

Popular public trackers (can be used as fallbacks)

Functions

func CheckChannelVideoCount

func CheckChannelVideoCount(channelID string) (apiCount, dbCount int, needsSync bool, err error)

CheckChannelVideoCount compares API video count with local database count

func CloseDB

func CloseDB() error

CloseDB closes the global database connection

func DownloadVideo

func DownloadVideo(url, filename string) error

DownloadVideo downloads a video from a URL and saves it to a file

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func GetDB

func GetDB() (*sql.DB, error)

GetDB returns the global database instance, initializing it if necessary

func GetSetting

func GetSetting(key string) (string, error)

GetSetting retrieves a setting value by key

func LogDebug

func LogDebug(message string, args ...interface{})

LogDebug logs database operations for debugging

func NewMenu

func NewMenu() menuModel

Create the main menu

func RunChannelBrowserTUI

func RunChannelBrowserTUI(channels []Channel) error

RunChannelBrowserTUI creates and runs the channel browser TUI

func RunTUI

func RunTUI() error

Run the interactive TUI

func SetSetting

func SetSetting(key, value string) error

SetSetting updates or inserts a setting

func StoreChannel

func StoreChannel(channel Channel) error

StoreChannel stores or updates channel information in the database

func StoreVideos

func StoreVideos(channelID string, videos []Video) error

StoreVideos stores multiple videos in the database

func StoreVideosBatch

func StoreVideosBatch(channelID string, videos []Video) error

StoreVideosBatch stores videos in a batch with proper error handling

func UpdateVideoFileSize

func UpdateVideoFileSize(videoID string, fileSize int64) error

UpdateVideoFileSize updates the file_size for a video in the database

Types

type Channel

type Channel struct {
	ID              string    `json:"_id"`
	Title           string    `json:"title"`
	Summary         string    `json:"summary,omitempty"`
	TextInfo        string    `json:"textInfo,omitempty"`
	Avatar          string    `json:"avatar,omitempty"`
	CoverImage      string    `json:"coverImage,omitempty"`
	IsLive          bool      `json:"isLive,omitempty"`
	TotalVideos     float64   `json:"totalVideos,omitempty"`
	TotalVideoViews float64   `json:"totalVideoViews,omitempty"`
	TotalLikes      float64   `json:"totalLikes,omitempty"`
	Videos          []Video   `json:"videos,omitempty"`
	ShowInfo        *ShowInfo `json:"showInfo,omitempty"`
	Links           *Links    `json:"links,omitempty"`
}

Channel represents a channel structure

func GetAllChannels

func GetAllChannels() ([]Channel, error)

GetAllChannels retrieves all channels from the database

func GetAllChannelsFromDB

func GetAllChannelsFromDB() ([]Channel, error)

GetAllChannelsFromDB retrieves all channels from the database

type Client

type Client struct {
	APIEndpoint string
}

Client represents the API client

func NewClient

func NewClient(apiEndpoint string) *Client

NewClient creates a new API client

func (*Client) FetchAllChannels

func (c *Client) FetchAllChannels() error

FetchAllChannels fetches all available channels and stores them in database

func (*Client) FetchAllVideos

func (c *Client) FetchAllVideos(channelID string) ([]Video, error)

FetchAllVideos recursively fetches all videos for a channel using pagination

func (*Client) FetchAllVideosWithLimit

func (c *Client) FetchAllVideosWithLimit(channelID string, maxVideos int) ([]Video, error)

FetchAllVideosWithLimit is like FetchAllVideos but stops after maxVideos for testing

func (*Client) FetchChannelData

func (c *Client) FetchChannelData(channelID string) error

FetchChannelData fetches detailed channel information

func (*Client) FetchVideos

func (c *Client) FetchVideos(channelID string, offset, limit int) ([]Video, error)

FetchVideos fetches videos from the API and stores them in the database

func (*Client) GetChannelVideoCount

func (c *Client) GetChannelVideoCount(channelID string) (int, error)

GetChannelVideoCount fetches the video count for a channel from the API

func (*Client) SyncAllChannelVideos

func (c *Client) SyncAllChannelVideos() error

SyncAllChannelVideos syncs videos for all channels incrementally

func (*Client) SyncAllChannelVideosWithOptions

func (c *Client) SyncAllChannelVideosWithOptions(fetchFileSizes bool) error

SyncAllChannelVideosWithOptions syncs videos for all channels incrementally with options

func (*Client) SyncChannelVideos

func (c *Client) SyncChannelVideos(channelID string) error

SyncChannelVideos fetches only new videos for a specific channel

func (*Client) SyncChannelVideosWithOptions

func (c *Client) SyncChannelVideosWithOptions(channelID string, fetchFileSizes bool) error

SyncChannelVideosWithOptions fetches only new videos for a specific channel with options

func (*Client) SyncChannels

func (c *Client) SyncChannels() error

SyncChannels fetches only new/updated channels

type GetAllChannelsResponse

type GetAllChannelsResponse struct {
	Data struct {
		GetAllChannels []Channel `json:"getAllChannels"`
	} `json:"data"`
}

type GetChannelResponse

type GetChannelResponse struct {
	Data struct {
		GetChannel Channel `json:"getChannel"`
	} `json:"data"`
}

type GetChannelVideosResponse

type GetChannelVideosResponse struct {
	Data struct {
		GetChannel struct {
			ID     string  `json:"_id"`
			Videos []Video `json:"videos"`
		} `json:"getChannel"`
	} `json:"data"`
}

type GitHubRelease

type GitHubRelease struct {
	TagName string `json:"tag_name"`
	Name    string `json:"name"`
	Assets  []struct {
		Name               string `json:"name"`
		BrowserDownloadURL string `json:"browser_download_url"`
		Size               int64  `json:"size"`
	} `json:"assets"`
	Prerelease bool   `json:"prerelease"`
	Draft      bool   `json:"draft"`
	Body       string `json:"body"`
}

GitHub API structs

type GraphQLRequest

type GraphQLRequest struct {
	OperationName string                 `json:"operationName"`
	Variables     map[string]interface{} `json:"variables"`
	Query         string                 `json:"query"`
}

GraphQL request/response structures

type Links 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"`
}

type ShowInfo

type ShowInfo struct {
	Times string `json:"times"`
	Phone string `json:"phone"`
}

type TorrentConfig

type TorrentConfig struct {
	Tracker     string
	OutputDir   string
	PieceLength int
	Comment     string
	Private     bool
}

TorrentConfig holds configuration for torrent creation

type Video

type Video struct {
	ID            string  `json:"_id"`
	Title         string  `json:"title"`
	Summary       string  `json:"summary"`
	LargeImage    string  `json:"largeImage"`
	VideoDuration float64 `json:"videoDuration"`
	CreatedAt     string  `json:"createdAt"`
	DirectURL     string  `json:"directUrl"`
	PlayCount     int     `json:"playCount,omitempty"`
	LikeCount     int     `json:"likeCount,omitempty"`
	AngerCount    int     `json:"angerCount,omitempty"`
	EmbedURL      string  `json:"embedUrl,omitempty"`
	Published     bool    `json:"published,omitempty"`
	FileSize      int64   `json:"fileSize,omitempty"`
}

Video represents a video structure

func GetChannelVideos

func GetChannelVideos(channelID string, limit, offset int) ([]Video, error)

GetChannelVideos retrieves videos for a specific channel from the database

type VideoInfo

type VideoInfo struct {
	ID        string
	Title     string
	DirectURL string
	FileSize  int64
	Error     error
}

VideoInfo holds video information with file size

Jump to

Keyboard shortcuts

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