musikr: use interpreter instead of taginterpreter

This commit is contained in:
Alexander Capehart 2025-01-21 16:14:24 -07:00
parent 0919f29085
commit b2073f2213
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
3 changed files with 8 additions and 9 deletions

View file

@ -28,13 +28,12 @@ import org.oxycblt.musikr.tag.interpret.Separators
data class Storage( data class Storage(
/** /**
* A repository of cached metadata to read and write from over the course of music loading only. * A repository of cached metadata to read and write from over the course of music loading only.
* This will be used only during music loading.
*/ */
val cache: MutableSongCache, val cache: MutableSongCache,
/** /**
* A repository of cover images to for re-use during music loading. Should be kept in lock-step * A repository of cover images to for re-use during music loading. Should be kept in lock-step
* with the cache for best performance. This will be used during music loading and when * with the [cache] for best performance. This will be used during music loading and when
* retrieving cover information from the library. * retrieving cover information from the library.
*/ */
val covers: MutableCovers, val covers: MutableCovers,

View file

@ -33,7 +33,7 @@ import org.oxycblt.musikr.graph.MusicGraph
import org.oxycblt.musikr.model.LibraryFactory import org.oxycblt.musikr.model.LibraryFactory
import org.oxycblt.musikr.playlist.db.StoredPlaylists import org.oxycblt.musikr.playlist.db.StoredPlaylists
import org.oxycblt.musikr.playlist.interpret.PlaylistInterpreter import org.oxycblt.musikr.playlist.interpret.PlaylistInterpreter
import org.oxycblt.musikr.tag.interpret.TagInterpreter import org.oxycblt.musikr.tag.interpret.Interpreter
internal interface EvaluateStep { internal interface EvaluateStep {
suspend fun evaluate(complete: Flow<Complete>): MutableLibrary suspend fun evaluate(complete: Flow<Complete>): MutableLibrary
@ -41,7 +41,7 @@ internal interface EvaluateStep {
companion object { companion object {
fun new(storage: Storage, interpretation: Interpretation): EvaluateStep = fun new(storage: Storage, interpretation: Interpretation): EvaluateStep =
EvaluateStepImpl( EvaluateStepImpl(
TagInterpreter.new(interpretation), Interpreter.new(interpretation),
PlaylistInterpreter.new(interpretation), PlaylistInterpreter.new(interpretation),
storage.storedPlaylists, storage.storedPlaylists,
LibraryFactory.new()) LibraryFactory.new())
@ -49,7 +49,7 @@ internal interface EvaluateStep {
} }
private class EvaluateStepImpl( private class EvaluateStepImpl(
private val tagInterpreter: TagInterpreter, private val interpreter: Interpreter,
private val playlistInterpreter: PlaylistInterpreter, private val playlistInterpreter: PlaylistInterpreter,
private val storedPlaylists: StoredPlaylists, private val storedPlaylists: StoredPlaylists,
private val libraryFactory: LibraryFactory private val libraryFactory: LibraryFactory
@ -65,7 +65,7 @@ private class EvaluateStepImpl(
val rawSongs = filterFlow.right val rawSongs = filterFlow.right
val preSongs = val preSongs =
rawSongs rawSongs
.tryMap { tagInterpreter.interpret(it) } .tryMap { interpreter.interpret(it) }
.flowOn(Dispatchers.Default) .flowOn(Dispatchers.Default)
.buffer(Channel.UNLIMITED) .buffer(Channel.UNLIMITED)
val prePlaylists = val prePlaylists =

View file

@ -30,15 +30,15 @@ import org.oxycblt.musikr.tag.format.parseId3GenreNames
import org.oxycblt.musikr.tag.parse.ParsedTags import org.oxycblt.musikr.tag.parse.ParsedTags
import org.oxycblt.musikr.util.toUuidOrNull import org.oxycblt.musikr.util.toUuidOrNull
internal interface TagInterpreter { internal interface Interpreter {
fun interpret(song: RawSong): PreSong fun interpret(song: RawSong): PreSong
companion object { companion object {
fun new(interpretation: Interpretation): TagInterpreter = TagInterpreterImpl(interpretation) fun new(interpretation: Interpretation): Interpreter = InterpreterImpl(interpretation)
} }
} }
private class TagInterpreterImpl(private val interpretation: Interpretation) : TagInterpreter { private class InterpreterImpl(private val interpretation: Interpretation) : Interpreter {
override fun interpret(song: RawSong): PreSong { override fun interpret(song: RawSong): PreSong {
val individualPreArtists = val individualPreArtists =
makePreArtists( makePreArtists(