mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
Merge pull request #4899 from Bnyro/master
fix: date parsing crash due to YouTube AB testing
This commit is contained in:
commit
b03d119a6e
@ -2,18 +2,18 @@ package com.github.libretube.api.obj
|
||||
|
||||
import com.github.libretube.db.obj.DownloadItem
|
||||
import com.github.libretube.enums.FileType
|
||||
import com.github.libretube.extensions.toLocalDateSafe
|
||||
import com.github.libretube.extensions.toMillis
|
||||
import com.github.libretube.helpers.ProxyHelper
|
||||
import com.github.libretube.parcelable.DownloadData
|
||||
import kotlin.io.path.Path
|
||||
import kotlinx.datetime.LocalDate
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.io.path.Path
|
||||
|
||||
@Serializable
|
||||
data class Streams(
|
||||
val title: String,
|
||||
val description: String,
|
||||
val uploadDate: LocalDate,
|
||||
val uploadDate: String,
|
||||
val uploader: String,
|
||||
val uploaderUrl: String,
|
||||
val uploaderAvatar: String? = null,
|
||||
@ -84,8 +84,8 @@ data class Streams(
|
||||
uploaderName = uploader,
|
||||
uploaderUrl = uploaderUrl,
|
||||
uploaderAvatar = uploaderAvatar,
|
||||
uploadedDate = uploadDate.toString(),
|
||||
uploaded = uploadDate.toMillis(),
|
||||
uploadedDate = uploadDate,
|
||||
uploaded = uploadDate.toLocalDateSafe().toMillis(),
|
||||
duration = duration,
|
||||
views = views,
|
||||
uploaderVerified = uploaderVerified,
|
||||
|
@ -3,5 +3,8 @@ package com.github.libretube.extensions
|
||||
import kotlinx.datetime.LocalDate
|
||||
import kotlinx.datetime.TimeZone
|
||||
import kotlinx.datetime.atStartOfDayIn
|
||||
import kotlinx.datetime.toLocalDate
|
||||
|
||||
fun LocalDate.toMillis() = this.atStartOfDayIn(TimeZone.UTC).toEpochMilliseconds()
|
||||
|
||||
fun String.toLocalDateSafe() = this.substring(0, 10).toLocalDate()
|
@ -28,6 +28,7 @@ import com.github.libretube.enums.FileType
|
||||
import com.github.libretube.extensions.formatAsFileSize
|
||||
import com.github.libretube.extensions.getContentLength
|
||||
import com.github.libretube.extensions.parcelableExtra
|
||||
import com.github.libretube.extensions.toLocalDateSafe
|
||||
import com.github.libretube.extensions.toastFromMainThread
|
||||
import com.github.libretube.helpers.DownloadHelper
|
||||
import com.github.libretube.helpers.DownloadHelper.getNotificationId
|
||||
@ -115,7 +116,7 @@ class DownloadService : LifecycleService() {
|
||||
streams.title,
|
||||
streams.description,
|
||||
streams.uploader,
|
||||
streams.uploadDate,
|
||||
streams.uploadDate.toLocalDateSafe(),
|
||||
thumbnailTargetPath
|
||||
)
|
||||
Database.downloadDao().insertDownload(download)
|
||||
|
@ -78,6 +78,7 @@ import com.github.libretube.extensions.seekBy
|
||||
import com.github.libretube.extensions.serializableExtra
|
||||
import com.github.libretube.extensions.setMetadata
|
||||
import com.github.libretube.extensions.toID
|
||||
import com.github.libretube.extensions.toLocalDateSafe
|
||||
import com.github.libretube.extensions.toastFromMainDispatcher
|
||||
import com.github.libretube.extensions.togglePlayPauseState
|
||||
import com.github.libretube.extensions.updateParameters
|
||||
@ -873,11 +874,9 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
}
|
||||
|
||||
private fun localizeDate(streams: Streams): String {
|
||||
return if (!streams.livestream) {
|
||||
TextUtils.SEPARATOR + TextUtils.localizeDate(streams.uploadDate)
|
||||
} else {
|
||||
""
|
||||
}
|
||||
if (streams.livestream) return ""
|
||||
|
||||
return TextUtils.SEPARATOR + TextUtils.localizeDate(streams.uploadDate.toLocalDateSafe())
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
|
Loading…
x
Reference in New Issue
Block a user