Merge pull request #6394 from Bnyro/master

fix: crashes and issues with local stream extractor
This commit is contained in:
Bnyro 2024-08-23 16:28:17 +02:00 committed by GitHub
commit 483f27a20e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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,

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