This commit is contained in:
53
lib/models/MediaItem.dart
Normal file
53
lib/models/MediaItem.dart
Normal file
@ -0,0 +1,53 @@
|
||||
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';
|
||||
String get mediaUrl => 'https://f0ck.me/b/$dest';
|
||||
String get coverUrl => 'https://f0ck.me/ca/$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'],
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user