/// 图转视频任务项(V2 字段映射) class TaskItem { const TaskItem({ required this.templateName, required this.title, this.previewImageUrl, this.previewVideoUrl, this.imageCount = 0, this.taskType, this.needopt = false, this.ext, this.credits480p, this.credits720p, }); final String templateName; final String title; final String? previewImageUrl; final String? previewVideoUrl; final int imageCount; final String? taskType; final bool needopt; final String? ext; /// 480P 积分,来自 reverify.greaves final int? credits480p; /// 720P 积分,来自 preprocess.greaves final int? credits720p; @override String toString() => 'TaskItem(templateName: $templateName, title: $title, previewImageUrl: $previewImageUrl, ' 'previewVideoUrl: $previewVideoUrl, imageCount: $imageCount, taskType: $taskType, needopt: $needopt, credits480p: $credits480p, credits720p: $credits720p)'; factory TaskItem.fromJson(Map json) { final extract = json['extract'] as Map?; final preempt = json['preempt'] as Map?; final reverify = json['reverify'] as Map?; final preprocess = json['preprocess'] as Map?; final imgUrl = extract?['digitize'] as String?; final videoUrl = preempt?['digitize'] as String?; final greaves480 = reverify?['greaves']; final greaves720 = preprocess?['greaves']; final credits480p = greaves480 is int ? greaves480 : greaves480 is num ? greaves480.toInt() : null; final credits720p = greaves720 is int ? greaves720 : greaves720 is num ? greaves720.toInt() : null; return TaskItem( templateName: json['congregation'] as String? ?? '', title: json['glossary'] as String? ?? '', previewImageUrl: imgUrl, previewVideoUrl: videoUrl, imageCount: json['simplify'] as int? ?? 0, taskType: json['cipher'] as String?, needopt: json['allowance'] as bool? ?? false, ext: json['nexus'] as String? ?? '', credits480p: credits480p, credits720p: credits720p, ); } }