From f1f2142fdf20542c0e35f8a4af6cd7dfcc83978a Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Thu, 2 May 2024 17:37:18 -0700 Subject: [PATCH] correct rss to null check the author --- internal/services/input/httpClient.go | 4 ++-- internal/services/input/rss.go | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/internal/services/input/httpClient.go b/internal/services/input/httpClient.go index d942158..9091abe 100644 --- a/internal/services/input/httpClient.go +++ b/internal/services/input/httpClient.go @@ -2,7 +2,7 @@ package input import ( "crypto/tls" - "io/ioutil" + "io" "log" "net/http" ) @@ -35,7 +35,7 @@ func getHttpContent(uri string) ([]byte, error) { } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, err } diff --git a/internal/services/input/rss.go b/internal/services/input/rss.go index 1faa40c..e5dbccd 100644 --- a/internal/services/input/rss.go +++ b/internal/services/input/rss.go @@ -39,7 +39,11 @@ func (rc rssClient) GetArticles() ([]domain.ArticleEntity, error) { Description: post.Content, Url: post.Link, PubDate: *post.PublishedParsed, - AuthorName: post.Author.Email, + //AuthorName: post.Authors[0].Email, + } + + if len(post.Authors) != 0 { + article.AuthorName = post.Authors[0].Email } var postTags []string @@ -47,6 +51,21 @@ func (rc rssClient) GetArticles() ([]domain.ArticleEntity, error) { postTags = append(postTags, post.Categories...) article.Tags = strings.Join(postTags, ",") + /* + pageContent, err := getHttpContent(article.Url) + if err != nil { + continue + } + + htmlNode, err := html.Parse(bytes.NewReader(pageContent)) + if err != nil { + continue + } + htmlNode. + + fmt.Println(htmlNode) + */ + if post.Image == nil { article.Thumbnail = "" }