Skip to content

Commit

Permalink
[optimize|build|doc] Optimize podcast icon extraction logic; update d…
Browse files Browse the repository at this point in the history
…ependencies; update README
  • Loading branch information
SkyD666 committed Dec 2, 2024
1 parent d90ffbc commit 8a021e7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</a>
</p>
<p>
An <b>all-in-one tool</b> for <b>RSS subscription and updates</b>, <b>bit torrent downloads</b>, and <b>video playback</b>.
An <b>all-in-one Podcast tool</b> for <b>RSS subscription and updates</b>, <b>media downloads</b> and <b>playback</b>.
</p>
<p>
AniVu utilizes the <b><a href="https://developer.android.com/topic/architecture#recommended-app-arch">MVI</a></b> architecture and fully adopts the <b><a href="https://m3.material.io/">Material You</a></b> design style. All pages are developed using <b>Jetpack Compose</b>.
Expand All @@ -41,7 +41,6 @@
</p>
</div>


<a href="https://f-droid.org/packages/com.skyd.anivu"><img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" alt="Get it on F-Droid" height="80"></a>

## 💡 Features
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {
minSdk = 24
targetSdk = 35
versionCode = 24
versionName = "2.1-beta11"
versionName = "2.1-beta12"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
39 changes: 30 additions & 9 deletions app/src/main/java/com/skyd/anivu/model/repository/RssHelper.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package com.skyd.anivu.model.repository

import android.util.Log
import com.rometools.modules.itunes.EntryInformationImpl
import com.rometools.modules.mediarss.MediaEntryModuleImpl
import com.rometools.modules.itunes.EntryInformation
import com.rometools.modules.itunes.FeedInformation
import com.rometools.modules.mediarss.MediaEntryModule
import com.rometools.modules.mediarss.MediaModule
import com.rometools.modules.mediarss.types.Rating
import com.rometools.rome.feed.module.Module
import com.rometools.rome.feed.synd.SyndEntry
import com.rometools.rome.feed.synd.SyndFeed
import com.rometools.rome.io.SyndFeedInput
import com.rometools.rome.io.XmlReader
import com.skyd.anivu.ext.toEncodedUrl
import com.skyd.anivu.model.bean.feed.FeedBean
import com.skyd.anivu.model.bean.feed.FeedWithArticleBean
import com.skyd.anivu.model.bean.article.ArticleBean
import com.skyd.anivu.model.bean.article.ArticleWithEnclosureBean
import com.skyd.anivu.model.bean.article.EnclosureBean
import com.skyd.anivu.model.bean.article.RssMediaBean
import com.skyd.anivu.model.bean.feed.FeedBean
import com.skyd.anivu.model.bean.feed.FeedWithArticleBean
import com.skyd.anivu.util.favicon.FaviconExtractor
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
Expand Down Expand Up @@ -45,7 +48,9 @@ class RssHelper @Inject constructor(
title = syndFeed.title,
description = syndFeed.description,
link = syndFeed.link,
icon = syndFeed.icon?.link ?: iconAsync.await(),
icon = getMediaRssIcon(syndFeed)
?: syndFeed.icon?.link
?: iconAsync.await(),
)
val list = syndFeed.entries.map { article(feed, it) }
FeedWithArticleBean(feed, list)
Expand Down Expand Up @@ -75,7 +80,9 @@ class RssHelper @Inject constructor(
title = syndFeed.title,
description = syndFeed.description,
link = syndFeed.link,
icon = syndFeed.icon?.link ?: iconAsync.await(),
icon = getMediaRssIcon(syndFeed)
?: syndFeed.icon?.link
?: iconAsync.await(),
),
articles = syndFeed.entries
.asSequence()
Expand Down Expand Up @@ -151,7 +158,7 @@ class RssHelper @Inject constructor(
private fun getRssMedia(articleId: String, modules: List<Module>): RssMediaBean? {
modules.forEach { module ->
val media = when (module) {
is EntryInformationImpl -> {
is EntryInformation -> {
RssMediaBean(
articleId = articleId,
duration = module.duration?.milliseconds,
Expand All @@ -161,7 +168,7 @@ class RssHelper @Inject constructor(
)
}

is MediaEntryModuleImpl -> {
is MediaEntryModule -> {
val content = module.mediaContents.firstOrNull()
RssMediaBean(
articleId = articleId,
Expand All @@ -179,7 +186,21 @@ class RssHelper @Inject constructor(
return null
}

fun getRssIcon(url: String): String? {
private fun getMediaRssIcon(syndFeed: SyndFeed): String? {
var icon: String?
syndFeed.modules.forEach { module ->
icon = when (module) {
is FeedInformation -> module.image?.toString()
is MediaModule -> module.metadata?.thumbnail?.firstOrNull()?.url?.toString()

else -> null
}
if (icon != null) return icon
}
return null
}

private fun getRssIcon(url: String): String? {
return runCatching {
faviconExtractor.extractFavicon(url).apply { Log.e("TAG", "getRssIcon: $this") }
}.onFailure { it.printStackTrace() }.getOrNull()
Expand Down
3 changes: 2 additions & 1 deletion doc/readme/README-zh-rCN.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</a>
</p>
<p>
<b>AniVu</b>,一个集<b> RSS 订阅与更新、比特洪流下载、视频播放</b>为一体的工具
<b>AniVu</b>,一个集<b> RSS 订阅与更新、媒体下载与播放</b>为一体的播客工具
</p>
<p>
使用 <b><a href="https://developer.android.com/topic/architecture#recommended-app-arch">MVI</a></b> 架构,完全采用 <b><a href="https://m3.material.io/">Material You</a></b> 设计风格。使用 <b>Jetpack Compose</b> 开发。
Expand All @@ -35,6 +35,7 @@
</p>
</div>


<a href="https://f-droid.org/packages/com.skyd.anivu"><img src="https://fdroid.gitlab.io/artwork/badge/get-it-on-zh-cn.png" alt="Get it on F-Droid" height="80"></a>

## 💡主要功能
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
adaptive = "1.0.0"
coil = "3.0.3"
coil = "3.0.4"
hilt = "2.52"
libtorrent4j = "2.1.0-35"
composeMaterial = "1.7.5"
Expand Down

0 comments on commit 8a021e7

Please sign in to comment.