clients

package
v0.0.0-...-96d54e8 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RSSLog  = "RssClient"
	DLLog   = "Downloader"
	TCPALog = "TCPAudio"
)

Variables

This section is empty.

Functions

func InitLoggers

func InitLoggers(factory func(prefix string) *log.Logger)

InitLoggers should be called by the bootstrapping application to assign log.Logger instances to the various clients

Types

type Channel

type Channel struct {
	XMLName     xml.Name `xml:"channel"`
	Item        []Item   `xml:"item"`
	Generator   string   `xml:"generator"`
	Title       string   `xml:"title"`
	Description string   `xml:"description"`
	Language    string   `xml:"language"`
	PubDate     string   `xml:"pubDate"`
}

Channel data represents an entire podcast.

type ChunkBufferStreamer

type ChunkBufferStreamer struct {
	beep.StreamSeekCloser

	Episode string
	// contains filtered or unexported fields
}

func NewChunkBufferStreamer

func NewChunkBufferStreamer(url string) (*ChunkBufferStreamer, beep.Format)

func (*ChunkBufferStreamer) Close

func (cb *ChunkBufferStreamer) Close() error

func (*ChunkBufferStreamer) Length

func (cb *ChunkBufferStreamer) Length() int

func (*ChunkBufferStreamer) Position

func (cb *ChunkBufferStreamer) Position() int

func (*ChunkBufferStreamer) RequestChunkAtOffset

func (cb *ChunkBufferStreamer) RequestChunkAtOffset(offset int) io.ReadCloser

func (*ChunkBufferStreamer) RequestSampleRange

func (cb *ChunkBufferStreamer) RequestSampleRange(start, end int) (io.ReadCloser, *http.Response)

func (*ChunkBufferStreamer) Seek

func (cb *ChunkBufferStreamer) Seek(p int) error

func (*ChunkBufferStreamer) Stream

func (cb *ChunkBufferStreamer) Stream(samples [][2]float64) (int, bool)

type ClientStreamer

type ClientStreamer struct {
	Buff *beep.Buffer
	// contains filtered or unexported fields
}

func StreamDecode

func StreamDecode(audio io.ReadCloser) (*ClientStreamer, beep.Format, error)

StreamDecode is replicating the interface of mp3.Decode returning a buffer instead of a reader. It acts as a wrapper to asynchronously buffer the tcp audio stream.

func (*ClientStreamer) Close

func (client *ClientStreamer) Close() error

func (*ClientStreamer) Err

func (client *ClientStreamer) Err() error

func (*ClientStreamer) Len

func (client *ClientStreamer) Len() int

func (*ClientStreamer) Position

func (client *ClientStreamer) Position() int

func (*ClientStreamer) Seek

func (client *ClientStreamer) Seek(p int) error

func (*ClientStreamer) Stream

func (client *ClientStreamer) Stream(samples [][2]float64) (n int, ok bool)

func (*ClientStreamer) String

func (client *ClientStreamer) String() string

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder is a ripoff of the streamer that mp3.Decode returns but with a Decoder.SetLength. All the methods are identical except the Decoder.SetLength.

func TcpDiskBufferedStreamer

func TcpDiskBufferedStreamer(url string, logger *log.Logger, cachePath string) (streamer *Decoder, format beep.Format)

TcpDiskBufferedStreamer is basically a proxy to some hacked together beep source code, all credit to them, unless the code looks a bit messy, that's probably us.

func (*Decoder) Close

func (d *Decoder) Close() error

func (*Decoder) Err

func (d *Decoder) Err() error

func (*Decoder) Len

func (d *Decoder) Len() int

func (*Decoder) Position

func (d *Decoder) Position() int

func (*Decoder) Seek

func (d *Decoder) Seek(p int) error

func (*Decoder) SetLength

func (d *Decoder) SetLength(length int)

func (*Decoder) Stream

func (d *Decoder) Stream(samples [][2]float64) (n int, ok bool)

type DownloadClient

type DownloadClient struct {
	Client *grab.Client
}

func NewClient

func NewClient() *DownloadClient

func (*DownloadClient) CreateRequests

func (c *DownloadClient) CreateRequests(urls []string) (reqs []*grab.Request)

func (*DownloadClient) DownloadEpisode

func (c *DownloadClient) DownloadEpisode(req *grab.Request)

func (*DownloadClient) DownloadMulti

func (c *DownloadClient) DownloadMulti(urls ...string)

type Enclosure

type Enclosure struct {
	Url    string `xml:"url,attr"`
	Length int64  `xml:"length,attr"`
	Type   string `xml:"type,attr"`
}

type FeedCache

type FeedCache map[string]*RSSFeed

type Item

type Item struct {
	XMLName     xml.Name  `xml:"item"`
	Title       string    `xml:"title"`
	Description string    `xml:"description"`
	PubDate     string    `xml:"pubDate"`
	Author      string    `xml:"author"`
	Link        string    `xml:"link"`
	Enclosure   Enclosure `xml:"enclosure"`
}

Item contains data for individual episodes.

type RSSFeed

type RSSFeed struct {
	XMLName xml.Name  `xml:"rss"`
	Channel []Channel `xml:"channel"`
}

Defining Structs to parse clients Feed xml from HTTP request. The full feed including header.

func GetContent

func GetContent(url string) (*RSSFeed, error)

GetContent retrieves a clients Feed via HTTP Request. Parse the xml in the response into structs. Exit & Print in the event of an error.

func (*RSSFeed) EpisodeData

func (RSSFeed *RSSFeed) EpisodeData(feed RSSFeed)

EpisodeData iterates over Item structs within the Channel struct. Print some episode information to the terminal.

func (RSSFeed *RSSFeed) EpisodeLink(feed RSSFeed, episodeNumber int) string

EpisodeLink returns the link for a single episode.

type SizedResult

type SizedResult struct {
	Size int64
	Err  error
}

SizedResult is the struct that encapsulates the error on failure or the size, either predicted or written to disk, of the corresponding data in bytes

func Fail

func Fail(failure error) *SizedResult

Fail is the named constructor for the case that the copy to disk fails

func Success

func Success(size int64) *SizedResult

Success is the named constructor for the case that the download completes successfully

func (*SizedResult) IsSuccess

func (r *SizedResult) IsSuccess() bool

IsSuccess returns true if the SizedResult.Err is not nil, i.e. a return value of true corresponds to the file being successfully downloaded

Jump to

Keyboard shortcuts

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