|
1 | 1 | package api.miniflux
|
2 | 2 |
|
| 3 | +import android.util.Log |
3 | 4 | import api.Api
|
4 | 5 | import co.appreactor.feedk.AtomLinkRel
|
5 | 6 | import db.Entry
|
@@ -39,7 +40,16 @@ class MinifluxApiAdapter(
|
39 | 40 | }
|
40 | 41 |
|
41 | 42 | override suspend fun getFeeds(): Result<List<Feed>> {
|
42 |
| - return runCatching { api.getFeeds().mapNotNull { it.toFeed() } } |
| 43 | + return runCatching { |
| 44 | + api.getFeeds().mapNotNull { |
| 45 | + try { |
| 46 | + it.toFeed() |
| 47 | + } catch (e: Exception) { |
| 48 | + Log.w("MinifluxApiAdapter", "Failed to parse feed ${it.feed_url}", e) |
| 49 | + null |
| 50 | + } |
| 51 | + } |
| 52 | + } |
43 | 53 | }
|
44 | 54 |
|
45 | 55 | override suspend fun updateFeedTitle(feedId: String, newTitle: String): Result<Unit> {
|
@@ -143,22 +153,27 @@ class MinifluxApiAdapter(
|
143 | 153 | extCacheUri = null,
|
144 | 154 | )
|
145 | 155 |
|
146 |
| - val alternateLink = Link( |
147 |
| - feedId = feedId, |
148 |
| - entryId = null, |
149 |
| - href = site_url.toHttpUrl(), |
150 |
| - rel = AtomLinkRel.Alternate, |
151 |
| - type = "text/html", |
152 |
| - hreflang = null, |
153 |
| - title = null, |
154 |
| - length = null, |
155 |
| - extEnclosureDownloadProgress = null, |
156 |
| - extCacheUri = null, |
157 |
| - ) |
| 156 | + val alternateLink = try { |
| 157 | + Link( |
| 158 | + feedId = feedId, |
| 159 | + entryId = null, |
| 160 | + href = site_url.toHttpUrl(), |
| 161 | + rel = AtomLinkRel.Alternate, |
| 162 | + type = "text/html", |
| 163 | + hreflang = null, |
| 164 | + title = null, |
| 165 | + length = null, |
| 166 | + extEnclosureDownloadProgress = null, |
| 167 | + extCacheUri = null, |
| 168 | + ) |
| 169 | + } catch (e: Exception) { |
| 170 | + Log.d("MinifluxApiAdapter", "Failed to parse alternate link for feed $feed_url", e) |
| 171 | + null |
| 172 | + } |
158 | 173 |
|
159 | 174 | return Feed(
|
160 | 175 | id = feedId,
|
161 |
| - links = listOf(selfLink, alternateLink), |
| 176 | + links = listOfNotNull(selfLink, alternateLink), |
162 | 177 | title = title,
|
163 | 178 | ext_open_entries_in_browser = false,
|
164 | 179 | ext_blocked_words = "",
|
|
0 commit comments