fix: crashes and issues with local stream extractor

This commit is contained in:
Bnyro 2024-08-23 16:23:38 +02:00
parent fe0ba373cd
commit 213fc626c1
2 changed files with 5 additions and 3 deletions

View File

@ -30,7 +30,7 @@ object StreamsExtractor {
val resp = StreamInfo.getInfo("https://www.youtube.com/watch?v=$videoId")
return Streams(
title = resp.name,
description = resp.description.toString(),
description = resp.description.content,
uploader = resp.uploaderName,
uploaderAvatar = resp.uploaderAvatars.maxBy { it.height }.url,
uploaderUrl = resp.uploaderUrl.replace("https://www.youtube.com", ""),
@ -56,7 +56,7 @@ object StreamsExtractor {
uploadTimestamp = resp.uploadDate.offsetDateTime().toInstant().toKotlinInstant(),
uploaded = resp.uploadDate.offsetDateTime().toEpochSecond(),
thumbnailUrl = resp.thumbnails.maxBy { it.height }.url,
relatedStreams = resp.relatedItems.map { it as StreamInfoItem }.map {
relatedStreams = resp.relatedItems.filterIsInstance<StreamInfoItem>().map {
StreamItem(
it.url.replace("https://www.youtube.com", ""),
StreamItem.TYPE_STREAM,
@ -72,7 +72,7 @@ object StreamsExtractor {
it.uploadDate?.offsetDateTime()?.toEpochSecond() ?: 0L,
it.shortDescription,
it.isShortFormContent,
)
)
},
chapters = resp.streamSegments.map {
ChapterSegment(

View File

@ -62,6 +62,8 @@ class PlayerViewModel(
JsonHelper.json.decodeFromString<Message>(this).message
}?.getOrNull() ?: context.getString(R.string.server_error)
return@withContext null to errorMessage
} catch (e: Exception) {
return@withContext null to e.message
}
return@withContext streamsInfo to null