170 lines
4.2 KiB
Dart
170 lines
4.2 KiB
Dart
class XtreamCategory {
|
|
final String id;
|
|
final String name;
|
|
|
|
XtreamCategory({required this.id, required this.name});
|
|
|
|
factory XtreamCategory.fromJson(Map<String, dynamic> json) {
|
|
return XtreamCategory(
|
|
id: json['category_id']?.toString() ?? '',
|
|
name: json['category_name']?.toString() ?? '',
|
|
);
|
|
}
|
|
}
|
|
|
|
int _parseInt(dynamic value) {
|
|
if (value == null) return 0;
|
|
if (value is int) return value;
|
|
if (value is String) return int.tryParse(value) ?? 0;
|
|
return 0;
|
|
}
|
|
|
|
class XtreamStream {
|
|
final int streamId;
|
|
final String name;
|
|
final String? streamIcon;
|
|
final String? plot;
|
|
final String? rating;
|
|
final String? containerExtension;
|
|
final String? categoryId;
|
|
String? url;
|
|
|
|
XtreamStream({
|
|
required this.streamId,
|
|
required this.name,
|
|
this.streamIcon,
|
|
this.plot,
|
|
this.rating,
|
|
this.containerExtension,
|
|
this.categoryId,
|
|
this.url,
|
|
});
|
|
|
|
factory XtreamStream.fromJson(Map<String, dynamic> json) {
|
|
return XtreamStream(
|
|
streamId: _parseInt(json['stream_id']),
|
|
name: json['name']?.toString() ?? '',
|
|
streamIcon: json['stream_icon']?.toString(),
|
|
plot: json['plot']?.toString(),
|
|
rating: json['rating']?.toString(),
|
|
containerExtension: json['container_extension']?.toString(),
|
|
categoryId: json['category_id']?.toString(),
|
|
url: null,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'stream_id': streamId,
|
|
'name': name,
|
|
'stream_icon': streamIcon,
|
|
'plot': plot,
|
|
'rating': rating,
|
|
'container_extension': containerExtension,
|
|
'category_id': categoryId,
|
|
'url': url,
|
|
};
|
|
}
|
|
}
|
|
|
|
class XtreamSeries {
|
|
final int seriesId;
|
|
final String name;
|
|
final String? cover;
|
|
final String? plot;
|
|
final String? rating;
|
|
final List<XtreamSeason> seasons;
|
|
|
|
XtreamSeries({
|
|
required this.seriesId,
|
|
required this.name,
|
|
this.cover,
|
|
this.plot,
|
|
this.rating,
|
|
this.seasons = const [],
|
|
});
|
|
|
|
factory XtreamSeries.fromJson(Map<String, dynamic> json) {
|
|
return XtreamSeries(
|
|
seriesId: _parseInt(json['series_id']),
|
|
name: json['name']?.toString() ?? '',
|
|
cover: json['cover']?.toString(),
|
|
plot: json['plot']?.toString(),
|
|
rating: json['rating']?.toString(),
|
|
seasons: [],
|
|
);
|
|
}
|
|
}
|
|
|
|
class XtreamSeason {
|
|
final int seasonNumber;
|
|
final List<XtreamEpisode> episodes;
|
|
|
|
XtreamSeason({required this.seasonNumber, this.episodes = const []});
|
|
}
|
|
|
|
class XtreamEpisode {
|
|
final int episodeId;
|
|
final int seasonNumber;
|
|
final int episodeNumber;
|
|
final String title;
|
|
final String? info;
|
|
final String? containerExtension;
|
|
String? url;
|
|
|
|
XtreamEpisode({
|
|
required this.episodeId,
|
|
required this.seasonNumber,
|
|
required this.episodeNumber,
|
|
required this.title,
|
|
this.info,
|
|
this.containerExtension,
|
|
this.url,
|
|
});
|
|
|
|
factory XtreamEpisode.fromJson(Map<String, dynamic> json) {
|
|
return XtreamEpisode(
|
|
episodeId: _parseInt(json['id']),
|
|
seasonNumber: _parseInt(json['season']),
|
|
episodeNumber: _parseInt(json['episode_num']),
|
|
title: json['title']?.toString() ?? '',
|
|
info: json['info']?.toString(),
|
|
containerExtension: json['container_extension']?.toString(),
|
|
url: null,
|
|
);
|
|
}
|
|
}
|
|
|
|
class XtreamUserInfo {
|
|
final String username;
|
|
final String password;
|
|
final int maxConnections;
|
|
final int activeCons;
|
|
final bool isTrial;
|
|
final int? expDate;
|
|
final String status;
|
|
|
|
XtreamUserInfo({
|
|
required this.username,
|
|
required this.password,
|
|
required this.maxConnections,
|
|
required this.activeCons,
|
|
required this.isTrial,
|
|
this.expDate,
|
|
required this.status,
|
|
});
|
|
|
|
factory XtreamUserInfo.fromJson(Map<String, dynamic> json) {
|
|
final userInfo = json['user_info'] ?? json;
|
|
return XtreamUserInfo(
|
|
username: userInfo['username']?.toString() ?? '',
|
|
password: userInfo['password']?.toString() ?? '',
|
|
maxConnections: _parseInt(userInfo['max_connections']),
|
|
activeCons: _parseInt(userInfo['active_cons']),
|
|
isTrial: userInfo['is_trial']?.toString() == '1',
|
|
expDate: userInfo['exp_date'] != null ? _parseInt(userInfo['exp_date']) : null,
|
|
status: userInfo['status']?.toString() ?? '',
|
|
);
|
|
}
|
|
}
|