all: fix formatting
This commit is contained in:
parent
7fab7f7eeb
commit
880967f8be
17 changed files with 356 additions and 335 deletions
|
@ -41,7 +41,7 @@ spotless {
|
|||
|
||||
cpp {
|
||||
target "*/src/**/cpp/*.cpp"
|
||||
clangFormat("18.1.8").
|
||||
eclipseCdt()
|
||||
licenseHeaderFile("NOTICE")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,29 +22,30 @@
|
|||
|
||||
// TODO: Handle stream exceptions
|
||||
|
||||
JVMInputStream::JVMInputStream(JNIEnv *env, jobject inputStream)
|
||||
: env(env), inputStream(inputStream) {
|
||||
if (!env->IsInstanceOf(
|
||||
inputStream,
|
||||
JVMInputStream::JVMInputStream(JNIEnv *env, jobject inputStream) : env(env), inputStream(
|
||||
inputStream) {
|
||||
if (!env->IsInstanceOf(inputStream,
|
||||
env->FindClass("org/oxycblt/musikr/metadata/NativeInputStream"))) {
|
||||
throw std::runtime_error("oStream is not an instance of TagLibOStream");
|
||||
}
|
||||
jclass inputStreamClass =
|
||||
env->FindClass("org/oxycblt/musikr/metadata/NativeInputStream");
|
||||
inputStreamNameMethod =
|
||||
env->GetMethodID(inputStreamClass, "name", "()Ljava/lang/String;");
|
||||
inputStreamReadBlockMethod =
|
||||
env->GetMethodID(inputStreamClass, "readBlock", "(J)[B");
|
||||
inputStreamIsOpenMethod = env->GetMethodID(inputStreamClass, "isOpen", "()Z");
|
||||
inputStreamSeekFromBeginningMethod =
|
||||
env->GetMethodID(inputStreamClass, "seekFromBeginning", "(J)V");
|
||||
inputStreamSeekFromCurrentMethod =
|
||||
env->GetMethodID(inputStreamClass, "seekFromCurrent", "(J)V");
|
||||
inputStreamSeekFromEndMethod =
|
||||
env->GetMethodID(inputStreamClass, "seekFromEnd", "(J)V");
|
||||
jclass inputStreamClass = env->FindClass(
|
||||
"org/oxycblt/musikr/metadata/NativeInputStream");
|
||||
inputStreamNameMethod = env->GetMethodID(inputStreamClass, "name",
|
||||
"()Ljava/lang/String;");
|
||||
inputStreamReadBlockMethod = env->GetMethodID(inputStreamClass, "readBlock",
|
||||
"(J)[B");
|
||||
inputStreamIsOpenMethod = env->GetMethodID(inputStreamClass, "isOpen",
|
||||
"()Z");
|
||||
inputStreamSeekFromBeginningMethod = env->GetMethodID(inputStreamClass,
|
||||
"seekFromBeginning", "(J)V");
|
||||
inputStreamSeekFromCurrentMethod = env->GetMethodID(inputStreamClass,
|
||||
"seekFromCurrent", "(J)V");
|
||||
inputStreamSeekFromEndMethod = env->GetMethodID(inputStreamClass,
|
||||
"seekFromEnd", "(J)V");
|
||||
inputStreamClearMethod = env->GetMethodID(inputStreamClass, "clear", "()V");
|
||||
inputStreamTellMethod = env->GetMethodID(inputStreamClass, "tell", "()J");
|
||||
inputStreamLengthMethod = env->GetMethodID(inputStreamClass, "length", "()J");
|
||||
inputStreamLengthMethod = env->GetMethodID(inputStreamClass, "length",
|
||||
"()J");
|
||||
env->DeleteLocalRef(inputStreamClass);
|
||||
}
|
||||
|
||||
|
@ -54,8 +55,8 @@ JVMInputStream::~JVMInputStream() {
|
|||
}
|
||||
|
||||
TagLib::FileName JVMInputStream::name() const {
|
||||
auto name =
|
||||
(jstring)env->CallObjectMethod(inputStream, inputStreamNameMethod);
|
||||
auto name = (jstring) env->CallObjectMethod(inputStream,
|
||||
inputStreamNameMethod);
|
||||
const char *nameChars = env->GetStringUTFChars(name, nullptr);
|
||||
auto fileName = TagLib::FileName(nameChars);
|
||||
env->ReleaseStringUTFChars(name, nameChars);
|
||||
|
@ -63,8 +64,8 @@ TagLib::FileName JVMInputStream::name() const {
|
|||
}
|
||||
|
||||
TagLib::ByteVector JVMInputStream::readBlock(size_t length) {
|
||||
auto data = (jbyteArray)env->CallObjectMethod(
|
||||
inputStream, inputStreamReadBlockMethod, length);
|
||||
auto data = (jbyteArray) env->CallObjectMethod(inputStream,
|
||||
inputStreamReadBlockMethod, length);
|
||||
jsize dataLength = env->GetArrayLength(data);
|
||||
auto dataBytes = env->GetByteArrayElements(data, nullptr);
|
||||
TagLib::ByteVector byteVector(reinterpret_cast<const char*>(dataBytes),
|
||||
|
@ -86,7 +87,9 @@ void JVMInputStream::removeBlock(TagLib::offset_t start, size_t length) {
|
|||
throw std::runtime_error("Not implemented");
|
||||
}
|
||||
|
||||
bool JVMInputStream::readOnly() const { return true; }
|
||||
bool JVMInputStream::readOnly() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JVMInputStream::isOpen() const {
|
||||
return env->CallBooleanMethod(inputStream, inputStreamIsOpenMethod);
|
||||
|
@ -100,7 +103,8 @@ void JVMInputStream::seek(TagLib::offset_t offset, Position p) {
|
|||
joffset);
|
||||
break;
|
||||
case Current:
|
||||
env->CallVoidMethod(inputStream, inputStreamSeekFromCurrentMethod, joffset);
|
||||
env->CallVoidMethod(inputStream, inputStreamSeekFromCurrentMethod,
|
||||
joffset);
|
||||
break;
|
||||
case End:
|
||||
env->CallVoidMethod(inputStream, inputStreamSeekFromEndMethod, joffset);
|
||||
|
|
|
@ -21,8 +21,9 @@
|
|||
#include <taglib/mp4tag.h>
|
||||
#include <taglib/textidentificationframe.h>
|
||||
|
||||
JVMMetadataBuilder::JVMMetadataBuilder(JNIEnv *env)
|
||||
: env(env), id3v2(env), xiph(env), mp4(env), cover(), properties(nullptr) {}
|
||||
JVMMetadataBuilder::JVMMetadataBuilder(JNIEnv *env) : env(env), id3v2(env), xiph(
|
||||
env), mp4(env), cover(), properties(nullptr) {
|
||||
}
|
||||
|
||||
void JVMMetadataBuilder::setMimeType(const std::string_view type) {
|
||||
this->mimeType = type;
|
||||
|
@ -35,13 +36,12 @@ void JVMMetadataBuilder::setId3v2(const TagLib::ID3v2::Tag &tag) {
|
|||
TagLib::StringList frameText = txxxFrame->fieldList();
|
||||
// Frame text starts with the description then the remaining values
|
||||
auto begin = frameText.begin();
|
||||
TagLib::String key =
|
||||
TagLib::String(frame->frameID()) + ":" + begin->upper();
|
||||
TagLib::String key = TagLib::String(frame->frameID()) + ":"
|
||||
+ begin->upper();
|
||||
frameText.erase(begin);
|
||||
id3v2.add(key, frameText);
|
||||
} else if (auto textFrame =
|
||||
dynamic_cast<TagLib::ID3v2::TextIdentificationFrame *>(
|
||||
frame)) {
|
||||
dynamic_cast<TagLib::ID3v2::TextIdentificationFrame*>(frame)) {
|
||||
TagLib::String key = frame->frameID();
|
||||
TagLib::StringList frameText = textFrame->fieldList();
|
||||
id3v2.add(key, frameText);
|
||||
|
@ -96,8 +96,8 @@ void JVMMetadataBuilder::setMp4(const TagLib::MP4::Tag &tag) {
|
|||
// It's inefficient going from the integer representation back into
|
||||
// a string, but I fully expect taggers to just write "NN/TT" strings
|
||||
// anyway, and musikr doesn't have to do as much fiddly variant handling.
|
||||
auto value = std::to_string(itemValue.toIntPair().first) + "/" +
|
||||
std::to_string(itemValue.toIntPair().second);
|
||||
auto value = std::to_string(itemValue.toIntPair().first) + "/"
|
||||
+ std::to_string(itemValue.toIntPair().second);
|
||||
id3v2.add(itemName, value);
|
||||
return;
|
||||
}
|
||||
|
@ -129,19 +129,19 @@ void JVMMetadataBuilder::setProperties(TagLib::AudioProperties *properties) {
|
|||
}
|
||||
|
||||
jobject JVMMetadataBuilder::build() {
|
||||
jclass propertiesClass =
|
||||
env->FindClass("org/oxycblt/musikr/metadata/Properties");
|
||||
jmethodID propertiesInit =
|
||||
env->GetMethodID(propertiesClass, "<init>", "(Ljava/lang/String;JII)V");
|
||||
jobject propertiesObj = env->NewObject(
|
||||
propertiesClass, propertiesInit, env->NewStringUTF(mimeType.data()),
|
||||
jclass propertiesClass = env->FindClass(
|
||||
"org/oxycblt/musikr/metadata/Properties");
|
||||
jmethodID propertiesInit = env->GetMethodID(propertiesClass, "<init>",
|
||||
"(Ljava/lang/String;JII)V");
|
||||
jobject propertiesObj = env->NewObject(propertiesClass, propertiesInit,
|
||||
env->NewStringUTF(mimeType.data()),
|
||||
(jlong) properties->lengthInMilliseconds(), properties->bitrate(),
|
||||
properties->sampleRate());
|
||||
env->DeleteLocalRef(propertiesClass);
|
||||
|
||||
jclass metadataClass = env->FindClass("org/oxycblt/musikr/metadata/Metadata");
|
||||
jmethodID metadataInit =
|
||||
env->GetMethodID(metadataClass, "<init>",
|
||||
jclass metadataClass = env->FindClass(
|
||||
"org/oxycblt/musikr/metadata/Metadata");
|
||||
jmethodID metadataInit = env->GetMethodID(metadataClass, "<init>",
|
||||
"(Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;[BLorg/"
|
||||
"oxycblt/musikr/metadata/Properties;)V");
|
||||
jobject id3v2Map = id3v2.getObject();
|
||||
|
@ -154,9 +154,8 @@ jobject JVMMetadataBuilder::build() {
|
|||
env->SetByteArrayRegion(coverArray, 0, coverSize,
|
||||
reinterpret_cast<const jbyte*>(cover->data()));
|
||||
}
|
||||
jobject metadataObj =
|
||||
env->NewObject(metadataClass, metadataInit, id3v2Map, xiphMap, mp4Map,
|
||||
coverArray, propertiesObj);
|
||||
jobject metadataObj = env->NewObject(metadataClass, metadataInit, id3v2Map,
|
||||
xiphMap, mp4Map, coverArray, propertiesObj);
|
||||
env->DeleteLocalRef(metadataClass);
|
||||
return metadataObj;
|
||||
}
|
|
@ -24,27 +24,28 @@ JVMTagMap::JVMTagMap(JNIEnv *env) : env(env) {
|
|||
hashMap = env->NewObject(hashMapClass, init);
|
||||
hashMapGetMethod = env->GetMethodID(hashMapClass, "get",
|
||||
"(Ljava/lang/Object;)Ljava/lang/Object;");
|
||||
hashMapPutMethod = env->GetMethodID(
|
||||
hashMapClass, "put",
|
||||
hashMapPutMethod = env->GetMethodID(hashMapClass, "put",
|
||||
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
||||
env->DeleteLocalRef(hashMapClass);
|
||||
|
||||
jclass arrayListClass = env->FindClass("java/util/ArrayList");
|
||||
arrayListInitMethod = env->GetMethodID(arrayListClass, "<init>", "()V");
|
||||
arrayListAddMethod =
|
||||
env->GetMethodID(arrayListClass, "add", "(Ljava/lang/Object;)Z");
|
||||
arrayListAddMethod = env->GetMethodID(arrayListClass, "add",
|
||||
"(Ljava/lang/Object;)Z");
|
||||
env->DeleteLocalRef(arrayListClass);
|
||||
}
|
||||
|
||||
JVMTagMap::~JVMTagMap() { env->DeleteLocalRef(hashMap); }
|
||||
JVMTagMap::~JVMTagMap() {
|
||||
env->DeleteLocalRef(hashMap);
|
||||
}
|
||||
|
||||
void JVMTagMap::add(TagLib::String &key, std::string_view value) {
|
||||
jstring jKey = env->NewStringUTF(key.toCString(true));
|
||||
jstring jValue = env->NewStringUTF(value.data());
|
||||
|
||||
// check if theres already a value arraylist in the map
|
||||
jobject existingValue =
|
||||
env->CallObjectMethod(hashMap, hashMapGetMethod, jKey);
|
||||
jobject existingValue = env->CallObjectMethod(hashMap, hashMapGetMethod,
|
||||
jKey);
|
||||
// if there is, add to the value to the existing arraylist
|
||||
if (existingValue != nullptr) {
|
||||
env->CallBooleanMethod(existingValue, arrayListAddMethod, jValue);
|
||||
|
@ -62,8 +63,8 @@ void JVMTagMap::add(TagLib::String &key, TagLib::StringList &value) {
|
|||
jstring jKey = env->NewStringUTF(key.toCString(true));
|
||||
|
||||
// check if theres already a value arraylist in the map
|
||||
jobject existingValue =
|
||||
env->CallObjectMethod(hashMap, hashMapGetMethod, jKey);
|
||||
jobject existingValue = env->CallObjectMethod(hashMap, hashMapGetMethod,
|
||||
jKey);
|
||||
// if there is, add to the value to the existing arraylist
|
||||
if (existingValue != nullptr) {
|
||||
for (auto &val : value) {
|
||||
|
@ -83,4 +84,6 @@ void JVMTagMap::add(TagLib::String &key, TagLib::StringList &value) {
|
|||
}
|
||||
}
|
||||
|
||||
jobject JVMTagMap::getObject() { return hashMap; }
|
||||
jobject JVMTagMap::getObject() {
|
||||
return hashMap;
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package org.oxycblt.musikr.graph
|
||||
|
||||
import org.oxycblt.musikr.Music
|
||||
import org.oxycblt.musikr.Playlist
|
||||
import org.oxycblt.musikr.playlist.PlaylistFile
|
||||
import org.oxycblt.musikr.playlist.SongPointer
|
||||
import org.oxycblt.musikr.playlist.interpret.PrePlaylist
|
||||
import org.oxycblt.musikr.tag.interpret.PreAlbum
|
||||
|
|
|
@ -41,7 +41,11 @@ internal interface LibraryFactory {
|
|||
}
|
||||
|
||||
private class LibraryFactoryImpl() : LibraryFactory {
|
||||
override fun create(graph: MusicGraph, storage: Storage, interpretation: Interpretation): MutableLibrary {
|
||||
override fun create(
|
||||
graph: MusicGraph,
|
||||
storage: Storage,
|
||||
interpretation: Interpretation
|
||||
): MutableLibrary {
|
||||
val songs =
|
||||
graph.songVertex.mapTo(mutableSetOf()) { vertex ->
|
||||
SongImpl(SongVertexCore(vertex)).also { vertex.tag = it }
|
||||
|
@ -105,8 +109,7 @@ private class LibraryFactoryImpl() : LibraryFactory {
|
|||
private class PlaylistVertexCore(vertex: PlaylistVertex) : PlaylistCore {
|
||||
override val prePlaylist = vertex.prePlaylist
|
||||
|
||||
override val songs = vertex.songVertices.mapNotNull { vertex ->
|
||||
vertex?.let { it.tag as Song }
|
||||
}
|
||||
override val songs =
|
||||
vertex.songVertices.mapNotNull { vertex -> vertex?.let { it.tag as Song } }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,11 +24,7 @@ import org.oxycblt.musikr.MutableLibrary
|
|||
import org.oxycblt.musikr.Playlist
|
||||
import org.oxycblt.musikr.Song
|
||||
import org.oxycblt.musikr.Storage
|
||||
import org.oxycblt.musikr.cover.StoredCovers
|
||||
import org.oxycblt.musikr.fs.Path
|
||||
import org.oxycblt.musikr.playlist.PlaylistHandle
|
||||
import org.oxycblt.musikr.playlist.db.PlaylistInfo
|
||||
import org.oxycblt.musikr.playlist.db.StoredPlaylists
|
||||
|
||||
internal data class LibraryImpl(
|
||||
override val songs: Collection<SongImpl>,
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.oxycblt.musikr.model
|
|||
import org.oxycblt.musikr.Playlist
|
||||
import org.oxycblt.musikr.Song
|
||||
import org.oxycblt.musikr.cover.Cover
|
||||
import org.oxycblt.musikr.playlist.PlaylistHandle
|
||||
import org.oxycblt.musikr.playlist.interpret.PrePlaylistInfo
|
||||
import org.oxycblt.musikr.tag.Name
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import kotlinx.coroutines.channels.Channel
|
|||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.buffer
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.filterIsInstance
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.merge
|
||||
|
@ -33,8 +32,6 @@ import org.oxycblt.musikr.MutableLibrary
|
|||
import org.oxycblt.musikr.Storage
|
||||
import org.oxycblt.musikr.graph.MusicGraph
|
||||
import org.oxycblt.musikr.model.LibraryFactory
|
||||
import org.oxycblt.musikr.model.PlaylistImpl
|
||||
import org.oxycblt.musikr.playlist.SongPointer
|
||||
import org.oxycblt.musikr.playlist.interpret.PlaylistInterpreter
|
||||
import org.oxycblt.musikr.tag.interpret.TagInterpreter
|
||||
|
||||
|
@ -46,7 +43,8 @@ internal interface EvaluateStep {
|
|||
): MutableLibrary
|
||||
|
||||
companion object {
|
||||
fun new(): EvaluateStep = EvaluateStepImpl(TagInterpreter.new(), PlaylistInterpreter.new(), LibraryFactory.new())
|
||||
fun new(): EvaluateStep =
|
||||
EvaluateStepImpl(TagInterpreter.new(), PlaylistInterpreter.new(), LibraryFactory.new())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +58,8 @@ private class EvaluateStepImpl(
|
|||
interpretation: Interpretation,
|
||||
extractedMusic: Flow<ExtractedMusic>
|
||||
): MutableLibrary {
|
||||
val filterFlow = extractedMusic.divert {
|
||||
val filterFlow =
|
||||
extractedMusic.divert {
|
||||
when (it) {
|
||||
is ExtractedMusic.Song -> Divert.Right(it.song)
|
||||
is ExtractedMusic.Playlist -> Divert.Left(it.file)
|
||||
|
@ -72,15 +71,16 @@ private class EvaluateStepImpl(
|
|||
.map { tagInterpreter.interpret(it, interpretation) }
|
||||
.flowOn(Dispatchers.Main)
|
||||
.buffer(Channel.UNLIMITED)
|
||||
val prePlaylists = filterFlow.left
|
||||
val prePlaylists =
|
||||
filterFlow.left
|
||||
.map { playlistInterpreter.interpret(it, interpretation) }
|
||||
.flowOn(Dispatchers.Main)
|
||||
.buffer(Channel.UNLIMITED)
|
||||
val graphBuilder = MusicGraph.builder()
|
||||
val graphBuild = merge(
|
||||
val graphBuild =
|
||||
merge(
|
||||
preSongs.onEach { graphBuilder.add(it) },
|
||||
prePlaylists.onEach { graphBuilder.add(it) }
|
||||
)
|
||||
prePlaylists.onEach { graphBuilder.add(it) })
|
||||
graphBuild.collect()
|
||||
val graph = graphBuilder.build()
|
||||
return libraryFactory.create(graph, storage, interpretation)
|
||||
|
|
|
@ -23,7 +23,6 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.buffer
|
||||
import kotlinx.coroutines.flow.filterIsInstance
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.mapNotNull
|
||||
|
@ -52,7 +51,8 @@ private class ExtractStepImpl(
|
|||
private val tagParser: TagParser
|
||||
) : ExtractStep {
|
||||
override fun extract(storage: Storage, nodes: Flow<ExploreNode>): Flow<ExtractedMusic> {
|
||||
val filterFlow = nodes.divert {
|
||||
val filterFlow =
|
||||
nodes.divert {
|
||||
when (it) {
|
||||
is ExploreNode.Audio -> Divert.Right(it.file)
|
||||
is ExploreNode.Playlist -> Divert.Left(it.file)
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.oxycblt.musikr.playlist.SongPointer
|
|||
|
||||
interface StoredPlaylists {
|
||||
suspend fun new(name: String, songs: List<Song>): PlaylistHandle
|
||||
|
||||
suspend fun read(): List<PlaylistFile>
|
||||
|
||||
companion object {
|
||||
|
@ -36,17 +37,8 @@ interface StoredPlaylists {
|
|||
|
||||
private class StoredPlaylistsImpl(private val playlistDao: PlaylistDao) : StoredPlaylists {
|
||||
override suspend fun new(name: String, songs: List<Song>): PlaylistHandle {
|
||||
val info =
|
||||
PlaylistInfo(
|
||||
Music.UID.auxio(Music.UID.Item.PLAYLIST),
|
||||
name
|
||||
)
|
||||
playlistDao.insertPlaylist(
|
||||
RawPlaylist(
|
||||
info,
|
||||
songs.map { PlaylistSong(it.uid) }
|
||||
)
|
||||
)
|
||||
val info = PlaylistInfo(Music.UID.auxio(Music.UID.Item.PLAYLIST), name)
|
||||
playlistDao.insertPlaylist(RawPlaylist(info, songs.map { PlaylistSong(it.uid) }))
|
||||
return StoredPlaylistHandle(info, playlistDao)
|
||||
}
|
||||
|
||||
|
@ -55,7 +47,6 @@ private class StoredPlaylistsImpl(private val playlistDao: PlaylistDao) : Stored
|
|||
PlaylistFile(
|
||||
it.playlistInfo.name,
|
||||
it.songs.map { song -> SongPointer.UID(song.songUid) },
|
||||
StoredPlaylistHandle(it.playlistInfo, playlistDao)
|
||||
)
|
||||
StoredPlaylistHandle(it.playlistInfo, playlistDao))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Auxio Project
|
||||
* PlaylistInterpreter.kt is part of Auxio.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.oxycblt.musikr.playlist.interpret
|
||||
|
||||
import org.oxycblt.musikr.Interpretation
|
||||
import org.oxycblt.musikr.playlist.PlaylistFile
|
||||
import org.oxycblt.musikr.playlist.PlaylistHandle
|
||||
import org.oxycblt.musikr.playlist.SongPointer
|
||||
|
||||
internal interface PlaylistInterpreter {
|
||||
fun interpret(file: PlaylistFile, interpretation: Interpretation): PrePlaylist
|
||||
|
@ -25,18 +42,12 @@ private data object PlaylistInterpreterImpl : PlaylistInterpreter {
|
|||
name = interpretation.naming.name(file.name, null),
|
||||
rawName = file.name,
|
||||
handle = file.handle,
|
||||
songPointers = file.songPointers
|
||||
)
|
||||
songPointers = file.songPointers)
|
||||
|
||||
override fun interpret(
|
||||
name: String,
|
||||
handle: PlaylistHandle,
|
||||
interpretation: Interpretation
|
||||
): PostPlaylist =
|
||||
PostPlaylist(
|
||||
name = interpretation.naming.name(name, null),
|
||||
rawName = name,
|
||||
handle = handle
|
||||
)
|
||||
|
||||
PostPlaylist(name = interpretation.naming.name(name, null), rawName = name, handle = handle)
|
||||
}
|
|
@ -1,3 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Auxio Project
|
||||
* PrePlaylist.kt is part of Auxio.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.oxycblt.musikr.playlist.interpret
|
||||
|
||||
import org.oxycblt.musikr.playlist.PlaylistHandle
|
||||
|
|
|
@ -67,12 +67,13 @@ sealed interface Name : Comparable<Name> {
|
|||
}
|
||||
|
||||
/** An individual part of a name string that can be compared intelligently. */
|
||||
class Token
|
||||
internal constructor(internal val collationKey: CollationKey, internal val type: Type) :
|
||||
class Token internal constructor(internal val collationKey: CollationKey, internal val type: Type) :
|
||||
Comparable<Token> {
|
||||
override fun equals(other: Any?) =
|
||||
other is Token && collationKey == other.collationKey && type == other.type
|
||||
|
||||
override fun hashCode() = 31 * collationKey.hashCode() + type.hashCode()
|
||||
|
||||
val value: String
|
||||
get() = collationKey.sourceString
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.oxycblt.musikr.Music
|
|||
import org.oxycblt.musikr.cover.Cover
|
||||
import org.oxycblt.musikr.fs.Format
|
||||
import org.oxycblt.musikr.fs.Path
|
||||
import org.oxycblt.musikr.playlist.PlaylistHandle
|
||||
import org.oxycblt.musikr.tag.Date
|
||||
import org.oxycblt.musikr.tag.Disc
|
||||
import org.oxycblt.musikr.tag.Name
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.oxycblt.musikr.tag.interpret
|
|||
import org.oxycblt.musikr.Interpretation
|
||||
import org.oxycblt.musikr.fs.Format
|
||||
import org.oxycblt.musikr.pipeline.RawSong
|
||||
import org.oxycblt.musikr.playlist.PlaylistFile
|
||||
import org.oxycblt.musikr.tag.Disc
|
||||
import org.oxycblt.musikr.tag.Name
|
||||
import org.oxycblt.musikr.tag.Placeholder
|
||||
|
|
Loading…
Reference in a new issue