Start integrating some more song metadata
This commit is contained in:
parent
4648e56b15
commit
bdbea9fb42
12 changed files with 89 additions and 22 deletions
|
@ -39,6 +39,9 @@ class HistoryEntity(
|
||||||
@ColumnInfo(name = "artist_name")
|
@ColumnInfo(name = "artist_name")
|
||||||
val artistName: String,
|
val artistName: String,
|
||||||
val composer: String?,
|
val composer: String?,
|
||||||
|
@ColumnInfo(name = "cover_art")
|
||||||
|
val coverArt: String?,
|
||||||
|
val genres: String?,
|
||||||
@ColumnInfo(name = "album_artist")
|
@ColumnInfo(name = "album_artist")
|
||||||
val albumArtist: String?,
|
val albumArtist: String?,
|
||||||
@ColumnInfo(name = "time_played")
|
@ColumnInfo(name = "time_played")
|
||||||
|
|
|
@ -41,6 +41,9 @@ class PlayCountEntity(
|
||||||
val composer: String?,
|
val composer: String?,
|
||||||
@ColumnInfo(name = "album_artist")
|
@ColumnInfo(name = "album_artist")
|
||||||
val albumArtist: String?,
|
val albumArtist: String?,
|
||||||
|
@ColumnInfo(name = "cover_art")
|
||||||
|
val coverArt: String?,
|
||||||
|
val genres: String?,
|
||||||
@ColumnInfo(name = "time_played")
|
@ColumnInfo(name = "time_played")
|
||||||
val timePlayed: Long,
|
val timePlayed: Long,
|
||||||
@ColumnInfo(name = "play_count")
|
@ColumnInfo(name = "play_count")
|
||||||
|
|
|
@ -19,7 +19,7 @@ import androidx.room.RoomDatabase
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
entities = [PlaylistEntity::class, SongEntity::class, HistoryEntity::class, PlayCountEntity::class, BlackListStoreEntity::class, LyricsEntity::class],
|
entities = [PlaylistEntity::class, SongEntity::class, HistoryEntity::class, PlayCountEntity::class, BlackListStoreEntity::class, LyricsEntity::class],
|
||||||
version = 23,
|
version = 24,
|
||||||
exportSchema = false
|
exportSchema = false
|
||||||
)
|
)
|
||||||
abstract class RetroDatabase : RoomDatabase() {
|
abstract class RetroDatabase : RoomDatabase() {
|
||||||
|
|
|
@ -48,5 +48,8 @@ class SongEntity(
|
||||||
val artistName: String,
|
val artistName: String,
|
||||||
val composer: String?,
|
val composer: String?,
|
||||||
@ColumnInfo(name = "album_artist")
|
@ColumnInfo(name = "album_artist")
|
||||||
val albumArtist: String?
|
val albumArtist: String?,
|
||||||
|
@ColumnInfo(name = "cover_art")
|
||||||
|
val coverArt: String?,
|
||||||
|
val genres: String?
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
|
|
@ -43,7 +43,9 @@ fun Song.toHistoryEntity(timePlayed: Long): HistoryEntity {
|
||||||
artistName = artistName,
|
artistName = artistName,
|
||||||
composer = composer,
|
composer = composer,
|
||||||
albumArtist = albumArtist,
|
albumArtist = albumArtist,
|
||||||
timePlayed = timePlayed
|
timePlayed = timePlayed,
|
||||||
|
coverArt = coverArt,
|
||||||
|
genres = genres?.joinToString(";")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +64,9 @@ fun Song.toSongEntity(playListId: Long): SongEntity {
|
||||||
artistId = artistId,
|
artistId = artistId,
|
||||||
artistName = artistName,
|
artistName = artistName,
|
||||||
composer = composer,
|
composer = composer,
|
||||||
albumArtist = albumArtist
|
albumArtist = albumArtist,
|
||||||
|
coverArt = coverArt,
|
||||||
|
genres = genres?.joinToString(";")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +84,9 @@ fun SongEntity.toSong(): Song {
|
||||||
artistId = artistId,
|
artistId = artistId,
|
||||||
artistName = artistName,
|
artistName = artistName,
|
||||||
composer = composer,
|
composer = composer,
|
||||||
albumArtist = albumArtist
|
albumArtist = albumArtist,
|
||||||
|
coverArt = coverArt,
|
||||||
|
genres = genres?.split(';')?.toTypedArray()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +104,9 @@ fun PlayCountEntity.toSong(): Song {
|
||||||
artistId = artistId,
|
artistId = artistId,
|
||||||
artistName = artistName,
|
artistName = artistName,
|
||||||
composer = composer,
|
composer = composer,
|
||||||
albumArtist = albumArtist
|
albumArtist = albumArtist,
|
||||||
|
coverArt = coverArt,
|
||||||
|
genres = genres?.split(';')?.toTypedArray()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +124,9 @@ fun HistoryEntity.toSong(): Song {
|
||||||
artistId = artistId,
|
artistId = artistId,
|
||||||
artistName = artistName,
|
artistName = artistName,
|
||||||
composer = composer,
|
composer = composer,
|
||||||
albumArtist = albumArtist
|
albumArtist = albumArtist,
|
||||||
|
coverArt = coverArt,
|
||||||
|
genres = genres?.split(';')?.toTypedArray()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +146,9 @@ fun Song.toPlayCount(): PlayCountEntity {
|
||||||
composer = composer,
|
composer = composer,
|
||||||
albumArtist = albumArtist,
|
albumArtist = albumArtist,
|
||||||
timePlayed = System.currentTimeMillis(),
|
timePlayed = System.currentTimeMillis(),
|
||||||
playCount = 1
|
playCount = 1,
|
||||||
|
coverArt = coverArt,
|
||||||
|
genres = genres?.joinToString(";")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.ArtistSignatureUtil
|
import code.name.monkey.retromusic.util.ArtistSignatureUtil
|
||||||
import code.name.monkey.retromusic.util.CustomArtistImageUtil.Companion.getFile
|
import code.name.monkey.retromusic.util.CustomArtistImageUtil.Companion.getFile
|
||||||
import code.name.monkey.retromusic.util.CustomArtistImageUtil.Companion.getInstance
|
import code.name.monkey.retromusic.util.CustomArtistImageUtil.Companion.getInstance
|
||||||
import code.name.monkey.retromusic.util.MusicUtil.getMediaStoreAlbumCoverUri
|
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import com.bumptech.glide.GenericTransitionOptions
|
import com.bumptech.glide.GenericTransitionOptions
|
||||||
import com.bumptech.glide.Priority
|
import com.bumptech.glide.Priority
|
||||||
|
@ -51,10 +50,11 @@ object RetroGlideExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSongModel(song: Song, ignoreMediaStore: Boolean): Any {
|
private fun getSongModel(song: Song, ignoreMediaStore: Boolean): Any {
|
||||||
return if (ignoreMediaStore) {
|
return if (!song.coverArt.isNullOrEmpty()) {
|
||||||
AudioFileCover(song.data)
|
song.coverArtUri!!
|
||||||
} else {
|
} else {
|
||||||
getMediaStoreAlbumCoverUri(song.albumId)
|
// this won't work but is a fallback for now i guess lol
|
||||||
|
AudioFileCover(song.data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,9 @@ class PlaylistSong(
|
||||||
val playlistId: Long,
|
val playlistId: Long,
|
||||||
val idInPlayList: Long,
|
val idInPlayList: Long,
|
||||||
override val composer: String?,
|
override val composer: String?,
|
||||||
override val albumArtist: String?
|
override val albumArtist: String?,
|
||||||
|
override val coverArt: String?,
|
||||||
|
override val genres: Array<String>?
|
||||||
) : Song(
|
) : Song(
|
||||||
id = id,
|
id = id,
|
||||||
title = title,
|
title = title,
|
||||||
|
@ -48,7 +50,9 @@ class PlaylistSong(
|
||||||
artistId = artistId,
|
artistId = artistId,
|
||||||
artistName = artistName,
|
artistName = artistName,
|
||||||
composer = composer,
|
composer = composer,
|
||||||
albumArtist = albumArtist
|
albumArtist = albumArtist,
|
||||||
|
coverArt = coverArt,
|
||||||
|
genres = genres
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
|
@ -73,6 +77,8 @@ class PlaylistSong(
|
||||||
if (idInPlayList != other.idInPlayList) return false
|
if (idInPlayList != other.idInPlayList) return false
|
||||||
if (composer != other.composer) return false
|
if (composer != other.composer) return false
|
||||||
if (albumArtist != other.albumArtist) return false
|
if (albumArtist != other.albumArtist) return false
|
||||||
|
if (coverArt != other.coverArt) return false
|
||||||
|
if (!genres.contentEquals(other.genres)) return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -93,7 +99,9 @@ class PlaylistSong(
|
||||||
result = 31 * result + playlistId.hashCode()
|
result = 31 * result + playlistId.hashCode()
|
||||||
result = 31 * result + idInPlayList.hashCode()
|
result = 31 * result + idInPlayList.hashCode()
|
||||||
result = 31 * result + composer.hashCode()
|
result = 31 * result + composer.hashCode()
|
||||||
result = 31 * result + (albumArtist?.hashCode() ?: 0)
|
result = 31 * result + albumArtist.hashCode()
|
||||||
|
result = 31 * result + coverArt.hashCode()
|
||||||
|
result = 31 * result + genres.contentHashCode()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,6 +13,7 @@
|
||||||
*/
|
*/
|
||||||
package code.name.monkey.retromusic.model
|
package code.name.monkey.retromusic.model
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ open class Song(
|
||||||
open val trackNumber: Int,
|
open val trackNumber: Int,
|
||||||
open val year: Int,
|
open val year: Int,
|
||||||
open val duration: Long,
|
open val duration: Long,
|
||||||
|
// stream path
|
||||||
open val data: String,
|
open val data: String,
|
||||||
open val dateModified: Long,
|
open val dateModified: Long,
|
||||||
open val albumId: Long,
|
open val albumId: Long,
|
||||||
|
@ -31,9 +33,14 @@ open class Song(
|
||||||
open val artistId: Long,
|
open val artistId: Long,
|
||||||
open val artistName: String,
|
open val artistName: String,
|
||||||
open val composer: String?,
|
open val composer: String?,
|
||||||
open val albumArtist: String?
|
open val albumArtist: String?,
|
||||||
|
open val coverArt: String?,
|
||||||
|
// TODO: store genres in a smarter way
|
||||||
|
open val genres: Array<String>?
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
|
val coverArtUri: Uri?
|
||||||
|
get() = Uri.parse(coverArt)
|
||||||
|
|
||||||
// need to override manually because is open and cannot be a data class
|
// need to override manually because is open and cannot be a data class
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
|
@ -55,6 +62,8 @@ open class Song(
|
||||||
if (artistName != other.artistName) return false
|
if (artistName != other.artistName) return false
|
||||||
if (composer != other.composer) return false
|
if (composer != other.composer) return false
|
||||||
if (albumArtist != other.albumArtist) return false
|
if (albumArtist != other.albumArtist) return false
|
||||||
|
if (coverArt != other.coverArt) return false
|
||||||
|
if (!genres.contentEquals(other.genres)) return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -73,6 +82,8 @@ open class Song(
|
||||||
result = 31 * result + artistName.hashCode()
|
result = 31 * result + artistName.hashCode()
|
||||||
result = 31 * result + (composer?.hashCode() ?: 0)
|
result = 31 * result + (composer?.hashCode() ?: 0)
|
||||||
result = 31 * result + (albumArtist?.hashCode() ?: 0)
|
result = 31 * result + (albumArtist?.hashCode() ?: 0)
|
||||||
|
result = 31 * result + (coverArt?.hashCode() ?: 0)
|
||||||
|
result = 31 * result + (genres?.contentHashCode() ?: 0)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +104,9 @@ open class Song(
|
||||||
artistId = -1,
|
artistId = -1,
|
||||||
artistName = "",
|
artistName = "",
|
||||||
composer = "",
|
composer = "",
|
||||||
albumArtist = ""
|
albumArtist = "",
|
||||||
|
coverArt = "",
|
||||||
|
genres = emptyArray()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -53,6 +53,7 @@ interface PlaylistRepository {
|
||||||
fun playlistSongs(playlistId: Long): List<Song>
|
fun playlistSongs(playlistId: Long): List<Song>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: uncursorify this
|
||||||
class RealPlaylistRepository(
|
class RealPlaylistRepository(
|
||||||
private val contentResolver: ContentResolver
|
private val contentResolver: ContentResolver
|
||||||
) : PlaylistRepository {
|
) : PlaylistRepository {
|
||||||
|
@ -168,7 +169,9 @@ class RealPlaylistRepository(
|
||||||
playlistId,
|
playlistId,
|
||||||
idInPlaylist,
|
idInPlaylist,
|
||||||
composer ?: "",
|
composer ?: "",
|
||||||
albumArtist
|
albumArtist,
|
||||||
|
null,
|
||||||
|
emptyArray()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import code.name.monkey.retromusic.model.Song
|
||||||
* Created by hemanths on 16/08/17.
|
* Created by hemanths on 16/08/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO: uncursorify this
|
||||||
object PlaylistSongsLoader {
|
object PlaylistSongsLoader {
|
||||||
|
|
||||||
fun getPlaylistSongList(
|
fun getPlaylistSongList(
|
||||||
|
@ -99,7 +100,9 @@ object PlaylistSongsLoader {
|
||||||
playlistId,
|
playlistId,
|
||||||
idInPlaylist,
|
idInPlaylist,
|
||||||
composer,
|
composer,
|
||||||
albumArtist
|
albumArtist,
|
||||||
|
null,
|
||||||
|
emptyArray()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ class RealSongRepository(private val context: Context) : SongRepository {
|
||||||
"river-lake convergence",
|
"river-lake convergence",
|
||||||
1,
|
1,
|
||||||
2021,
|
2021,
|
||||||
23723478,
|
237234,
|
||||||
"https://versary.town/river-lake-convergence.mp3",
|
"https://versary.town/river-lake-convergence.mp3",
|
||||||
1639589623,
|
1639589623,
|
||||||
1,
|
1,
|
||||||
|
@ -93,7 +93,26 @@ class RealSongRepository(private val context: Context) : SongRepository {
|
||||||
1,
|
1,
|
||||||
"annieversary",
|
"annieversary",
|
||||||
null,
|
null,
|
||||||
"annieversary"
|
"annieversary",
|
||||||
|
"https://i1.sndcdn.com/artworks-T3nLbND6w681B2ey-YDI6ew-t500x500.jpg",
|
||||||
|
genres = arrayOf("Lakecore")
|
||||||
|
),
|
||||||
|
Song(
|
||||||
|
2,
|
||||||
|
"river-lake convergence 2",
|
||||||
|
1,
|
||||||
|
2021,
|
||||||
|
237234,
|
||||||
|
"https://versary.town/river-lake-convergence.mp3",
|
||||||
|
1639589623,
|
||||||
|
2,
|
||||||
|
"river-lake convergence 2",
|
||||||
|
1,
|
||||||
|
"annieversary",
|
||||||
|
null,
|
||||||
|
"annieversary",
|
||||||
|
"https://i1.sndcdn.com/artworks-T3nLbND6w681B2ey-YDI6ew-t500x500.jpg",
|
||||||
|
genres = arrayOf("Lakecore")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -854,7 +854,7 @@ public class MusicService extends MediaBrowserServiceCompat
|
||||||
.setMediaId(String.valueOf(song.getId()))
|
.setMediaId(String.valueOf(song.getId()))
|
||||||
.setTitle(song.getTitle())
|
.setTitle(song.getTitle())
|
||||||
.setSubtitle(song.getArtistName())
|
.setSubtitle(song.getArtistName())
|
||||||
.setIconUri(MusicUtil.getMediaStoreAlbumCoverUri(song.getAlbumId()))
|
.setIconUri(song.getCoverArtUri())
|
||||||
.build(), FLAG_PLAYABLE
|
.build(), FLAG_PLAYABLE
|
||||||
);
|
);
|
||||||
result.sendResult(Collections.singletonList(mediaItem));
|
result.sendResult(Collections.singletonList(mediaItem));
|
||||||
|
|
Loading…
Reference in a new issue