Merge pull request #4394 from Bnyro/master

feat: support for video meta info
This commit is contained in:
Bnyro 2023-08-07 18:02:05 +02:00 committed by GitHub
commit dc9be11ba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,11 @@
package com.github.libretube.api.obj
import kotlinx.serialization.Serializable
@Serializable
data class MetaInfo(
val title: String,
val description: String,
val urls: List<String>,
val urlTexts: List<String>
)

View File

@ -21,6 +21,7 @@ data class Streams(
val license: String, val license: String,
val visibility: String, val visibility: String,
val tags: List<String>, val tags: List<String>,
val metaInfo: List<MetaInfo>,
val hls: String? = null, val hls: String? = null,
val dash: String? = null, val dash: String? = null,
val lbryId: String? = null, val lbryId: String? = null,

View File

@ -16,6 +16,7 @@ import android.os.PowerManager
import android.text.format.DateUtils import android.text.format.DateUtils
import android.text.method.LinkMovementMethod import android.text.method.LinkMovementMethod
import android.text.util.Linkify import android.text.util.Linkify
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -861,6 +862,17 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
playerTitle.text = streams.title playerTitle.text = streams.title
playerDescription.text = streams.description playerDescription.text = streams.description
metaInfo.isVisible = streams.metaInfo.isNotEmpty()
// generate a meta info text with clickable links using html
val metaInfoText = streams.metaInfo.joinToString("\n\n") { info ->
val text = info.description.takeIf { it.isNotBlank() } ?: info.title
val links = info.urls.mapIndexed { index, url ->
"<a href=\"$url\">${info.urlTexts.getOrNull(index).orEmpty()}</a>"
}.joinToString(", ")
"$text $links"
}
metaInfo.text = metaInfoText.parseAsHtml()
playerChannelSubCount.text = context?.getString( playerChannelSubCount.text = context?.getString(
R.string.subscribers, R.string.subscribers,
streams.uploaderSubscriberCount.formatShort() streams.uploaderSubscriberCount.formatShort()

View File

@ -107,6 +107,14 @@
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone"> android:visibility="gone">
<TextView
android:id="@+id/meta_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:textSize="14sp"
android:visibility="gone" />
<TextView <TextView
android:id="@+id/player_description" android:id="@+id/player_description"
android:layout_width="match_parent" android:layout_width="match_parent"