Download feed image

This commit is contained in:
Pijus Kamandulis 2019-05-05 20:06:09 +03:00
parent be2baffe69
commit 12e6b93520
2 changed files with 5 additions and 0 deletions

View File

@ -26,6 +26,9 @@ func main() {
LogInfo("Writing feed details as JSON to " + feedInfoPath) LogInfo("Writing feed details as JSON to " + feedInfoPath)
WriteToFile(feedInfoPath, GrabFeedDetailsJSON(feed)) WriteToFile(feedInfoPath, GrabFeedDetailsJSON(feed))
feedImagePath := outputDir + "/image" + filepath.Ext(feed.Image.URL)
DownloadFile(feedImagePath, feed.Image.URL)
for _, item := range feed.Items { for _, item := range feed.Items {
itemOutputFilename := ToCleanString( itemOutputFilename := ToCleanString(
item.PublishedParsed.Format("20060102") + "_" + item.Title) item.PublishedParsed.Format("20060102") + "_" + item.Title)
@ -69,6 +72,7 @@ func GrabFeedDetailsJSON(feed *gofeed.Feed) string {
Categories: feed.Categories, Categories: feed.Categories,
Language: feed.Language, Language: feed.Language,
Link: feed.Link, Link: feed.Link,
FeedLink: feed.FeedLink,
Updated: feed.Updated, Updated: feed.Updated,
} }

View File

@ -5,6 +5,7 @@ type FeedDetails struct {
Title string Title string
Description string Description string
Link string Link string
FeedLink string
Updated string Updated string
Language string Language string
Categories []string Categories []string