mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 13:38:13 -08:00
61 lines
1.8 KiB
Dart
61 lines
1.8 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:isar/isar.dart';
|
|
|
|
import 'package:fladder/models/syncing/sync_item.dart';
|
|
|
|
part 'i_synced_item.g.dart';
|
|
|
|
@collection
|
|
class ISyncedItem {
|
|
String? userId;
|
|
String id;
|
|
bool syncing;
|
|
String? sortName;
|
|
@Index()
|
|
String? parentId;
|
|
String? path;
|
|
int? fileSize;
|
|
String? videoFileName;
|
|
String? trickPlayModel;
|
|
String? mediaSegments;
|
|
String? images;
|
|
List<String>? chapters;
|
|
List<String>? subtitles;
|
|
String? userData;
|
|
ISyncedItem({
|
|
this.userId,
|
|
required this.id,
|
|
required this.syncing,
|
|
this.sortName,
|
|
this.parentId,
|
|
this.path,
|
|
this.fileSize,
|
|
this.videoFileName,
|
|
this.trickPlayModel,
|
|
this.mediaSegments,
|
|
this.images,
|
|
this.chapters,
|
|
this.subtitles,
|
|
this.userData,
|
|
});
|
|
|
|
factory ISyncedItem.fromSynced(SyncedItem syncedItem, String? path) {
|
|
return ISyncedItem(
|
|
id: syncedItem.id,
|
|
parentId: syncedItem.parentId,
|
|
syncing: syncedItem.syncing,
|
|
userId: syncedItem.userId,
|
|
path: syncedItem.path?.replaceAll(path ?? "", '').substring(1),
|
|
fileSize: syncedItem.fileSize,
|
|
sortName: syncedItem.sortName,
|
|
videoFileName: syncedItem.videoFileName,
|
|
trickPlayModel: syncedItem.fTrickPlayModel != null ? jsonEncode(syncedItem.fTrickPlayModel?.toJson()) : null,
|
|
mediaSegments: syncedItem.mediaSegments != null ? jsonEncode(syncedItem.mediaSegments?.toJson()) : null,
|
|
images: syncedItem.fImages != null ? jsonEncode(syncedItem.fImages?.toJson()) : null,
|
|
chapters: syncedItem.fChapters.map((e) => jsonEncode(e.toJson())).toList(),
|
|
subtitles: syncedItem.subtitles.map((e) => jsonEncode(e.toJson())).toList(),
|
|
userData: syncedItem.userData != null ? jsonEncode(syncedItem.userData?.toJson()) : null,
|
|
);
|
|
}
|
|
}
|