Documentation
¶
Index ¶
- Constants
- Variables
- type BuildRequest
- type BuildResponse
- type DownloadFormat
- type DownloadRequest
- type DownloadResponse
- type Episode
- type EpisodeDownloader
- type Event
- func NewBuildRequestEvent(p BuildRequest) Event
- func NewBuildResponseEvent(p BuildResponse) Event
- func NewDownloadRequestEvent(p DownloadRequest) Event
- func NewDownloadResponseEvent(p DownloadResponse) Event
- func NewFeedInfoRequestEvent(p FeedInfoRequest) Event
- func NewFeedInfoResponseEvent(p FeedInfoResponse) Event
- type EventBus
- type EventHandler
- type EventType
- type FeedBuilder
- type FeedCategory
- type FeedInfo
- type FeedInfoRequest
- type FeedInfoResponse
- type FeedOwner
- type FeedType
- type MediaType
- type Platform
- type RequestSource
- type ResponseStatus
- type Store
Constants ¶
const ( MediaMp3 = feedcast.Mp3 MediaM4a = feedcast.M4a )
const ( FeedTypeNotSet = feedcast.TypeNotSet FeedTypeEpisodic = feedcast.TypeEpisodic FeedTypeSerial = feedcast.TypeSerial )
Variables ¶
var ( ErrBuildFeedFailed = errors.New("failed to build feed") ErrBuildLandingFailed = errors.New("failed to build landing page") ErrDownloadFailed = errors.New("failed to download episode") ErrDownloadInProgress = errors.New("episode already in progress") ErrDownloadExists = errors.New("episode already exists") ErrDownloadInterrupted = errors.New("episode download interrupted") ErrDownloadBusy = errors.New("downloader is busy") ErrNoMatchingPlatform = errors.New("no matching platform found") ErrInvalidUrl = errors.New("invalid download URL") ErrInvalidFormat = errors.New("unsupported download format") ErrDownloadQuality = errors.New("unsupported download quality") )
Domain errors
Functions ¶
This section is empty.
Types ¶
type BuildRequest ¶
type BuildRequest struct {
ID string // Unique request id
Source *RequestSource // User who made the request
}
BuildRequest represents a request to build the podcast feed and landing page.
func (BuildRequest) LogValue ¶
func (r BuildRequest) LogValue() slog.Value
LogValue implements slog.LogValuer interface
type BuildResponse ¶
type BuildResponse struct {
Status ResponseStatus
Error error
Request BuildRequest
}
BuildResponse represents the response for a BuildRequest.
func (BuildResponse) LogValue ¶
func (r BuildResponse) LogValue() slog.Value
LogValue implements slog.LogValuer interface
type DownloadFormat ¶
type DownloadFormat string
DownloadFormat is the format in which media should be downloaded (e.g., mp3, m4a) via DownloadRequest.
const ( DownloadMp3 DownloadFormat = "mp3" DownloadM4a DownloadFormat = "m4a" )
type DownloadRequest ¶
type DownloadRequest struct {
ID string // Unique request id
Source RequestSource // User who made the request
Url string // URL to download
DownloadFormat DownloadFormat // Format to download (e.g., mp3, m4a)
DownloadQuality string // Quality of the download (e.g., 128kbps)
}
DownloadRequest represents a request to download episode from a URL.
func (DownloadRequest) LogValue ¶
func (r DownloadRequest) LogValue() slog.Value
LogValue implements slog.LogValuer interface
type DownloadResponse ¶
type DownloadResponse struct {
Status ResponseStatus
Error error
Episode *Episode
Request DownloadRequest
}
DownloadResponse represents the response for a DownloadRequest.
func (DownloadResponse) LogValue ¶
func (r DownloadResponse) LogValue() slog.Value
LogValue implements slog.LogValuer interface
type Episode ¶
type Episode struct {
ID int64
Title string
Description string
ThumbnailFile string
MediaFile string
MediaType MediaType
MediaDuration int64
MediaSize int64
Author string
OriginalURL string
CanonicalURL string
CreatedAt time.Time
}
Episode represents a podcast episode.
type EpisodeDownloader ¶
type EpisodeDownloader interface {
Validate(ctx context.Context, request DownloadRequest) error
Download(ctx context.Context, request DownloadRequest) (*Episode, error)
}
EpisodeDownloader should download episode.
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
func NewBuildRequestEvent ¶
func NewBuildRequestEvent(p BuildRequest) Event
NewBuildRequestEvent creates a new Event for BuildRequest.
func NewBuildResponseEvent ¶
func NewBuildResponseEvent(p BuildResponse) Event
NewBuildResponseEvent creates a new Event for BuildResponse.
func NewDownloadRequestEvent ¶
func NewDownloadRequestEvent(p DownloadRequest) Event
NewDownloadRequestEvent creates a new Event for DownloadRequest.
func NewDownloadResponseEvent ¶
func NewDownloadResponseEvent(p DownloadResponse) Event
NewDownloadResponseEvent creates a new Event for DownloadResponse.
func NewFeedInfoRequestEvent ¶
func NewFeedInfoRequestEvent(p FeedInfoRequest) Event
NewFeedInfoRequestEvent creates a new Event for FeedInfoRequest.
func NewFeedInfoResponseEvent ¶
func NewFeedInfoResponseEvent(p FeedInfoResponse) Event
NewFeedInfoResponseEvent creates a new Event for FeedInfoResponse.
func (Event) LogValue ¶
LogValue implements slog.LogValuer interface
type EventBus ¶
type EventBus interface {
Publish(event Event)
Subscribe(eventType EventType, handler EventHandler)
Wait()
}
EventBus is an event bus for processing requests.
type EventHandler ¶
type EventHandler func(event Event)
EventHandler is a function that processes an event.
type FeedBuilder ¶
type FeedBuilder interface {
Build(ctx context.Context) error
Info(ctx context.Context) (*FeedInfo, error)
}
FeedBuilder should build podcast RSS feed and landing page.
type FeedCategory ¶
FeedCategory contains information about podcast category
type FeedInfo ¶
type FeedInfo struct {
Title string // Show title
Description string // Show description
Summary string // Show summary
Language string // Lang code
Categories []FeedCategory // Podcast categories
Keywords string // Podcast keywords comma separated
Author string // Podcast author name
Owner *FeedOwner // Podcast owner info
Copyright string // Show copyright info if any
Explicit bool // Is the show explicit
FeedType FeedType // The type of the show
FeedCompleted bool // Is the show completed
FeedBlocked bool // Is the show blocked in Apple Podcasts
WebsiteLink string // Website link
RSSLink string // RSS feed link
ImageUrl string // Cover image link
Generator string // RSS generator software
PubDate time.Time // Last published date. Zero time if no episodes
EpisodeCount int // Number of episodes in the feed
FeedMaxEpisodes int // Maximum number of episodes in the feed (0 means no limit)
}
FeedInfo contains information about podcast feed
type FeedInfoRequest ¶
type FeedInfoRequest struct {
ID string // Unique request id
Source RequestSource // User who made the request
}
func (FeedInfoRequest) LogValue ¶
func (r FeedInfoRequest) LogValue() slog.Value
LogValue implements slog.LogValuer interface
type FeedInfoResponse ¶
type FeedInfoResponse struct {
Status ResponseStatus
Error error
FeedInfo *FeedInfo
Request FeedInfoRequest
}
func (FeedInfoResponse) LogValue ¶
func (r FeedInfoResponse) LogValue() slog.Value
LogValue implements slog.LogValuer interface
type FeedType ¶
type FeedType = feedcast.ItunesType
FeedType represents the type of show. If your show is Serial you must use this tag. See feedcast.ItunesType for possible values.
type MediaType ¶
type MediaType = feedcast.EnclosureType
MediaType is the MIME type of the media file.
type Platform ¶
type Platform interface {
ID() string
Init(ctx context.Context) error
Match(request DownloadRequest) bool
Download(ctx context.Context, request DownloadRequest) (*Episode, error)
}
Platform should be able to download episodes from a specific platform.
type RequestSource ¶
type RequestSource struct {
UserID int64 // Telegram user ID
ChatID int64 // Telegram chat ID
MessageID int // Telegram message ID
}
RequestSource contains data about user who made the RequestType.
func (RequestSource) LogValue ¶
func (r RequestSource) LogValue() slog.Value
LogValue implements slog.LogValuer interface
type ResponseStatus ¶
type ResponseStatus int
ResponseStatus is the current status of the Response.
const ( StatusPending ResponseStatus = iota // Being processed StatusSuccess // Successfully processed (final state) StatusFailed // Processing failed (final state) )
func (ResponseStatus) String ¶
func (s ResponseStatus) String() string
type Store ¶
type Store interface {
// Close the store and release all resources.
Close()
// Begin starts a new transaction and returns a new Store instance.
Begin(ctx context.Context) (Store, error)
// Commit commits the current transaction.
Commit() error
// Rollback aborts the current transaction.
Rollback() error
// EpisodeCreate creates a new episode in the store.
EpisodeCreate(ctx context.Context, episode *Episode) error
// EpisodeGet returns all episodes from the store in descending order by creation date.
// Supports pagination via pageSize and pageNumber parameters.
// Zero values for pageSize and pageNumber will return all episodes without pagination.
EpisodeGet(ctx context.Context, pageSize, pageNumber int) ([]*Episode, error)
// EpisodeCount returns the total count of episodes in the store.
EpisodeCount(ctx context.Context) (int, error)
// EpisodeGetByUrl returns episodes matching the given original or canonical URL.
EpisodeGetByUrl(ctx context.Context, url string) ([]*Episode, error)
// EpisodeGetOldest returns the oldest episodes from the store.
EpisodeGetOldest(ctx context.Context, limit int) ([]*Episode, error)
// EpisodeDelete deletes an episode from the store.
EpisodeDelete(ctx context.Context, id int64) error
}
Store defines the interface for a data store that manages episodes.