Documentation
¶
Index ¶
- Constants
- Variables
- func BuildVersion() string
- func CollectionSource(source string) (string, error)
- func CredentialValid(value string) bool
- func EventString(event map[string]any, key string) (string, error)
- func FFmpegConfiguration() string
- func FastStart(path string) (bool, error)
- func FileHash(path string) (int64, string, error)
- func IsYouTubeSource(source string) bool
- func Language(value string) (string, error)
- func LoadAuth(config Config) string
- func Logout(config Config) error
- func MediaDuration(path string) (int64, error)
- func NewHTTPClients() (*http.Client, *http.Client, error)
- func Nonblank(value string) (string, error)
- func PrepareAudio(ctx context.Context, inputPath, outputPath string) (err error)
- func PrepareVideo(ctx context.Context, directory string, separateAudio bool, maxHeight int, ...) (int64, error)
- func ReadBounded(reader io.Reader, limit int64) ([]byte, error)
- func Redact(message string) string
- func Slug(value string) (string, error)
- func TransferTotals(sent, total int64) string
- func ValidID(value, prefix string) bool
- func WritePrivateJSON(path string, value any) error
- type API
- func (api *API) AuthStatus(ctx context.Context) (string, error)
- func (api *API) CreateEpisode(ctx context.Context, args EpisodeCreate, output, diagnostics io.Writer) error
- func (api *API) Do(request *http.Request) (*http.Response, error)
- func (api *API) Episodes(ctx context.Context, slug string, limit int) ([]p.EpisodeListItem, error)
- func (api *API) Events(ctx context.Context, path string) (*Events, error)
- func (api *API) Inventory(ctx context.Context, slug string) (p.SyncInventory, error)
- func (api *API) JSON(ctx context.Context, method, path string, body, out any) error
- func (api *API) Login(ctx context.Context, client p.AuthorizationClient, open func(string)) error
- func (api *API) SetOrder(ctx context.Context, slug string, collection *string, ids []string) (p.EpisodeOrder, error)
- func (api *API) TeamID(ctx context.Context) (string, error)
- func (api *API) UploadArtwork(ctx context.Context, show string, raw []byte) (string, error)
- func (api *API) UploadArtworkFile(ctx context.Context, show, path string) (string, error)
- func (api *API) UploadObject(ctx context.Context, path, contentType, method, uploadURL string, ...) error
- func (api *API) UploadPart(ctx context.Context, path string, offset, length int64, ...) (string, error)
- func (api *API) UploadSourceArtwork(ctx context.Context, show, source string) (string, error)
- type ByteRange
- type Catalog
- type Client
- func (c *Client) API(ctx context.Context) (*API, error)
- func (c *Client) Artwork(ctx context.Context, target string) ([]byte, error)
- func (c *Client) CachedCatalog(ctx context.Context) (Catalog, bool, error)
- func (c *Client) CachedEpisodes(ctx context.Context, slug string) ([]p.EpisodeListItem, bool, error)
- func (c *Client) Catalog(ctx context.Context) (Catalog, error)
- func (c *Client) CheckYouTubeJS(ctx context.Context) error
- func (c *Client) Close() error
- func (c *Client) CookieJar() *CookieJar
- func (c *Client) Episodes(ctx context.Context, slug string) ([]p.EpisodeListItem, error)
- func (c *Client) HasCredentials() bool
- func (c *Client) Import(ctx context.Context, source, team string, kind p.ShowSourceKind, ...) (p.Show, Report, error)
- func (c *Client) Login(ctx context.Context, open func(string)) error
- func (c *Client) Logout() error
- func (c *Client) Sync(ctx context.Context, slug string) (Report, error)
- func (c *Client) SyncDue(ctx context.Context, shows []p.Show) ([]string, error)
- func (c *Client) SyncState(ctx context.Context, slug string) (SyncState, error)
- func (c *Client) SyncYouTube(ctx context.Context, show string, watch bool, event func(SyncEvent)) error
- func (c *Client) WatchYouTubeJS(ctx context.Context) func()
- type Config
- type CookieJar
- type Database
- func (db *Database) Close() error
- func (db *Database) CompleteSync(ctx context.Context, origin, show string) error
- func (db *Database) Directory(operation string) (string, error)
- func (db *Database) Download(ctx context.Context, operation, name, identity string) error
- func (db *Database) Forget(ctx context.Context, origin, show, source string) error
- func (db *Database) HasPart(ctx context.Context, operation string, object int, part int32) (bool, error)
- func (db *Database) HasSegment(ctx context.Context, operation, name string) (bool, error)
- func (db *Database) Items(ctx context.Context, origin, show string) ([]Download, error)
- func (db *Database) LastSynced(ctx context.Context, origin, show string) (*time.Time, error)
- func (db *Database) Operation(ctx context.Context, origin, show, source, collection string) (string, error)
- func (db *Database) Outcome(ctx context.Context, origin, show string, item Download) error
- func (db *Database) Prepared(ctx context.Context, operation string) (*p.CreateEpisodePackage, error)
- func (db *Database) Published(ctx context.Context, origin, show string, sources []string) error
- func (db *Database) RangeHash(ctx context.Context, operation, name string, start int64) (string, error)
- func (db *Database) SavePart(ctx context.Context, operation string, object int, part int32) error
- func (db *Database) SavePrepared(ctx context.Context, manifest p.CreateEpisodePackage) error
- func (db *Database) SaveRange(ctx context.Context, operation, name string, start int64, hash string) error
- func (db *Database) SaveSegment(ctx context.Context, operation, name string) error
- func (db *Database) Session(ctx context.Context, operation, session string) error
- func (db *Database) Snapshot(ctx context.Context, origin, show, collection string, videos []Video, ...) error
- type Download
- type DownloadManager
- type Engine
- func (e *Engine) Close() error
- func (e *Engine) Database(ctx context.Context, config Config) (*Database, error)
- func (e *Engine) Import(ctx context.Context, api *API, source, team, requestedSlug string, ...) (p.Show, Report, error)
- func (e *Engine) NextScan(ctx context.Context) bool
- func (e *Engine) Once(ctx context.Context, api *API, slug string) (Report, error)
- type EpisodeCreate
- type Events
- type HTTPError
- type ImportEvent
- type Media
- type MediaStream
- type Phase
- func Complete() Phase
- func Downloading() Phase
- func Failed() Phase
- func NewPhaseFromValue(value string) (Phase, error)
- func Preparing() Phase
- func Publishing() Phase
- func Queued() Phase
- func Resolving() Phase
- func Retrying() Phase
- func Skipped() Phase
- func Uploading() Phase
- func WaitingToPrepare() Phase
- func WaitingToUpload() Phase
- type PlaylistScan
- type PlaylistSnapshot
- type Report
- type Stage
- type StoredAuth
- type SyncEvent
- type SyncState
- type Video
- type YouTube
- func (yt *YouTube) Close()
- func (yt *YouTube) CompletePlaylist(ctx context.Context, page youtubei.Playlist, progress func(PlaylistScan)) (PlaylistSnapshot, error)
- func (yt *YouTube) FallbackMedia(ctx context.Context, id string, media *Media, refused *MediaStream) (bool, error)
- func (yt *YouTube) Media(ctx context.Context, id, collection string) (*Media, string, error)
- func (yt *YouTube) PlaylistHead(ctx context.Context, id string) (youtubei.Playlist, error)
- func (yt *YouTube) Snapshot(ctx context.Context, id string) (PlaylistSnapshot, error)
- func (yt *YouTube) VideoSnapshot(ctx context.Context, id string) (PlaylistSnapshot, error)
Constants ¶
const (
CookieGuideURL = "https://listenbox.app/guides/import-youtube-as-a-podcast/#when-youtube-asks-you-" +
"to-sign-in"
)
const RangeBytes = int64(1024 * 1024)
Variables ¶
var ( //nolint:revive,staticcheck // Preserve existing end-user guidance. ErrAuthentication = errors.New( "Sign in to Listenbox to continue.", ) //nolint:staticcheck // Preserve existing end-user guidance. ErrSyncStopped = errors.New( "The server stopped YouTube importing for this show. Progress is saved; refresh t" + "he podcast list.", ) ErrMediaUnavailable = errors.New( "YouTube refused the media download (HTTP 403). Try syncing again.", ) //nolint:staticcheck // Preserve existing end-user guidance. ErrSignInRequired = errors.New( "YouTube needs a signed-in session. Open Settings → YouTube to paste fresh cook" + "ies, or run listenbox youtube cookies import <cookies.txt>, then sync again.", ) // ErrRateLimited reports that YouTube throttled this session's player // requests; YouTube lifts it after up to an hour. ErrRateLimited = errors.New("YouTube is rate-limiting this computer") )
var ( Production = "0" Version string SourceCommit string )
var ErrUploadStalled = errors.New("upload stalled; resumable source upload state preserved")
Functions ¶
func BuildVersion ¶
func BuildVersion() string
BuildVersion uses the embedded release identity unless a build overrides it.
func CollectionSource ¶
func CredentialValid ¶
func FFmpegConfiguration ¶
func FFmpegConfiguration() string
FFmpegConfiguration identifies the linked, source-built codec library in diagnostics. astiav exposes codecs but not avcodec_configuration itself.
func IsYouTubeSource ¶
func MediaDuration ¶
func PrepareAudio ¶
func PrepareVideo ¶
func TransferTotals ¶ added in v0.2.37
TransferTotals formats sent and total bytes in MB, or in GB once the total reaches one gigabyte, with two decimals there so progress keeps moving.
func WritePrivateJSON ¶
Types ¶
type API ¶
type API struct {
Config Config
Credential string
HTTP *http.Client
UploadHTTP *http.Client
Public *p.Client
Clock clockwork.Clock
// contains filtered or unexported fields
}
func NewAPIWithClients ¶
func (*API) CreateEpisode ¶
func (*API) UploadArtwork ¶
func (*API) UploadArtworkFile ¶
func (*API) UploadObject ¶ added in v0.2.47
func (api *API) UploadObject( ctx context.Context, path, contentType, method, uploadURL string, progress func(int64), ) error
UploadObject uploads a whole file with one signed request whose signature covers its content type and length.
func (*API) UploadPart ¶
type Client ¶
func (*Client) Artwork ¶
Artwork retrieves a public cover through the profile's persistent HTTP cache. Revalidation stays synchronous so cancellation and logout own every request.
func (*Client) CachedCatalog ¶ added in v0.2.40
CachedCatalog returns the catalog last fetched with the current credential.
func (*Client) CachedEpisodes ¶ added in v0.2.40
func (c *Client) CachedEpisodes(ctx context.Context, slug string) ([]p.EpisodeListItem, bool, error)
CachedEpisodes returns the podcast's episode list last fetched with the current credential.
func (*Client) CheckYouTubeJS ¶ added in v0.2.53
CheckYouTubeJS adopts a newer signed YouTube.js release, if there is one.
func (*Client) HasCredentials ¶
func (*Client) SyncDue ¶ added in v0.2.40
SyncDue lists the podcasts a launch should sync: those no client finished syncing within the scan interval, and those with videos this computer still has queued. The hourly scan syncs every podcast regardless.
func (*Client) SyncYouTube ¶
func (*Client) WatchYouTubeJS ¶ added in v0.2.53
WatchYouTubeJS checks for YouTube.js releases now and then every ten minutes until ctx ends or the returned stop function is called. Checks are conditional, so unchanged releases cost one 304 response.
type Config ¶
type Config struct {
APIOrigin string `json:"api_origin" yaml:"api_origin"`
DashboardOrigin string `json:"dashboard_origin" yaml:"dashboard_origin"`
Directory string `json:"-" yaml:"-"`
}
func LoadConfig ¶
func LoadConfigIn ¶
type CookieJar ¶
type CookieJar struct {
// contains filtered or unexported fields
}
func NewCookieJar ¶
func (*CookieJar) ImportFile ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database owns durable checkpoints. Once admitted, journal operations drain independently of request cancellation; the client joins them before Close.
func (*Database) CompleteSync ¶
func (*Database) HasSegment ¶ added in v0.2.47
func (*Database) LastSynced ¶
func (*Database) SavePrepared ¶
func (*Database) SaveSegment ¶ added in v0.2.47
type Download ¶
type DownloadManager ¶
type DownloadManager struct {
Changed func()
// contains filtered or unexported fields
}
func NewDownloadManager ¶
func NewDownloadManager() *DownloadManager
func (*DownloadManager) Changes ¶
func (m *DownloadManager) Changes() <-chan struct{}
func (*DownloadManager) Clear ¶
func (m *DownloadManager) Clear()
func (*DownloadManager) Limits ¶
func (m *DownloadManager) Limits() (int, int)
func (*DownloadManager) Snapshot ¶
func (m *DownloadManager) Snapshot() []Download
type Engine ¶
type Engine struct {
Downloads *DownloadManager
// contains filtered or unexported fields
}
type EpisodeCreate ¶
type EpisodeCreate struct {
Show, Title, File string
Description *string
Publication p.EpisodePublication
}
type ImportEvent ¶
type Media ¶
type Media struct {
Title, Description, ArtworkURL string
PublishedAt, EstimatedSeconds int64
DurationSeconds *int64
Video MediaStream
Audio *MediaStream
// contains filtered or unexported fields
}
type MediaStream ¶
type MediaStream struct {
URL, UserAgent, Identity string
// contains filtered or unexported fields
}
type Phase ¶
type Phase struct {
// contains filtered or unexported fields
}
func Downloading ¶
func Downloading() Phase
func NewPhaseFromValue ¶
func Publishing ¶
func Publishing() Phase
func WaitingToPrepare ¶
func WaitingToPrepare() Phase
func WaitingToUpload ¶
func WaitingToUpload() Phase
type PlaylistScan ¶
type PlaylistSnapshot ¶
type Stage ¶
type Stage struct {
// contains filtered or unexported fields
}
func DownloadStage ¶
func DownloadStage() Stage
func PrepareStage ¶
func PrepareStage() Stage
func UploadStage ¶
func UploadStage() Stage
type StoredAuth ¶
type StoredAuth struct {
APIKey string `json:"api_key"`
}
type YouTube ¶
type YouTube struct {
// contains filtered or unexported fields
}
func (*YouTube) CompletePlaylist ¶
func (yt *YouTube) CompletePlaylist( ctx context.Context, page youtubei.Playlist, progress func(PlaylistScan), ) (PlaylistSnapshot, error)
func (*YouTube) FallbackMedia ¶
func (*YouTube) PlaylistHead ¶
func (*YouTube) VideoSnapshot ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package youtubejsrelease defines the signed manifest that authenticates YouTube.js bundles published as GitHub releases of the fork.
|
Package youtubejsrelease defines the signed manifest that authenticates YouTube.js bundles published as GitHub releases of the fork. |