Skip to content

Commit dc1653b

Browse files
mtsz-plfguillot
authored andcommitted
feat(finder): make cannonical url detection a proper step
1 parent 3ea4aee commit dc1653b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

internal/reader/subscription/finder.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,21 @@ func (f *subscriptionFinder) FindSubscriptions(websiteURL, rssBridgeURL string,
6868
f.feedDownloaded = true
6969
return Subscriptions{NewSubscription(responseHandler.EffectiveURL(), responseHandler.EffectiveURL(), feedFormat)}, nil
7070
}
71+
72+
// Step 2) Find the canonical URL of the website.
73+
slog.Debug("Try to find the canonical URL of the website", slog.String("website_url", websiteURL))
74+
websiteURL = f.findCanonicalURL(websiteURL, responseHandler.ContentType(), bytes.NewReader(responseBody))
7175

72-
// Step 2) Check if the website URL is a YouTube channel.
76+
// Step 3) Check if the website URL is a YouTube channel.
7377
slog.Debug("Try to detect feeds for a YouTube page", slog.String("website_url", websiteURL))
74-
youtubeURL := f.findCanonicalURL(websiteURL, responseHandler.ContentType(), bytes.NewReader(responseBody))
75-
if subscriptions, localizedError := f.findSubscriptionsFromYouTube(youtubeURL); localizedError != nil {
78+
if subscriptions, localizedError := f.findSubscriptionsFromYouTube(websiteURL); localizedError != nil {
7679
return nil, localizedError
7780
} else if len(subscriptions) > 0 {
7881
slog.Debug("Subscriptions found from YouTube page", slog.String("website_url", websiteURL), slog.Any("subscriptions", subscriptions))
7982
return subscriptions, nil
8083
}
8184

82-
// Step 3) Parse web page to find feeds from HTML meta tags.
85+
// Step 4) Parse web page to find feeds from HTML meta tags.
8386
slog.Debug("Try to detect feeds from HTML meta tags",
8487
slog.String("website_url", websiteURL),
8588
slog.String("content_type", responseHandler.ContentType()),
@@ -91,7 +94,7 @@ func (f *subscriptionFinder) FindSubscriptions(websiteURL, rssBridgeURL string,
9194
return subscriptions, nil
9295
}
9396

94-
// Step 4) Check if the website URL can use RSS-Bridge.
97+
// Step 5) Check if the website URL can use RSS-Bridge.
9598
if rssBridgeURL != "" {
9699
slog.Debug("Try to detect feeds with RSS-Bridge", slog.String("website_url", websiteURL))
97100
if subscriptions, localizedError := f.findSubscriptionsFromRSSBridge(websiteURL, rssBridgeURL, rssBridgeToken); localizedError != nil {
@@ -102,7 +105,7 @@ func (f *subscriptionFinder) FindSubscriptions(websiteURL, rssBridgeURL string,
102105
}
103106
}
104107

105-
// Step 5) Check if the website has a known feed URL.
108+
// Step 6) Check if the website has a known feed URL.
106109
slog.Debug("Try to detect feeds from well-known URLs", slog.String("website_url", websiteURL))
107110
if subscriptions, localizedError := f.findSubscriptionsFromWellKnownURLs(websiteURL); localizedError != nil {
108111
return nil, localizedError

0 commit comments

Comments
 (0)