update movie, tvshow
This commit is contained in:
@@ -337,6 +337,58 @@ class TVShowDetailsScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
Future<bool> updateTVShow() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
String? dbProtocol = prefs.getString('dbProtocol');
|
||||
String? dbHost = prefs.getString('dbHost');
|
||||
String? dbPath = prefs.getString('dbPath');
|
||||
|
||||
Uri url = Uri(
|
||||
scheme: dbProtocol,
|
||||
host: dbHost,
|
||||
path: dbPath,
|
||||
);
|
||||
|
||||
var seasonState = jsonEncode(tvShowDetails.seasonStatus.map((e) => e.toJson()).toList());
|
||||
|
||||
try {
|
||||
final r = await http.post(
|
||||
url,
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(
|
||||
<String, dynamic>{
|
||||
'module': 'tvshow',
|
||||
'function': 'update',
|
||||
'seriesID': tvShowDetails.seriesID.toString(),
|
||||
'seriesName': tvShowDetails.seriesName,
|
||||
'overview': tvShowDetails.overview,
|
||||
'firstAired':
|
||||
DateFormat('yyyy-MM-dd').format(tvShowDetails.firstAired),
|
||||
'resolution': tvShowDetails.resolution,
|
||||
'cliffhanger': tvShowDetails.cliffhanger.toString(),
|
||||
'status': tvShowDetails.status.toString(),
|
||||
'backdropPath': tvShowDetails.backdropPath,
|
||||
'seriesState': tvShowDetails.seriesState.toString(),
|
||||
'languages': tvShowDetails.languages,
|
||||
'networks': tvShowDetails.networks,
|
||||
'productionCompanies': tvShowDetails.productionCompanies,
|
||||
'voteAverage': tvShowDetails.voteAverage.toString(),
|
||||
'voteCount': tvShowDetails.voteCount.toString(),
|
||||
'cast': tvShowDetails.cast,
|
||||
'crew': tvShowDetails.crew,
|
||||
'genre': tvShowDetails.genre,
|
||||
'download': tvShowDetails.download,
|
||||
'localPath': tvShowDetails.localPath,
|
||||
'seasons': seasonState,
|
||||
},
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -351,8 +403,34 @@ class TVShowDetailsScreen extends StatelessWidget {
|
||||
void stateChanged(List<Season> seasonStatus) {
|
||||
tvShowDetails.seasonStatus = seasonStatus;
|
||||
|
||||
for (var s in tvShowDetails.seasonStatus) {
|
||||
print('Season: ${s.seasonNumber}, State: ${s.state}');
|
||||
bool hasInit = false;
|
||||
bool hasProg = false;
|
||||
bool hasDone = false;
|
||||
|
||||
for (var season in tvShowDetails.seasonStatus) {
|
||||
var episodeList = season.state.split(',');
|
||||
|
||||
for (var s in episodeList) {
|
||||
var states = s.split('|');
|
||||
|
||||
if (states[1] == '1') {
|
||||
hasInit = true;
|
||||
}
|
||||
if (states[1] == '2') {
|
||||
hasProg = true;
|
||||
}
|
||||
if (states[1] == '3') {
|
||||
hasDone = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasProg) {
|
||||
tvShowDetails.seriesState = 2;
|
||||
} else if (hasInit) {
|
||||
tvShowDetails.seriesState = 1;
|
||||
} else if (hasDone) {
|
||||
tvShowDetails.seriesState = 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ class TVShowDetailsSeasons extends StatefulWidget {
|
||||
final Function(List<Season>) stateChanged;
|
||||
|
||||
void stateChanged1(int seasonNumber, String state) {
|
||||
print('start stateChanged1 in seasons ...');
|
||||
for (int seasonID = 0; seasonID < seasonStatus.length; seasonID++) {
|
||||
if (seasonStatus[seasonID].seasonNumber == seasonNumber) {
|
||||
seasonStatus[seasonID].state = state;
|
||||
|
||||
Reference in New Issue
Block a user