100 lines
2.4 KiB
Dart
100 lines
2.4 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:notube/constants.dart';
|
|
|
|
@immutable
|
|
class Video extends Equatable {
|
|
Video({
|
|
this.id = '',
|
|
this.url = '',
|
|
this.extractor = '',
|
|
this.isParsed = false,
|
|
this.status = 'pending',
|
|
this.format = Format.mp4,
|
|
this.title = '',
|
|
this.thumbnail = '',
|
|
this.description = '',
|
|
this.duration = '0:00',
|
|
this.uploader = '',
|
|
this.uploadDate = '',
|
|
this.filename = '',
|
|
});
|
|
|
|
final String id;
|
|
final String url;
|
|
final String extractor;
|
|
final bool isParsed;
|
|
final String status;
|
|
final Format format;
|
|
final String title;
|
|
final String thumbnail;
|
|
final String description;
|
|
final String duration;
|
|
final String uploader;
|
|
final String uploadDate;
|
|
final String filename;
|
|
|
|
factory Video.fromJson(Map<String, dynamic> json) {
|
|
return Video(
|
|
id: json['id'],
|
|
isParsed: true,
|
|
url: json['url'] ?? json['original_url'],
|
|
extractor: json['extractor_key'] ?? '',
|
|
title: json['title'],
|
|
thumbnail: json['thumbnails']![0]['url'],
|
|
description: json['description'] ?? '',
|
|
duration: json['duration_string'] ?? '0:00',
|
|
uploader: json['uploader'] ?? '',
|
|
uploadDate: json['upload_date'] ?? '');
|
|
}
|
|
|
|
//set Status
|
|
Video copyWith({
|
|
String? id,
|
|
String? url,
|
|
String? extractor,
|
|
bool? isParsed,
|
|
String? status,
|
|
Format? format,
|
|
String? title,
|
|
String? thumbnail,
|
|
String? description,
|
|
String? duration,
|
|
String? uploader,
|
|
String? uploadDate,
|
|
String? filename,
|
|
}) {
|
|
return Video(
|
|
id: id ?? this.id,
|
|
url: url ?? this.url,
|
|
extractor: extractor ?? this.extractor,
|
|
isParsed: isParsed ?? this.isParsed,
|
|
status: status ?? this.status,
|
|
format: format ?? this.format,
|
|
title: title ?? this.title,
|
|
thumbnail: thumbnail ?? this.thumbnail,
|
|
description: description ?? this.description,
|
|
duration: duration ?? this.duration,
|
|
uploader: uploader ?? this.uploader,
|
|
uploadDate: uploadDate ?? this.uploadDate,
|
|
filename: filename ?? this.filename,
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<Object> get props => [
|
|
id,
|
|
title,
|
|
thumbnail,
|
|
description,
|
|
duration,
|
|
uploader,
|
|
uploadDate,
|
|
format,
|
|
status,
|
|
url,
|
|
isParsed,
|
|
filename,
|
|
];
|
|
}
|