|
|
|
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|
|
|
|
import 'package:accordion/accordion.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:logger/logger.dart';
|
|
|
|
|
import 'package:multimedia/data/movies.dart';
|
|
|
|
|
@ -399,10 +400,74 @@ class _AddMovieScreenState extends State<AddMovieScreen> {
|
|
|
|
|
appendToResponse: 'credits,external_ids',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
logger.i(response);
|
|
|
|
|
// logger.i(response);
|
|
|
|
|
Movie movie = Movie.fromJsonDynamic(response);
|
|
|
|
|
writeToDB(movie);
|
|
|
|
|
// logger.i('${movie.movieTitle} (${movie.movieID})');
|
|
|
|
|
|
|
|
|
|
logger.i('${movie.movieTitle} (${movie.movieID})');
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<bool> writeToDB(Movie movie) 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,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
final r = await http.post(
|
|
|
|
|
url,
|
|
|
|
|
headers: <String, String>{
|
|
|
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
|
|
|
},
|
|
|
|
|
body: jsonEncode(
|
|
|
|
|
<String, String>{
|
|
|
|
|
'module': 'movie',
|
|
|
|
|
'function': 'add',
|
|
|
|
|
'movieID': movie.movieID.toString(),
|
|
|
|
|
'movieTitle': movie.movieTitle,
|
|
|
|
|
'originalTitle': movie.originalTitle,
|
|
|
|
|
'overview': movie.overview,
|
|
|
|
|
'releaseDate':
|
|
|
|
|
DateFormat('yyyy-MM-dd').format(movie.releaseDate),
|
|
|
|
|
'resolution': movie.resolution,
|
|
|
|
|
'state': movie.state.toString(),
|
|
|
|
|
'backdropPath': movie.backdropPath,
|
|
|
|
|
'languages': movie.languages,
|
|
|
|
|
'productionCountries': movie.productionCountries,
|
|
|
|
|
'productionCompanies': movie.productionCompanies,
|
|
|
|
|
'voteAverage': movie.voteAverage.toString(),
|
|
|
|
|
'voteCount': movie.voteCount.toString(),
|
|
|
|
|
'cast': movie.cast,
|
|
|
|
|
'crew': movie.crew,
|
|
|
|
|
'genre': movie.genre,
|
|
|
|
|
'localPath': movie.localPath,
|
|
|
|
|
'posterPath': movie.posterPath,
|
|
|
|
|
'imdbid': movie.imdbID,
|
|
|
|
|
'originalLanguage': movie.originalLanguage,
|
|
|
|
|
'popularity': movie.popularity.toString(),
|
|
|
|
|
'adult': movie.adult.toString(),
|
|
|
|
|
'belongsToCollection': movie.belongsToCollection,
|
|
|
|
|
'budget': movie.budget.toString(),
|
|
|
|
|
'homepage': movie.homepage,
|
|
|
|
|
'revenue': movie.revenue.toString(),
|
|
|
|
|
'runtime': movie.runtime.toString(),
|
|
|
|
|
'status': '',
|
|
|
|
|
'tagline': movie.tagline,
|
|
|
|
|
'video': ''
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
logger.e(e.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|