mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
Merge pull request #7142 from FineFindus/fix/local-feed-short-videos
fix(Feed): extract shorts uploadDate from feedInfo
This commit is contained in:
commit
2c73287d71
@ -87,8 +87,13 @@ private fun AudioStream.toPipedStream() = PipedStream(
|
|||||||
)
|
)
|
||||||
|
|
||||||
fun StreamInfoItem.toStreamItem(
|
fun StreamInfoItem.toStreamItem(
|
||||||
uploaderAvatarUrl: String? = null
|
uploaderAvatarUrl: String? = null,
|
||||||
) = StreamItem(
|
feedInfo: StreamInfoItem? = null,
|
||||||
|
): StreamItem {
|
||||||
|
val uploadDate = uploadDate ?: feedInfo?.uploadDate
|
||||||
|
val textualUploadDate = textualUploadDate ?: feedInfo?.textualUploadDate
|
||||||
|
|
||||||
|
return StreamItem(
|
||||||
type = TYPE_STREAM,
|
type = TYPE_STREAM,
|
||||||
url = url.toID(),
|
url = url.toID(),
|
||||||
title = name,
|
title = name,
|
||||||
@ -106,6 +111,7 @@ fun StreamInfoItem.toStreamItem(
|
|||||||
shortDescription = shortDescription,
|
shortDescription = shortDescription,
|
||||||
isShort = isShortFormContent
|
isShort = isShortFormContent
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun InfoItem.toContentItem() = when (this) {
|
fun InfoItem.toContentItem() = when (this) {
|
||||||
is StreamInfoItem -> ContentItem(
|
is StreamInfoItem -> ContentItem(
|
||||||
|
@ -120,6 +120,7 @@ class LocalFeedRepository : FeedRepository {
|
|||||||
): List<StreamItem> {
|
): List<StreamItem> {
|
||||||
val channelUrl = "$YOUTUBE_FRONTEND_URL/channel/${channelId}"
|
val channelUrl = "$YOUTUBE_FRONTEND_URL/channel/${channelId}"
|
||||||
val feedInfo = FeedInfo.getInfo(channelUrl)
|
val feedInfo = FeedInfo.getInfo(channelUrl)
|
||||||
|
val feedInfoItems = feedInfo.relatedItems.associateBy { it.url }
|
||||||
|
|
||||||
val mostRecentChannelVideo = feedInfo.relatedItems.maxBy {
|
val mostRecentChannelVideo = feedInfo.relatedItems.maxBy {
|
||||||
it.uploadDate?.offsetDateTime()?.toInstant()?.toEpochMilli() ?: 0
|
it.uploadDate?.offsetDateTime()?.toInstant()?.toEpochMilli() ?: 0
|
||||||
@ -146,13 +147,15 @@ class LocalFeedRepository : FeedRepository {
|
|||||||
}.getOrElse { emptyList() }
|
}.getOrElse { emptyList() }
|
||||||
}.flatten().filterIsInstance<StreamInfoItem>()
|
}.flatten().filterIsInstance<StreamInfoItem>()
|
||||||
|
|
||||||
|
val channelAvatar = channelInfo.avatars.maxByOrNull { it.height }?.url
|
||||||
return related.map { item ->
|
return related.map { item ->
|
||||||
// avatar is not always included in these info items, thus must be taken from channel info response
|
// avatar is not always included in these info items, thus must be taken from channel info response
|
||||||
item.toStreamItem(channelInfo.avatars.maxByOrNull { it.height }?.url)
|
item.toStreamItem(
|
||||||
}.filter {
|
channelAvatar,
|
||||||
// shorts don't have upload dates apparently
|
// shorts fetched via the shorts tab don't have upload dates so we fall back to the feedInfo
|
||||||
it.isShort || it.uploaded > minimumDateMillis
|
feedInfoItems[item.url]
|
||||||
}
|
)
|
||||||
|
}.filter { it.uploaded > minimumDateMillis }
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user