]> Sergey Matveev's repositories - feeder.git/commitdiff
Use media:group/media:description if it exists
authorMatthieu Rakotojaona <m@rako.space>
Fri, 17 Feb 2023 17:13:06 +0000 (18:13 +0100)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 17 Feb 2023 18:30:04 +0000 (21:30 +0300)
Some feeds (typically rss feeds from invidious channels) have the
following structure for entries:

<item>
[...]
<content></content>
<description>A one line title</description>
<media:group>
[...]
<media:description>An actual text
that serves
as a description</media:description>
</media:group>
</item>

If it's there, and again longer than the other fields, use it

cmd/feed2mdir/main.go

index 1ea7f92e70ce93d3dcc3afec6744deff21a1b898..3089a232355796ea41f287902c70a726646d7ce7 100644 (file)
@@ -90,6 +90,17 @@ func main() {
                } 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, "]]>")
                h.Reset()