util

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2019 License: GPL-3.0, GPL-3.0-or-later Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateChannelPage

func CreateChannelPage(channel *Channel, projectRoot string) error

CreateChannelPage takes the permalink for the channel and creates a .md file in the content directory.

func CreateChannelVideoFolder

func CreateChannelVideoFolder(channel *Channel, projectRoot string) error

CreateChannelVideoFolder creates an empty folder within the videos data folder

func GetCreatorVideos

func GetCreatorVideos(slug string, projectRoot string) ([]string, error)

GetCreatorVideos returns a list of video IDs for a given creator

func SaveChannel

func SaveChannel(channel *Channel, dataDir string) error

SaveChannel saves an individual channel, overwriting the channel file if it already exists

func SaveChannels

func SaveChannels(channelList ChannelList, dataDir string) bool

SaveChannels saves all the channel definitions back to disk

Types

type Channel

type Channel struct {
	Name      string
	Slug      string
	Permalink string
	Providers map[string]Provider
	Tags      []interface{}
	// contains filtered or unexported fields
}

Channel represents a YouTube channel and it's associated providers

func (*Channel) GetChannelPage

func (c *Channel) GetChannelPage(projectRoot string) *ChannelPage

GetChannelPage returns the ChannelPage for the specifid channel

func (Channel) MarshalYAML

func (c Channel) MarshalYAML() (interface{}, error)

MarshalYAML handles the well defined channel details as well as any other fields specified

func (*Channel) UnmarshalYAML

func (c *Channel) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML handles the well defined channel details as well as any other fields specified

func (Channel) YouTubeURL

func (c Channel) YouTubeURL() *URL

YouTubeURL fetches the URL if this channel has the encoded provider URL and falls back to the top level channel URL if it's not found.

type ChannelList

type ChannelList map[string]Channel

ChannelList is a collection of channels

func LoadChannels

func LoadChannels(dataDir string) ChannelList

LoadChannels reads all the channel definitions off disk

func (ChannelList) Contains

func (channelList ChannelList) Contains(slug string) bool

Contains returns true if the supplied URL matches any provider's URL

func (ChannelList) Find

func (channelList ChannelList) Find(slug string) (*Channel, bool)

Find returns a channel that matches the specified slug

type ChannelPage

type ChannelPage struct {
	Aliases    []string `yaml:",omitempty"`
	Title      string
	TypeString string `yaml:"type"` // type is reserved
	Channel    string
	Tags       []string
	Url        string
	Videos     []string `yaml:",omitempty"`
	Menu       struct {
		Main struct {
			Parent string
		}
	}
}

ChannelPage represents all the fields required to create a channel specific page.

func (*ChannelPage) AddVideo

func (cp *ChannelPage) AddVideo(id string, projectRoot string) error

AddVideo adds a new video to the channel page and saves it

type Provider

type Provider struct {
	Name        string
	Slug        string
	URL         *URL
	Description string
	Subscribers uint64
}

Provider is one of youtube or patreon

type URL

type URL url.URL

URL is a newtype wrapper for url.URL which adds handling for yaml

func MustParseURL

func MustParseURL(input string) *URL

MustParseURL is designed for parsing valid URLs, known to be valid at compile time

func ParseURL

func ParseURL(input string) (*URL, error)

ParseURL is a wrapper function for url.Parse which returns the URL newtype

func (URL) MarshalYAML

func (u URL) MarshalYAML() (interface{}, error)

MarshalYAML converts a URL to a literal string (instead of the GO default of breaking it up into its components)

func (URL) String

func (u URL) String() string

func (*URL) UnmarshalYAML

func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML converts a string to a URL

Jump to

Keyboard shortcuts

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