feature: Improved sync capability

This commit is contained in:
PartyDonut 2025-06-09 21:23:02 +02:00
parent f3e920ac79
commit c5c7f71b84
31 changed files with 500 additions and 344 deletions

View file

@ -26,7 +26,6 @@ class CredentialsModel {
Map<String, String> header(Ref ref) {
final application = ref.read(applicationInfoProvider);
final headers = {
'content-type': 'application/json',
'authorization':
'MediaBrowser Token="$token", Client="${application.name}", Device="${application.os}", DeviceId="$deviceId", Version="${application.version}"'
};

View file

@ -74,6 +74,9 @@ class SeasonModel extends ItemBaseModel with SeasonModelMappable {
episodes.firstWhereOrNull((element) => element.userData.played == false);
}
@override
bool get syncAble => true;
@override
ImagesData? get getPosters => images ?? parentImages;

View file

@ -30,6 +30,7 @@ class ISyncedItem {
String id;
bool syncing;
String? sortName;
@Index()
String? parentId;
String? path;
int? fileSize;

View file

@ -77,7 +77,16 @@ const ISyncedItemSchema = IsarGeneratedSchema(
type: IsarType.string,
),
],
indexes: [],
indexes: [
IsarIndexSchema(
name: 'parentId',
properties: [
"parentId",
],
unique: false,
hash: false,
),
],
),
converter: IsarObjectConverter<String, ISyncedItem>(
serialize: serializeISyncedItem,

View file

@ -47,6 +47,7 @@ class SyncedItem with _$SyncedItem {
}) = _SyncItem;
static String trickPlayPath = "TrickPlay";
static String chaptersPath = "Chapters";
List<Chapter> get chapters => fChapters.map((e) => e.copyWith(imageUrl: joinAll({"$path", e.imageUrl}))).toList();
@ -94,6 +95,7 @@ class SyncedItem with _$SyncedItem {
try {
await videoFile.delete();
await Directory(joinAll([directory.path, trickPlayPath])).delete(recursive: true);
await Directory(joinAll([directory.path, chaptersPath])).delete(recursive: true);
} catch (e) {
return false;
}