feed: unexport utils func feedErr
Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
0580231fc8
commit
034e3adabe
12
feed/feed.go
12
feed/feed.go
@ -17,7 +17,6 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
YT_FEED_URL = "https://www.youtube.com/feeds/videos.xml?channel_id=%s"
|
YT_FEED_URL = "https://www.youtube.com/feeds/videos.xml?channel_id=%s"
|
||||||
YT_FEED_SAM = "https://www.youtube.com/feeds/videos.xml?channel_id=UC5Uxq95L6K60XVdNPmUxoYA"
|
|
||||||
YT_VIDEO_URL = "https://youtube.com/watch?v=%s"
|
YT_VIDEO_URL = "https://youtube.com/watch?v=%s"
|
||||||
__GENERATOR_NAME = "yttopodcast - H.B."
|
__GENERATOR_NAME = "yttopodcast - H.B."
|
||||||
)
|
)
|
||||||
@ -36,7 +35,7 @@ func ConvertYtToRss(w io.Writer, channel_id string, bounce_url string, meta RSSM
|
|||||||
channelUrl := fmt.Sprintf(YT_FEED_URL, channel_id)
|
channelUrl := fmt.Sprintf(YT_FEED_URL, channel_id)
|
||||||
feed, err := getFeed(channelUrl)
|
feed, err := getFeed(channelUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return FeedErr(err)
|
return feedErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
t_now := time.Now().UTC()
|
t_now := time.Now().UTC()
|
||||||
@ -107,18 +106,19 @@ func ConvertYtToRss(w io.Writer, channel_id string, bounce_url string, meta RSSM
|
|||||||
rssTemplate.Execute(&rssResult, podFeed)
|
rssTemplate.Execute(&rssResult, podFeed)
|
||||||
_, err = gofeed.NewParser().ParseString(rssResult.String())
|
_, err = gofeed.NewParser().ParseString(rssResult.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return FeedErr(err)
|
return feedErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert to Yt Atom to RSS given a Reader that provides xml
|
||||||
func convertAtomToRSS(w io.Writer, r io.Reader, meta RSSMetadata) error {
|
func convertAtomToRSS(w io.Writer, r io.Reader, meta RSSMetadata) error {
|
||||||
var podFeed templates.FeedData
|
var podFeed templates.FeedData
|
||||||
|
|
||||||
feed, err := gofeed.NewParser().Parse(r)
|
feed, err := gofeed.NewParser().Parse(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return FeedErr(err)
|
return feedErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
t_now := time.Now().UTC()
|
t_now := time.Now().UTC()
|
||||||
@ -189,13 +189,13 @@ func convertAtomToRSS(w io.Writer, r io.Reader, meta RSSMetadata) error {
|
|||||||
rssTemplate.Execute(&rssResult, podFeed)
|
rssTemplate.Execute(&rssResult, podFeed)
|
||||||
_, err = gofeed.NewParser().ParseString(rssResult.String())
|
_, err = gofeed.NewParser().ParseString(rssResult.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return FeedErr(err)
|
return feedErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func FeedErr(err error) error {
|
func feedErr(err error) error {
|
||||||
httpErr, ok := err.(gofeed.HTTPError)
|
httpErr, ok := err.(gofeed.HTTPError)
|
||||||
if ok {
|
if ok {
|
||||||
switch httpErr.StatusCode {
|
switch httpErr.StatusCode {
|
||||||
|
Loading…
Reference in New Issue
Block a user