mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
Merge pull request #6394 from Bnyro/master
fix: crashes and issues with local stream extractor
This commit is contained in:
commit
483f27a20e
@ -30,7 +30,7 @@ object StreamsExtractor {
|
|||||||
val resp = StreamInfo.getInfo("https://www.youtube.com/watch?v=$videoId")
|
val resp = StreamInfo.getInfo("https://www.youtube.com/watch?v=$videoId")
|
||||||
return Streams(
|
return Streams(
|
||||||
title = resp.name,
|
title = resp.name,
|
||||||
description = resp.description.toString(),
|
description = resp.description.content,
|
||||||
uploader = resp.uploaderName,
|
uploader = resp.uploaderName,
|
||||||
uploaderAvatar = resp.uploaderAvatars.maxBy { it.height }.url,
|
uploaderAvatar = resp.uploaderAvatars.maxBy { it.height }.url,
|
||||||
uploaderUrl = resp.uploaderUrl.replace("https://www.youtube.com", ""),
|
uploaderUrl = resp.uploaderUrl.replace("https://www.youtube.com", ""),
|
||||||
@ -56,7 +56,7 @@ object StreamsExtractor {
|
|||||||
uploadTimestamp = resp.uploadDate.offsetDateTime().toInstant().toKotlinInstant(),
|
uploadTimestamp = resp.uploadDate.offsetDateTime().toInstant().toKotlinInstant(),
|
||||||
uploaded = resp.uploadDate.offsetDateTime().toEpochSecond(),
|
uploaded = resp.uploadDate.offsetDateTime().toEpochSecond(),
|
||||||
thumbnailUrl = resp.thumbnails.maxBy { it.height }.url,
|
thumbnailUrl = resp.thumbnails.maxBy { it.height }.url,
|
||||||
relatedStreams = resp.relatedItems.map { it as StreamInfoItem }.map {
|
relatedStreams = resp.relatedItems.filterIsInstance<StreamInfoItem>().map {
|
||||||
StreamItem(
|
StreamItem(
|
||||||
it.url.replace("https://www.youtube.com", ""),
|
it.url.replace("https://www.youtube.com", ""),
|
||||||
StreamItem.TYPE_STREAM,
|
StreamItem.TYPE_STREAM,
|
||||||
@ -72,7 +72,7 @@ object StreamsExtractor {
|
|||||||
it.uploadDate?.offsetDateTime()?.toEpochSecond() ?: 0L,
|
it.uploadDate?.offsetDateTime()?.toEpochSecond() ?: 0L,
|
||||||
it.shortDescription,
|
it.shortDescription,
|
||||||
it.isShortFormContent,
|
it.isShortFormContent,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
chapters = resp.streamSegments.map {
|
chapters = resp.streamSegments.map {
|
||||||
ChapterSegment(
|
ChapterSegment(
|
||||||
|
@ -62,6 +62,8 @@ class PlayerViewModel(
|
|||||||
JsonHelper.json.decodeFromString<Message>(this).message
|
JsonHelper.json.decodeFromString<Message>(this).message
|
||||||
}?.getOrNull() ?: context.getString(R.string.server_error)
|
}?.getOrNull() ?: context.getString(R.string.server_error)
|
||||||
return@withContext null to errorMessage
|
return@withContext null to errorMessage
|
||||||
|
} catch (e: Exception) {
|
||||||
|
return@withContext null to e.message
|
||||||
}
|
}
|
||||||
|
|
||||||
return@withContext streamsInfo to null
|
return@withContext streamsInfo to null
|
||||||
|
Loading…
Reference in New Issue
Block a user