Documentation ¶
Index ¶
- Variables
- func AddNewEpisode(cfg *Config, feed *podcast.Podcast) error
- func CreateFeedItem(cfg *Config) (*etree.Element, error)
- func GetEpisodeDetails(trackName, podcastYAML string) (map[string]interface{}, error)
- func ReadXML(feedFileName string) (*podcast.Podcast, error)
- func WriteXML(p *podcast.Podcast)
- type Config
- type Podcast
Constants ¶
This section is empty.
Variables ¶
var DownloadFile = func(URL, fileName string) error { file, err := os.Create(fileName) if err != nil { return err } resp, err := http.Get(URL) if err != nil { return err } defer resp.Body.Close() _, err = io.Copy(file, resp.Body) if err != nil { return err } defer file.Close() return nil }
DownloadFile allows to download a URL content into a file.
var GetEpisodeLength = func(URL string) (int, error) { res, err := http.Head(URL) if err != nil { return 0, err } return int(res.ContentLength), nil }
GetEpisodeLength returns the Content-Length HTTP header value for a URL.
var GetFeed = func(URL string) (string, error) { resp, err := http.Get(URL) if err != nil { return "", err } defer resp.Body.Close() bodyBytes, err := ioutil.ReadAll(resp.Body) if err != nil { return "", err } return string(bodyBytes), nil }
GetFeed returns the content of the XML feed defined in `URL`, or an error.
var GetPubDate = time.Now
GetPubDate returns the `time.Time` value for current publication.
var GetScript = func(episodeTag string) (string, error) { q := fmt.Sprintf("name contains '%v'", episodeTag) svc, err := gdrive.GetService(os.Getenv("DRIVE_CREDENTIALS_FILE")) if err != nil { return "", err } if len(q) == 0 { return "", fmt.Errorf("no matching scripts, please add a query returning one single document") } r, err := stationery.GetFiles(svc, q) if err != nil { return "", err } if len(r) > 1 { return "", fmt.Errorf("too many results. Query must return only one document, not %v", len(r)) } content, err := stationery.ExportHTML(svc, r[0]) if err != nil { return "", err } return content, nil }
GetScript returns the content of the script which name matches the `episodeTag` in HTML, or an error.
Functions ¶
func AddNewEpisode ¶
AddNewEpisode creates a new episode from `cfg` and adds it to `feed`.
func CreateFeedItem ¶
CreateFeedItem creates a new feed's Item from the Config information.
func GetEpisodeDetails ¶
GetEpisodeDetails provides the corresponding episode details for the `trackName` provided according to the features defined in `podcastYAML`.
Types ¶
type Config ¶
type Config struct { Album string `yaml:"album"` Artist string `yaml:"artist"` Bucket string `yaml:"bucket"` Cover string `yaml:"cover"` CoverFileName string Image string `yaml:"image"` Intro string `yaml:"intro"` Links []string `yaml:"links"` Master string `yaml:"master"` PubDate time.Time `yaml:"pubDate"` Summary string `yaml:"summary"` Title string `yaml:"title"` TrackNo int `yaml:"trackNo"` EpisodeURL string `yaml:"episodeURL"` DistributionID string `yaml:"distributionID"` ConfigFileName string }
Config contains all the configuration data from the YAML file. Part of it is used by the appu container.
func LoadConfigYAML ¶
LoadConfigYAML reads the `YAMLFile` and gets the data loaded in `cfg`, or any error happened in the process.
func (*Config) PrepareFiles ¶
PrepareFiles makes all the configuration ready to be used by the appu container.
type Podcast ¶
type Podcast struct { FeedURL string `yaml:"feedURL"` MasterURLPattern string `yaml:"masterURLPattern"` PublishURL string `yaml:"publishURL"` DistributionID string `yaml:"distributionID"` DirectFields struct { Cover string `yaml:"cover"` Artist string `yaml:"artist"` Album string `yaml:"album"` IntroURL string `yaml:"introURL"` EpisodeBucket string `yaml:"episodeBucket"` } `yaml:"directFields"` ScriptFieldHooks []struct { Name string `yaml:"name"` Hook string `yaml:"hook"` List bool `yaml:"list"` Attribute string `yaml:"attribute"` } `yaml:"scriptFieldHooks"` EpisodeScriptHooks map[string]string `yaml:"episodeScriptHooks"` // contains filtered or unexported fields }
Podcast contains all the parameters to get the episode details for a podcast.
func NewPodcast ¶
NewPodcast constructs the `Podcast` object for a `trackName` according with the properties defined in the `YAMLFile`, or an error.