Documentation
¶
Overview ¶
Package core provides HLS (HTTP Live Streaming) download functionality.
Index ¶
- Constants
- Variables
- func CleanCache() error
- func DecryptEmbedSu(urlStr string, client *http.Client) (string, []string, string, error)
- func DecryptGeneric(urlStr string, client *http.Client) (string, []string, string, error)
- func DecryptMegacloud(urlStr string, client *http.Client) (string, []string, string, error)
- func DecryptMegacloudFromPage(urlStr string, client *http.Client) (string, []string, string, error)
- func DecryptMultiembed(urlStr string, client *http.Client) (string, []string, string, error)
- func DecryptStream(embedLink string, client *http.Client) (string, []string, string, error)
- func DecryptVidlink(urlStr string, client *http.Client) (string, []string, string, error)
- func DecryptVidlinkStream(urlStr, tmdbID string, client *http.Client) (string, []string, string, error)
- func DecryptVidsrc(urlStr string, client *http.Client) (string, []string, string, error)
- func Download(basePath, dlPath, name, url, referer, userAgent string, subtitles []string, ...) error
- func DownloadHLS(ctx context.Context, streamURL, outputPath, referer string, ...) error
- func DownloadPoster(url string, title string) (string, error)
- func DownloadYTDLP(basePath, dlPath, name, url, referer, userAgent string, debug bool) error
- func FormatRecommendLabel(r Recommendation) string
- func FormatShowLabel(s ShowSummary) string
- func GetCacheDir() (string, error)
- func NewClient() *http.Client
- func NewRequest(method, url string) (*http.Request, error)
- func ParseEpisodeRange(s string) ([]int, error)
- func Play(url, title, referer, userAgent string, subtitles []string, debug bool, ...) (float64, error)
- func PreviewPoster(path string) error
- func PreviewWithBackend(path, backend string) error
- func Prompt(label string) string
- func Select(label string, items []string) int
- func SelectAction(label string, actions []string) string
- func SelectActionCtx(label string, actions []string, done <-chan struct{}) string
- func SelectQuality(qualities []Quality, selectBest bool) (string, error)
- func SelectWithPreview(label string, items []string, previewCmd string) int
- func StartPlayer(url, title, referer, userAgent string, subtitles []string, debug bool, ...) (*exec.Cmd, error)
- type Action
- type Config
- type Context
- type DB
- type DecryptResponse
- type DecryptedSource
- type DecryptedTrack
- type Episode
- type EpisodeData
- type HistoryEntry
- type MediaType
- type PlayResult
- type PlaybackAction
- type Provider
- type Quality
- type Recommendation
- type SearchResult
- type Season
- type Server
- type ShowSummary
- type TmdbEpisode
- type TmdbSearchResult
- type TmdbSeason
- type TmdbSeasonDetails
- type TmdbShowDetails
Constants ¶
const ( ActionPlay Action = "play" ActionDownload Action = "download" Movie MediaType = "movie" Series MediaType = "series" )
const ( FLIXHQ_BASE_URL = "https://flixhq.to" FLIXHQ_SEARCH_URL = FLIXHQ_BASE_URL + "/search" FLIXHQ_AJAX_URL = FLIXHQ_BASE_URL + "/ajax" TMDB_API_KEY = "653bb8af90162bd98fc7ee32bcbbfb3d" TMDB_BASE_URL = "https://api.themoviedb.org/3" )
const TMDB_IMAGE_BASE_URL = "https://image.tmdb.org/t/p/w500"
TMDB_IMAGE_BASE_URL is the prefix for constructing poster image URLs.
Variables ¶
var Version string = "v1.1.1"
Functions ¶
func CleanCache ¶
func CleanCache() error
func DecryptEmbedSu ¶
func DecryptGeneric ¶ added in v1.0.18
func DecryptMegacloud ¶ added in v1.0.18
func DecryptMegacloudFromPage ¶ added in v1.0.18
func DecryptMultiembed ¶ added in v1.0.18
func DecryptStream ¶
func DecryptVidlink ¶
func DecryptVidlinkStream ¶ added in v1.0.18
func DecryptVidsrc ¶
func Download ¶
func Download(basePath, dlPath, name, url, referer, userAgent string, subtitles []string, debug bool) error
Download downloads a stream to disk using a native Go implementation. HLS streams (*.m3u8) are downloaded by fetching and concatenating segments concurrently. Other URLs are downloaded directly, using parallel byte-range requests when the server supports them and the file is large enough.
Subtitle files (VTT/SRT) are downloaded alongside the video when provided.
func DownloadHLS ¶ added in v1.1.0
func DownloadHLS(ctx context.Context, streamURL, outputPath, referer string, progressCallback func(int, int)) error
DownloadHLS downloads an HLS stream to outputPath, reporting segment progress via progressCallback(downloadedSegments, totalSegments). Pass nil to skip progress reporting.
func DownloadYTDLP ¶ added in v1.1.0
DownloadYTDLP downloads a URL using yt-dlp. It is intended for providers (e.g. YouTube) whose URLs yt-dlp handles natively.
func FormatRecommendLabel ¶ added in v1.1.0
func FormatRecommendLabel(r Recommendation) string
FormatRecommendLabel returns the fzf label for a recommendation.
func FormatShowLabel ¶ added in v1.1.0
func FormatShowLabel(s ShowSummary) string
FormatShowLabel returns a human-readable fzf label for a show summary.
func GetCacheDir ¶
func ParseEpisodeRange ¶
func Play ¶
func Play(url, title, referer, userAgent string, subtitles []string, debug bool, startSecs float64) (float64, error)
Play starts the player and blocks until it exits. Returns the final playback position in seconds; 0 if not tracked.
func PreviewPoster ¶
func PreviewWithBackend ¶ added in v1.1.0
PreviewWithBackend renders the image at path using chafa with the given backend.
func SelectAction ¶ added in v1.1.0
SelectAction shows an fzf menu with the given action labels and returns the label of the chosen action. Returns "" if the selection is cancelled.
func SelectActionCtx ¶ added in v1.1.1
SelectActionCtx is like SelectAction but takes an optional done channel. If done is closed before the user makes a selection, fzf is killed and "" is returned — this lets the caller detect that the player exited on its own.
func SelectQuality ¶ added in v1.0.19
func SelectWithPreview ¶
func StartPlayer ¶ added in v1.1.0
func StartPlayer(url, title, referer, userAgent string, subtitles []string, debug bool, wlDir string, startSecs float64) (*exec.Cmd, error)
StartPlayer launches the player in the background with its output suppressed so the terminal stays available for the fzf control menu. wlDir is passed to mpv's --watch-later-directory if non-empty. startSecs, if > 0, tells mpv to seek to that position before playing. Returns the running *exec.Cmd so the caller can wait on or kill it.
Types ¶
type Config ¶
type Config struct {
FzfPath string `yaml:"fzf_path"`
Player string `yaml:"player"`
ImageBackend string `yaml:"image_backend"`
Provider string `yaml:"provider"`
DlPath string `yaml:"dl_path"`
Quality string `yaml:"quality"`
}
func LoadConfig ¶
func LoadConfig() *Config
type DB ¶ added in v1.1.0
type DB struct {
// contains filtered or unexported fields
}
DB wraps an open SQLite database for history operations.
func OpenHistory ¶ added in v1.1.0
OpenHistory opens (or creates) the history database.
func (*DB) AddEntry ¶ added in v1.1.0
func (db *DB) AddEntry(e HistoryEntry) error
AddEntry inserts a new history record.
func (*DB) GetLastPosition ¶ added in v1.1.1
GetLastPosition returns the most recently recorded playback position in seconds for the given title, season and episode. Returns 0 if no record is found.
func (*DB) ListShows ¶ added in v1.1.0
func (db *DB) ListShows() ([]ShowSummary, error)
ListShows returns one row per unique (title, url) pair, ordered by the most recent watch time descending. This is what --history displays.
type DecryptResponse ¶
type DecryptResponse struct {
Sources []DecryptedSource `json:"sources"`
Tracks []DecryptedTrack `json:"tracks"`
}
type DecryptedSource ¶
type DecryptedTrack ¶
type EpisodeData ¶
type HistoryEntry ¶ added in v1.1.0
type HistoryEntry struct {
ID int64
Title string
Season int // 0 for movies
Episode int // 0 for movies
EpName string // episode display name, empty for movies
URL string // provider media URL (used to resume)
Provider string // provider name (e.g. "flixhq", "sflix")
// PositionSecs is the playback position in seconds as written by mpv's
// watch-later file (e.g. 1234.56). 0 means start / not tracked.
PositionSecs float64
WatchedAt time.Time
}
HistoryEntry represents a single watch history record.
type PlayResult ¶ added in v1.1.1
type PlayResult struct {
Action PlaybackAction
PositionSecs float64 // seconds; 0 if not tracked
}
PlayResult bundles the chosen action and the final playback position.
func PlayWithControls ¶ added in v1.1.0
func PlayWithControls(url, title, referer, userAgent string, subtitles []string, debug bool, startSecs float64) (PlayResult, error)
PlayWithControls starts the player in the background and shows an fzf menu with Replay / Next / Previous / Quit. It kills the running player process before returning so the caller can act on the chosen action immediately. Returns a PlayResult containing the chosen action and the last tracked position.
type PlaybackAction ¶ added in v1.1.0
type PlaybackAction string
PlaybackAction represents what the user chose from the playback control menu.
const ( PlaybackReplay PlaybackAction = "Replay" PlaybackNext PlaybackAction = "Next" PlaybackPrevious PlaybackAction = "Previous" PlaybackQuit PlaybackAction = "Quit" )
type Provider ¶
type Provider interface {
Search(query string) ([]SearchResult, error)
GetMediaID(url string) (string, error)
GetSeasons(mediaID string) ([]Season, error)
GetEpisodes(id string, isSeason bool) ([]Episode, error)
GetServers(episodeID string) ([]Server, error)
GetLink(serverID string) (string, error)
}
type Quality ¶ added in v1.0.19
func GetBestQuality ¶ added in v1.0.19
type Recommendation ¶ added in v1.1.0
type Recommendation struct {
Title string
MediaType MediaType // Movie or Series
Year string
Overview string
TmdbID int
Score float64 // internal relevance score, higher is better
PosterPath string // TMDB poster_path (e.g. "/abc123.jpg"); build full URL with TMDB_IMAGE_BASE_URL
}
Recommendation is a title suggested based on watch history.
func GetRecommendations ¶ added in v1.1.0
func GetRecommendations(client *http.Client) ([]Recommendation, error)
GetRecommendations builds a taste profile from the user's watch history and returns a ranked list of titles the user has not yet watched.
Algorithm:
- Load history; assign each show a recency weight (exponential decay).
- For each show, fetch its TMDB genre and keyword IDs; accumulate into the taste profile weighted by recency.
- Derive the top genres from the profile and use /discover to pull a pool of candidate movies and TV shows.
- Score every candidate: sum of matched genre weight + keyword weight from the profile, multiplied by a quality factor (vote_average * log(vote_count+1)).
- Exclude already-watched titles, sort by score descending, return top 50.
type SearchResult ¶
type ShowSummary ¶ added in v1.1.0
type ShowSummary struct {
Title string
URL string
Provider string
Season int
Episode int
EpName string
WatchedAt time.Time
}
ShowSummary is one entry per unique show (title+url), carrying the most recent watch details so the user can resume from where they left off.
type TmdbEpisode ¶ added in v1.0.8
type TmdbSearchResult ¶ added in v1.0.8
type TmdbSearchResult struct {
Results []struct {
ID int `json:"id"`
MediaType string `json:"media_type"`
Title string `json:"title"`
Name string `json:"name"`
PosterPath string `json:"poster_path"`
ReleaseDate string `json:"release_date"`
FirstAirDate string `json:"first_air_date"`
} `json:"results"`
}
type TmdbSeason ¶ added in v1.0.8
type TmdbSeasonDetails ¶ added in v1.0.8
type TmdbSeasonDetails struct {
Episodes []TmdbEpisode `json:"episodes"`
}
type TmdbShowDetails ¶ added in v1.0.8
type TmdbShowDetails struct {
Seasons []TmdbSeason `json:"seasons"`
}