-/*
-feeder -- newsfeeds aggregator
-Copyright (C) 2022 Sergey Matveev <stargrave@stargrave.org>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 3 of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
+// feeder -- newsfeeds aggregator
+// Copyright (C) 2022-2024 Sergey Matveev <stargrave@stargrave.org>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 3 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
package main
"mime"
"os"
"path"
+ "path/filepath"
"strings"
"time"
}
}
+ feedTitle := feed.Title
+ if len(feedTitle) == 0 {
+ feedTitle, err = filepath.Abs(mdir)
+ if err != nil {
+ log.Fatalln(err)
+ }
+ feedTitle = path.Base(feedTitle)
+ }
+
h := sha512.New()
news := 0
var when *time.Time
latest = when
}
var what string
- if len(item.Content) == 0 {
- what = item.Description
- } else {
+ if len(item.Content) > len(item.Description) {
what = item.Content
+ } else {
+ what = item.Description
+ }
+ if media, ok := item.Extensions["media"]; ok {
+ if mediagroups, ok := media["group"]; ok {
+ if len(mediagroups) == 1 {
+ if mediadescription, ok := mediagroups[0].Children["description"]; ok {
+ if len(mediadescription[0].Value) > len(what) {
+ what = mediadescription[0].Value
+ }
+ }
+ }
+ }
}
what = strings.TrimPrefix(what, "<![CDATA[")
what = strings.TrimSuffix(what, "]]>")
if err != nil {
log.Fatalln(err)
}
- fd.WriteString("From: \"" + feed.Title + "\" <feeder@localhost>\n")
+ fd.WriteString("From: \"" + feedTitle + "\" <feeder@localhost>\n")
fd.WriteString("Date: " + when.UTC().Format(time.RFC1123Z) + "\n")
fd.WriteString("Subject: " + mime.BEncoding.Encode("UTF-8", item.Title) + "\n")
fd.WriteString("MIME-Version: 1.0\n")
log.Fatalln(err)
}
}
- fmt.Println(feed.Title)
+ fmt.Println(feedTitle)
}