class MediaItem { final int id; final String mime; final int size; final int stamp; final String dest; final int mode; final List? tags; final List? favorites; final String? username; final String? userchannel; final String? usernetwork; MediaItem({ required this.id, required this.mime, required this.size, required this.stamp, required this.dest, required this.mode, this.tags = const [], this.favorites = const [], this.username, this.userchannel, this.usernetwork, }); 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'; String get postUrl => 'https://f0ck.me/$id'; MediaItem copyWith({ int? id, String? mime, int? size, int? stamp, String? dest, int? mode, List? tags, List? favorites, String? username, String? userchannel, String? usernetwork, }) { return MediaItem( id: id ?? this.id, mime: mime ?? this.mime, size: size ?? this.size, stamp: stamp ?? this.stamp, dest: dest ?? this.dest, mode: mode ?? this.mode, tags: tags ?? this.tags, favorites: favorites ?? this.favorites, username: username ?? this.username, userchannel: userchannel ?? this.userchannel, usernetwork: usernetwork ?? this.usernetwork, ); } factory MediaItem.fromJson(Map 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?) ?.map((e) => Tag.fromJson(e)) .toList() ?? [], favorites: (json['favorites'] as List?) ?.map((e) => Favorite.fromJson(e)) .toList() ?? [], username: json['username'], userchannel: json['userchannel'], usernetwork: json['usernetwork'], ); } } 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 json) { return Tag( id: json['id'], tag: json['tag'], normalized: json['normalized'], ); } } class Favorite { final int userId; final String username; final int avatar; Favorite({ required this.userId, required this.username, required this.avatar, }); factory Favorite.fromJson(Map json) { return Favorite( userId: json['userId'], username: json['username'], avatar: json['avatar'], ); } String get avatarUrl => 'https://f0ck.me/t/$avatar.webp'; }