Skip to content

Commit

Permalink
Fix categories import from Thunderbird's OPML
Browse files Browse the repository at this point in the history
Thunderbird OPML exports are looking like this:

```xml
<opml version="1.0" xmlns:fz="urn:forumzilla:">
<head>
	<title>Thunderbird OPML Export - RSS</title>
    	<dateCreated>Sat, 24 Feb 2024 11:31:13 GMT</dateCreated>
</head>
<body>
	<outline title="News">
		<outline type="rss" ...>
		<outline type="rss" ...>
		...
	</outline>
	<outline title="Blogs">
		<outline type="rss" ...>
		<outline type="rss" ...>
		...
	</outline>
</body>
```

This commit make it so that categories are now correctly imported.
  • Loading branch information
jvoisin authored and fguillot committed Feb 25, 2024
1 parent 1da65d9 commit c544dad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/reader/opml/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func getSubscriptionsFromOutlines(outlines opmlOutlineCollection, category strin
CategoryName: category,
})
} else if outline.Outlines.HasChildren() {
subscriptions = append(subscriptions, getSubscriptionsFromOutlines(outline.Outlines, outline.Text)...)
subscriptions = append(subscriptions, getSubscriptionsFromOutlines(outline.Outlines, outline.GetTitle())...)
}
}
return subscriptions
Expand Down
10 changes: 5 additions & 5 deletions internal/reader/opml/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,19 @@ func TestParseOpmlVersion1(t *testing.T) {
<dateCreated>Wed, 13 Mar 2019 11:51:41 GMT</dateCreated>
</head>
<body>
<outline title="Feed 1">
<outline title="Category 1">
<outline type="rss" title="Feed 1" xmlUrl="http://example.org/feed1/" htmlUrl="http://example.org/1"></outline>
</outline>
<outline title="Feed 2">
<outline title="Category 2">
<outline type="rss" title="Feed 2" xmlUrl="http://example.org/feed2/" htmlUrl="http://example.org/2"></outline>
</outline>
</body>
</opml>
`

var expected SubcriptionList
expected = append(expected, &Subcription{Title: "Feed 1", FeedURL: "http://example.org/feed1/", SiteURL: "http://example.org/1", CategoryName: ""})
expected = append(expected, &Subcription{Title: "Feed 2", FeedURL: "http://example.org/feed2/", SiteURL: "http://example.org/2", CategoryName: ""})
expected = append(expected, &Subcription{Title: "Feed 1", FeedURL: "http://example.org/feed1/", SiteURL: "http://example.org/1", CategoryName: "Category 1"})
expected = append(expected, &Subcription{Title: "Feed 2", FeedURL: "http://example.org/feed2/", SiteURL: "http://example.org/2", CategoryName: "Category 2"})

subscriptions, err := Parse(bytes.NewBufferString(data))
if err != nil {
Expand Down Expand Up @@ -250,7 +250,7 @@ func TestParseOpmlWithInvalidCharacterEntity(t *testing.T) {
`

var expected SubcriptionList
expected = append(expected, &Subcription{Title: "Feed 1", FeedURL: "http://example.org/feed1/a&b", SiteURL: "http://example.org/c&d", CategoryName: ""})
expected = append(expected, &Subcription{Title: "Feed 1", FeedURL: "http://example.org/feed1/a&b", SiteURL: "http://example.org/c&d", CategoryName: "Feed 1"})

subscriptions, err := Parse(bytes.NewBufferString(data))
if err != nil {
Expand Down

0 comments on commit c544dad

Please sign in to comment.