Documentation ¶
Index ¶
- Constants
- func DBPath() string
- func RefreshDB(filename string)
- type BeebURL
- type Category
- type IplayerDocumentResult
- type MainCategoryDocument
- type NextPager
- type Pager
- type Programme
- type ProgrammeDB
- func (pdb *ProgrammeDB) FindProgramme(index int) (*Programme, error)
- func (pdb *ProgrammeDB) FindRelatedLinks(index int) ([]*RelatedLink, error)
- func (pdb *ProgrammeDB) FindTitle(title string) string
- func (pdb *ProgrammeDB) FindURL(index int) (string, error)
- func (pdb *ProgrammeDB) ListAvailableCategories() string
- func (pdb *ProgrammeDB) ListCategory(category string) string
- func (pdb *ProgrammeDB) MarkSaved(filename string)
- func (pdb *ProgrammeDB) Save(filename string) error
- type RelatedLink
- type SavedProgramme
- type TestHTMLURL
- type TestIplayerDocument
Constants ¶
const ( BBCPrefix = "https://bbc.co.uk" NipDB = "progdb.json" )
BBCPrefix is the iplayer hostname.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Category ¶
Category represents an Iplayer Prograamme, consisting of its name and a list of its programmes.
func NewCategory ¶
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.
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 (*ProgrammeDB) FindRelatedLinks ¶
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 ¶
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 ¶
SavedProgramme is the url to a downloaded programme and the time it was downloaded.
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.