mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-28 14:17:19 +02:00
Remove: unused functions from LocalMediaItem.kt
This commit is contained in:
@@ -4,70 +4,65 @@ import com.fasterxml.jackson.annotation.JsonIgnore
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Used as a helper class to generate LocalLibraryItem from scan results
|
Used as a helper class to generate LocalLibraryItem from scan results
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
data class LocalMediaItem(
|
data class LocalMediaItem(
|
||||||
var id:String,
|
var id: String,
|
||||||
var name: String,
|
var name: String,
|
||||||
var mediaType:String,
|
var mediaType: String,
|
||||||
var folderId:String,
|
var folderId: String,
|
||||||
var contentUrl:String,
|
var contentUrl: String,
|
||||||
var simplePath: String,
|
var simplePath: String,
|
||||||
var basePath:String,
|
var basePath: String,
|
||||||
var absolutePath:String,
|
var absolutePath: String,
|
||||||
var audioTracks:MutableList<AudioTrack>,
|
var audioTracks: MutableList<AudioTrack>,
|
||||||
var ebookFile:EBookFile?,
|
var ebookFile: EBookFile?,
|
||||||
var localFiles:MutableList<LocalFile>,
|
var localFiles: MutableList<LocalFile>,
|
||||||
var coverContentUrl:String?,
|
var coverContentUrl: String?,
|
||||||
var coverAbsolutePath:String?
|
var coverAbsolutePath: String?
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getDuration():Double {
|
fun getDuration(): Double {
|
||||||
var total = 0.0
|
var total = 0.0
|
||||||
audioTracks.forEach{ total += it.duration }
|
audioTracks.forEach { total += it.duration }
|
||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getTotalSize():Long {
|
fun getTotalSize(): Long {
|
||||||
var total = 0L
|
var total = 0L
|
||||||
localFiles.forEach { total += it.size }
|
localFiles.forEach { total += it.size }
|
||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
fun getMediaMetadata():MediaTypeMetadata {
|
fun getMediaMetadata(): MediaTypeMetadata {
|
||||||
return if (mediaType == "book") {
|
return if (mediaType == "book") {
|
||||||
BookMetadata(name,null, mutableListOf(), mutableListOf(), mutableListOf(),null,null,null,null,null,null,null,false,null,null,null, null, null)
|
BookMetadata(
|
||||||
|
name,
|
||||||
|
null,
|
||||||
|
mutableListOf(),
|
||||||
|
mutableListOf(),
|
||||||
|
mutableListOf(),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
PodcastMetadata(name,null,null, mutableListOf(), false)
|
PodcastMetadata(name, null, null, mutableListOf(), false)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
fun getAudiobookChapters():List<BookChapter> {
|
|
||||||
if (mediaType != "book" || audioTracks.isEmpty()) return mutableListOf()
|
|
||||||
if (audioTracks.size == 1) { // Single track audiobook look for chapters from ffprobe
|
|
||||||
return audioTracks[0].audioProbeResult?.getBookChapters() ?: mutableListOf()
|
|
||||||
}
|
|
||||||
// Multi-track make chapters from tracks
|
|
||||||
return audioTracks.map { it.getBookChapter() }
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
fun getLocalLibraryItem():LocalLibraryItem {
|
|
||||||
val mediaMetadata = getMediaMetadata()
|
|
||||||
if (mediaType == "book") {
|
|
||||||
val chapters = getAudiobookChapters()
|
|
||||||
val book = Book(mediaMetadata as BookMetadata, coverAbsolutePath, mutableListOf(), mutableListOf(), chapters,audioTracks,ebookFile,getTotalSize(),getDuration(),audioTracks.size)
|
|
||||||
return LocalLibraryItem(id, folderId, basePath,absolutePath, contentUrl, false,mediaType, book, localFiles, coverContentUrl, coverAbsolutePath,true,null,null,null,null)
|
|
||||||
} else {
|
|
||||||
val podcast = Podcast(mediaMetadata as PodcastMetadata, coverAbsolutePath, mutableListOf(), mutableListOf(), false, 0)
|
|
||||||
podcast.setAudioTracks(audioTracks) // Builds episodes from audio tracks
|
|
||||||
return LocalLibraryItem(id, folderId, basePath,absolutePath, contentUrl, false, mediaType, podcast,localFiles,coverContentUrl, coverAbsolutePath, true, null,null,null,null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user