This commit is contained in:
2024-11-15 21:34:26 +01:00
parent d66f5d430b
commit 31997709dd
4 changed files with 174 additions and 123 deletions
+48 -47
View File
@@ -1,6 +1,7 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -341,57 +342,57 @@ class TVShowDetailsScreen extends StatelessWidget {
}
Future<bool> updateTVShow() async {
// SharedPreferences prefs = await SharedPreferences.getInstance();
SharedPreferences prefs = await SharedPreferences.getInstance();
// String? dbProtocol = prefs.getString('dbProtocol');
// String? dbHost = prefs.getString('dbHost');
// String? dbPath = prefs.getString('dbPath');
String? dbProtocol = prefs.getString('dbProtocol');
String? dbHost = prefs.getString('dbHost');
String? dbPath = prefs.getString('dbPath');
// Uri url = Uri(
// scheme: dbProtocol,
// host: dbHost,
// path: dbPath,
// );
Uri url = Uri(
scheme: dbProtocol,
host: dbHost,
path: dbPath,
);
// var seasonState = jsonEncode(tvShowDetails.seasonStatus.map((e) => e.toJson()).toList());
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) {
// logger.e(e.toString());
// }
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) {
logger.e(e.toString());
}
return true;
}
+5
View File
@@ -13,6 +13,9 @@ import 'package:multimedia/data/tvshows.dart';
import 'package:multimedia/constants.dart';
import 'package:logger/logger.dart';
import 'package:multimedia/log_printer.dart';
String convertState(String state) {
List<String> stateList = state.split(',');
int maxEpisode = 0;
@@ -348,6 +351,8 @@ class TVShowDataSource extends DataGridSource {
buildDataGridRow();
}
Logger logger = getLogger();
void buildDataGridRow() {
_tvshowDataGridRows = tvshows
.map<DataGridRow>((e) => DataGridRow(cells: [