Skip to content

Commit 3094271

Browse files
authored
Merge pull request #6168 from Bnyro/master
fix: crash when playing video without upload date
2 parents d6c0ad8 + 94ef6a0 commit 3094271

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

app/src/main/java/com/github/libretube/api/obj/Streams.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ data class Streams(
1919

2020
@Serializable(SafeInstantSerializer::class)
2121
@SerialName("uploadDate")
22-
val uploadTimestamp: Instant,
22+
val uploadTimestamp: Instant?,
23+
val uploaded: Long? = null,
2324

2425
val uploader: String,
2526
val uploaderUrl: String,
@@ -91,9 +92,9 @@ data class Streams(
9192
uploaderName = uploader,
9293
uploaderUrl = uploaderUrl,
9394
uploaderAvatar = uploaderAvatar,
94-
uploadedDate = uploadTimestamp.toLocalDateTime(TimeZone.currentSystemDefault()).date
95-
.toString(),
96-
uploaded = uploadTimestamp.toEpochMilliseconds(),
95+
uploadedDate = uploadTimestamp?.toLocalDateTime(TimeZone.currentSystemDefault())?.date
96+
?.toString(),
97+
uploaded = uploaded ?: uploadTimestamp?.toEpochMilliseconds() ?: 0,
9798
duration = duration,
9899
views = views,
99100
uploaderVerified = uploaderVerified,

app/src/main/java/com/github/libretube/services/DownloadService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class DownloadService : LifecycleService() {
120120
streams.description,
121121
streams.uploader,
122122
streams.duration,
123-
streams.uploadTimestamp.toLocalDateTime(TimeZone.currentSystemDefault()).date,
123+
streams.uploadTimestamp?.toLocalDateTime(TimeZone.currentSystemDefault())?.date,
124124
thumbnailTargetPath
125125
)
126126
Database.downloadDao().insertDownload(download)

app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
681681
commentsViewModel.setCommentSheetExpand(null)
682682

683683
updateResolutionOnFullscreenChange(true)
684-
685684
openOrCloseFullscreenDialog(true)
686685

687686
binding.player.updateMarginsByFullscreenMode()
@@ -691,7 +690,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
691690
fun unsetFullscreen() {
692691
viewModel.isFullscreen.value = false
693692

694-
if (!PlayerHelper.autoFullscreenEnabled) {
693+
if (!PlayerHelper.autoFullscreenEnabled && activity != null) {
695694
mainActivity.requestedOrientation = mainActivity.screenOrientationPref
696695
}
697696

app/src/main/java/com/github/libretube/ui/views/DescriptionLayout.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ class DescriptionLayout(
143143
}
144144

145145
private fun localizeDate(streams: Streams): String {
146-
if (streams.livestream) return ""
146+
if (streams.livestream || streams.uploadTimestamp == null) return ""
147147

148148
val date = streams.uploadTimestamp.toLocalDateTime(TimeZone.currentSystemDefault()).date
149+
149150
return TextUtils.SEPARATOR + TextUtils.localizeDate(date)
150151
}
151152

0 commit comments

Comments
 (0)