52 lines
1.1 KiB
Dart
52 lines
1.1 KiB
Dart
class MediaItem {
|
|
final int id;
|
|
final String mime;
|
|
final int size;
|
|
final int stamp;
|
|
final String dest;
|
|
final int mode;
|
|
final List<Tag> tags;
|
|
|
|
MediaItem({
|
|
required this.id,
|
|
required this.mime,
|
|
required this.size,
|
|
required this.stamp,
|
|
required this.dest,
|
|
required this.mode,
|
|
required this.tags,
|
|
});
|
|
|
|
factory MediaItem.fromJson(Map<String, dynamic> json) {
|
|
return MediaItem(
|
|
id: json['id'],
|
|
mime: json['mime'],
|
|
size: json['size'],
|
|
stamp: json['stamp'],
|
|
dest: json['dest'],
|
|
mode: json['mode'],
|
|
tags: (json['tags'] as List<dynamic>)
|
|
.map((tagJson) => Tag.fromJson(tagJson))
|
|
.toList(),
|
|
);
|
|
}
|
|
|
|
String get thumbnailUrl => 'https://f0ck.me/t/$id.webp';
|
|
}
|
|
|
|
class Tag {
|
|
final int id;
|
|
final String tag;
|
|
final String normalized;
|
|
|
|
Tag({required this.id, required this.tag, required this.normalized});
|
|
|
|
factory Tag.fromJson(Map<String, dynamic> json) {
|
|
return Tag(
|
|
id: json['id'],
|
|
tag: json['tag'],
|
|
normalized: json['normalized'],
|
|
);
|
|
}
|
|
}
|