Skip to content

Commit

Permalink
Remove: unused functions from LocalMediaItem.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
nichwall committed Feb 8, 2025
1 parent 7c6e098 commit 20206d6
Showing 1 changed file with 40 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,65 @@ import com.fasterxml.jackson.annotation.JsonIgnore
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)
data class LocalMediaItem(
var id:String,
var name: String,
var mediaType:String,
var folderId:String,
var contentUrl:String,
var simplePath: String,
var basePath:String,
var absolutePath:String,
var audioTracks:MutableList<AudioTrack>,
var ebookFile:EBookFile?,
var localFiles:MutableList<LocalFile>,
var coverContentUrl:String?,
var coverAbsolutePath:String?
var id: String,
var name: String,
var mediaType: String,
var folderId: String,
var contentUrl: String,
var simplePath: String,
var basePath: String,
var absolutePath: String,
var audioTracks: MutableList<AudioTrack>,
var ebookFile: EBookFile?,
var localFiles: MutableList<LocalFile>,
var coverContentUrl: String?,
var coverAbsolutePath: String?
) {

@JsonIgnore
fun getDuration():Double {
fun getDuration(): Double {
var total = 0.0
audioTracks.forEach{ total += it.duration }
audioTracks.forEach { total += it.duration }
return total
}

@JsonIgnore
fun getTotalSize():Long {
fun getTotalSize(): Long {
var total = 0L
localFiles.forEach { total += it.size }
return total
}

@JsonIgnore
fun getMediaMetadata():MediaTypeMetadata {
fun getMediaMetadata(): MediaTypeMetadata {
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 {
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)
PodcastMetadata(name, null, null, mutableListOf(), false)
}
}
}

0 comments on commit 20206d6

Please sign in to comment.