bring in database

switch to just using source models (no extra db fields)
start re-implementing sync service
This commit is contained in:
austinried
2025-11-07 11:45:13 +09:00
parent f1c734d432
commit 0e6acbed0f
18 changed files with 6747 additions and 625 deletions

View File

@@ -2,7 +2,7 @@ import 'package:xml/xml.dart';
import '../models.dart';
SourceArtist mapArtist(XmlElement e, XmlElement? info) => SourceArtist(
Artist mapArtist(XmlElement e, XmlElement? info) => Artist(
id: e.getAttribute('id')!,
name: e.getAttribute('name')!,
starred: DateTime.tryParse(e.getAttribute('starred').toString()),
@@ -10,11 +10,11 @@ SourceArtist mapArtist(XmlElement e, XmlElement? info) => SourceArtist(
largeImage: Uri.tryParse(info?.getElement('largeImageUrl')?.innerText ?? ''),
);
SourceAlbum mapAlbum(
Album mapAlbum(
XmlElement e, {
int? frequentRank,
int? recentRank,
}) => SourceAlbum(
}) => Album(
id: e.getAttribute('id')!,
artistId: e.getAttribute('artistId'),
name: e.getAttribute('name')!,
@@ -28,7 +28,7 @@ SourceAlbum mapAlbum(
recentRank: recentRank,
);
SourcePlaylist mapPlaylist(XmlElement e) => SourcePlaylist(
Playlist mapPlaylist(XmlElement e) => Playlist(
id: e.getAttribute('id')!,
name: e.getAttribute('name')!,
comment: e.getAttribute('comment'),
@@ -36,10 +36,9 @@ SourcePlaylist mapPlaylist(XmlElement e) => SourcePlaylist(
created: DateTime.parse(e.getAttribute('created')!),
changed: DateTime.parse(e.getAttribute('changed')!),
owner: e.getAttribute('owner'),
public: bool.tryParse(e.getAttribute('public').toString()),
);
SourceSong mapSong(XmlElement e) => SourceSong(
Song mapSong(XmlElement e) => Song(
id: e.getAttribute('id')!,
albumId: e.getAttribute('albumId'),
artistId: e.getAttribute('artistId'),
@@ -57,10 +56,10 @@ SourceSong mapSong(XmlElement e) => SourceSong(
genre: e.getAttribute('genre'),
);
SourcePlaylistSong mapPlaylistSong(
PlaylistSong mapPlaylistSong(
int index,
XmlElement e,
) => SourcePlaylistSong(
) => PlaylistSong(
playlistId: e.parentElement!.getAttribute('id')!,
songId: e.getAttribute('id')!,
position: index,

View File

@@ -41,7 +41,7 @@ class SubsonicSource implements MusicSource {
}
@override
Stream<SourceArtist> allArtists() async* {
Stream<Artist> allArtists() async* {
final getArtistsRes = await _pool.withResource(
() => client.get('getArtists'),
);
@@ -58,7 +58,7 @@ class SubsonicSource implements MusicSource {
}
@override
Stream<SourceAlbum> allAlbums() async* {
Stream<Album> allAlbums() async* {
final extras = await Future.wait([
_albumList(
'frequent',
@@ -89,7 +89,7 @@ class SubsonicSource implements MusicSource {
}
@override
Stream<SourcePlaylist> allPlaylists() async* {
Stream<Playlist> allPlaylists() async* {
final res = await _pool.withResource(() => client.get('getPlaylists'));
yield* Stream.fromIterable(
@@ -98,7 +98,7 @@ class SubsonicSource implements MusicSource {
}
@override
Stream<SourcePlaylistSong> allPlaylistSongs() async* {
Stream<PlaylistSong> allPlaylistSongs() async* {
final allPlaylists = await _pool.withResource(
() => client.get('getPlaylists'),
);
@@ -116,7 +116,7 @@ class SubsonicSource implements MusicSource {
}
@override
Stream<SourceSong> allSongs() async* {
Stream<Song> allSongs() async* {
if (await supportsFastSongSync) {
await for (var songs in _songSearch()) {
yield* Stream.fromIterable(songs.map(mapSong));