musikr: reformat
This commit is contained in:
parent
55d3bd79ba
commit
2fd4fd751f
3 changed files with 27 additions and 5 deletions
|
@ -27,14 +27,17 @@ internal class PlaylistGraph {
|
||||||
|
|
||||||
fun link(vertex: PlaylistVertex) {
|
fun link(vertex: PlaylistVertex) {
|
||||||
for ((pointer, songVertex) in pointerMap) {
|
for ((pointer, songVertex) in pointerMap) {
|
||||||
|
// Link the vertices we are already aware of to this vertex.
|
||||||
vertex.pointerMap[pointer]?.forEach { index -> vertex.songVertices[index] = songVertex }
|
vertex.pointerMap[pointer]?.forEach { index -> vertex.songVertices[index] = songVertex }
|
||||||
}
|
}
|
||||||
|
vertices.add(vertex)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun link(vertex: SongVertex) {
|
fun link(vertex: SongVertex) {
|
||||||
val pointer = SongPointer.UID(vertex.preSong.uid)
|
val pointer = SongPointer.UID(vertex.preSong.uid)
|
||||||
pointerMap[pointer] = vertex
|
pointerMap[pointer] = vertex
|
||||||
for (playlistVertex in vertices) {
|
for (playlistVertex in vertices) {
|
||||||
|
// Retroactively update previously known playlists to add the new vertex.
|
||||||
playlistVertex.pointerMap[pointer]?.forEach { index ->
|
playlistVertex.pointerMap[pointer]?.forEach { index ->
|
||||||
playlistVertex.songVertices[index] = vertex
|
playlistVertex.songVertices[index] = vertex
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,14 +30,16 @@ internal class SongGraph(
|
||||||
private val vertices = mutableMapOf<Music.UID, SongVertex>()
|
private val vertices = mutableMapOf<Music.UID, SongVertex>()
|
||||||
|
|
||||||
fun link(vertex: SongVertex): Boolean {
|
fun link(vertex: SongVertex): Boolean {
|
||||||
val preSong = vertex.preSong
|
val uid = vertex.preSong.uid
|
||||||
val uid = preSong.uid
|
|
||||||
if (vertices.containsKey(uid)) {
|
if (vertices.containsKey(uid)) {
|
||||||
|
// Discard songs with duplicate ID's, they wreck the entire
|
||||||
|
// music model and they're pretty much always the same file.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// Link the vertex to the rest of the graph now.
|
||||||
|
albumGraph.link(vertex)
|
||||||
artistGraph.link(vertex)
|
artistGraph.link(vertex)
|
||||||
genreGraph.link(vertex)
|
genreGraph.link(vertex)
|
||||||
albumGraph.link(vertex)
|
|
||||||
playlistGraph.link(vertex)
|
playlistGraph.link(vertex)
|
||||||
vertices[uid] = vertex
|
vertices[uid] = vertex
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -1,6 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025 Auxio Project
|
||||||
|
* ID3Genre.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.tag.interpret
|
package org.oxycblt.musikr.tag.interpret
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a multi-value genre name using ID3 rules. This will convert any ID3v1 integer
|
* Parse a multi-value genre name using ID3 rules. This will convert any ID3v1 integer
|
||||||
* representations of genre fields into their named counterparts, and split up singular ID3v2-style
|
* representations of genre fields into their named counterparts, and split up singular ID3v2-style
|
||||||
|
@ -36,7 +53,7 @@ private fun String.parseId3v1Genre(): String? {
|
||||||
// try to index the genre table with such.
|
// try to index the genre table with such.
|
||||||
val numeric =
|
val numeric =
|
||||||
toIntOrNull()
|
toIntOrNull()
|
||||||
// Not a numeric value, try some other fixed values.
|
// Not a numeric value, try some other fixed values.
|
||||||
?: return when (this) {
|
?: return when (this) {
|
||||||
// CR and RX are not technically ID3v1, but are formatted similarly to a plain
|
// CR and RX are not technically ID3v1, but are formatted similarly to a plain
|
||||||
// number.
|
// number.
|
||||||
|
|
Loading…
Reference in a new issue