tv

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BBCPrefix = "https://bbc.co.uk"
	NipDB     = "progdb.json"
)

BBCPrefix is the iplayer hostname.

Variables

This section is empty.

Functions

func DBPath

func DBPath() string

DBPath returns the path to the json programme DB. If no db exists at this path, it creates an empty db and saves it to disk.

func RefreshDB

func RefreshDB(filename string)

RefreshDB makes a new Category for all entries in caturls, and if successful, stores them in ProgrammeDB.

Types

type BeebURL

type BeebURL string

BeebURL is the Url to an iplayer web site.

type Category

type Category struct {
	Name       string
	Programmes []*Programme
}

Category represents an Iplayer Prograamme, consisting of its name and a list of its programmes.

func NewCategory

func NewCategory(name string, np NextPager) *Category

NewCategory takes a category name and a category root document, generates a newMainCategory and returns a Category.

type IplayerDocumentResult

type IplayerDocumentResult struct {
	Idoc  iplayerDocument
	Error error
}

An IplayerDocumentResult is the result of generating a new goquery.Document from a iplayer Url. If successful, the Idoc will be an iplayerDocument and nil for The error field.

type MainCategoryDocument

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

A MainCategoryDocument is the collection point for an iplayer category. maindoc is the root (or page 1) document, nextdocs pages 2 - n, programpagedocs are the docuemnts for all programmes that have more than 1 episode, and selectionresults have the programmes with only one available episode.

func (*MainCategoryDocument) Programmes

func (mcd *MainCategoryDocument) Programmes() []*Programme

Programmes traverses all iplayerdocuments of an MainCategoryDocument and returns all their programmes.

type NextPager

type NextPager interface {
	// contains filtered or unexported methods
}

NextPager is the interface that wraps the mainDoc, nextPages and programPages methods.

The mainDoc method returns the root document of a Category, nextPages returns a slice of category pages 2 - n, and programPages returns the urls for all programmes on pages 1 - n, that have more than one episode available.

type Pager

type Pager interface {
	// contains filtered or unexported methods
}

Pager is the interface that wraps the loadDocument method.

loadDocument sends the result of generating a new iplayerDocument from either a remote Url, or the path to a local html file to a provided channel of type *IplayerDocumentResult.

type Programme

type Programme struct {
	Title     string `json:"Title"`
	Subtitle  string `json:"subtitle"`
	Synopsis  string `json:"synopsis"`
	Thumbnail string `json:"thumbnail"`
	URL       string `json:"Url"`
	Index     int    `json:"index"`
	Available string `json:"available"`
	Duration  string `json:"duration"`
}

Programme represents an Iplayer TV programme. It consists of the programme's Title, subtitle, a short programme description, The Iplayer Programme ID, the Url to its thumbnail, the Url to the programme's website and a unique index.

func (*Programme) String

func (p *Programme) String() string

type ProgrammeDB

type ProgrammeDB struct {
	Categories      []*Category       `json:"categories"`
	Saved           time.Time         `json:"saved"`
	SavedProgrammes []*SavedProgramme `json:"saved_programmes"`
}

ProgrammeDB represents a (file) DB of all saved Programmes, divided by Categories. The Saved field speciefies at what time the DB was last refreshed.

func RestoreProgrammeDB

func RestoreProgrammeDB(filename string) (*ProgrammeDB, error)

RestoreProgrammeDB takes a path to a json file, reads it, and if successful, unmarshals it as struct ProgrammeDB.

func (*ProgrammeDB) FindProgramme

func (pdb *ProgrammeDB) FindProgramme(index int) (*Programme, error)

FindProgramme takes an index, queries the ProgrammeDB for it, and if found, returns it.

func (pdb *ProgrammeDB) FindRelatedLinks(index int) ([]*RelatedLink, error)

FindRelatedLinks loads the root page of a Programme. If found, it returns a slice of its related links, e.g. IMDB, Wikipedia, RottenTomatoes,...

func (*ProgrammeDB) FindTitle

func (pdb *ProgrammeDB) FindTitle(title string) string

FindTitle searches for a given term in the ProgrammeDB. Whenever a programmes Title contains the searchterm, the programme is appended to the result string.

func (*ProgrammeDB) FindURL

func (pdb *ProgrammeDB) FindURL(index int) (string, error)

FindURL takes an index, queries the ProgrammeDB for it, and if found, returns the URL for the matching programme.

func (*ProgrammeDB) ListAvailableCategories

func (pdb *ProgrammeDB) ListAvailableCategories() string

ListAvailableCategories returns a string with the name of all categories stored in ProgrammeDB.

func (*ProgrammeDB) ListCategory

func (pdb *ProgrammeDB) ListCategory(category string) string

ListCategory takes the name for a category, searches the ProgrammeDB for it, and if found, returns a string with all the category's programmes.

func (*ProgrammeDB) MarkSaved

func (pdb *ProgrammeDB) MarkSaved(filename string)

MarkSaved adds the filename of a downloaded programme + the date when it was downloaded to the SavedProgrammes entry in the ProgrammeDB.

func (*ProgrammeDB) Save

func (pdb *ProgrammeDB) Save(filename string) error

Save takes a path to json file, adds the current time to field 'Saved', converts it to json in a human readable format, and if successful saves it to said file.

type RelatedLink struct {
	Title string
	URL   string
}

RelatedLink represents a link entry on a programme's root home page. It consists of a title, e.g. IMDB, and the url, e.g. https://www.imdb.com/title/tt0146316/?ref_=ttfc_fc_tt

type SavedProgramme

type SavedProgramme struct {
	File  string    `json:"url"`
	Saved time.Time `json:"saved"`
}

SavedProgramme is the url to a downloaded programme and the time it was downloaded.

type TestHTMLURL

type TestHTMLURL string

TestHTMLURL is the path to a local testhtml file.

type TestIplayerDocument

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

A TestIplayerDocument is a goquery.Document for a saved to file, copy of a BBC iplayer page.

Jump to

Keyboard shortcuts

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