mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-31 04:32:32 +00:00
NEW - [Networking] Strict TLS/SSL validation is now disabled globally - [Routing] Hold the AppBar back button to pop back to the home page of the module - [Settings/Sonarr] Toggle to enable Sonarr v3 features - [Sonarr] Complete rewrite of Sonarr - [Sonarr] State is now held across module switches - [Sonarr/Overview] View tags applied to series - [Sonarr/Catalogue] (v3 only) Ability to set and update language profile - [Sonarr/Catalogue] Ability to view all, only monitored, or only unmonitored series - [Sonarr/Releases] (v3 only) Ability to interactively search for season packs - [Sonarr/Releases] Ability to view all, only approved, or only rejected releases TWEAKS - [Settings] Removed all toggles for strict TLS - [Sonarr] Many tweaks to Sonarr's design - [Sonarr/Add] (v3 only) Tapping an already-added series will take you to the series page - [Sonarr/Add] Automatically navigate to newly added series - [Sonarr/Series] Toggling monitored state of series has now been moved to the edit prompt FIXES - [Images] Images will now load for invalid/self-signed certificates - [Tautulli/Activity] Fix grey screen for music activity - [TextField] Fix TextField actions (cut, copy, paste, etc.) not showing - [Timestamps] Fix 12:xx AM being shown as 00:xx AM - Additional small bug fixes
102 lines
3.9 KiB
Dart
102 lines
3.9 KiB
Dart
import 'dart:convert';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:lunasea/core.dart';
|
|
import 'package:lunasea/core/database.dart';
|
|
|
|
class Import {
|
|
Import._();
|
|
|
|
static void _setLunaSea(BuildContext context, Map data) {
|
|
LunaProfile.changeProfile(context, data['profile']);
|
|
}
|
|
|
|
static void _setProfiles(List data) {
|
|
Box<dynamic> _box = Database.profilesBox;
|
|
for(Map profile in data) {
|
|
_box.put(profile['key'], ProfileHiveObject(
|
|
//Sonarr
|
|
sonarrEnabled: profile['sonarrEnabled'] ?? false,
|
|
sonarrHost: profile['sonarrHost'] ?? '',
|
|
sonarrKey: profile['sonarrKey'] ?? '',
|
|
sonarrVersion3: profile['sonarrVersion3'] ?? false,
|
|
sonarrHeaders: profile['sonarrHeaders'] ?? {},
|
|
//Radarr
|
|
radarrEnabled: profile['radarrEnabled'] ?? false,
|
|
radarrHost: profile['radarrHost'] ?? '',
|
|
radarrKey: profile['radarrKey'] ?? '',
|
|
radarrHeaders: profile['radarrHeaders'] ?? {},
|
|
//Lidarr
|
|
lidarrEnabled: profile['lidarrEnabled'] ?? false,
|
|
lidarrHost: profile['lidarrHost'] ?? '',
|
|
lidarrKey: profile['lidarrKey'] ?? '',
|
|
lidarrHeaders: profile['lidarrHeaders'] ?? {},
|
|
//SABnzbd
|
|
sabnzbdEnabled: profile['sabnzbdEnabled'] ?? false,
|
|
sabnzbdHost: profile['sabnzbdHost'] ?? '',
|
|
sabnzbdKey: profile['sabnzbdKey'] ?? '',
|
|
sabnzbdHeaders: profile['sabnzbdHeaders'] ?? {},
|
|
//NZBGet
|
|
nzbgetEnabled: profile['nzbgetEnabled'] ?? false,
|
|
nzbgetHost: profile['nzbgetHost'] ?? '',
|
|
nzbgetUser: profile['nzbgetUser'] ?? '',
|
|
nzbgetPass: profile['nzbgetPass'] ?? '',
|
|
nzbgetBasicAuth: profile['nzbgetBasicAuth'] ?? false,
|
|
nzbgetHeaders: profile['nzbgetHeaders'] ?? {},
|
|
//Wake on LAN
|
|
wakeOnLANEnabled: profile['wakeOnLANEnabled'] ?? false,
|
|
wakeOnLANBroadcastAddress: profile['wakeOnLANBroadcastAddress'] ?? '',
|
|
wakeOnLANMACAddress: profile['wakeOnLANMACAddress'] ?? '',
|
|
//Tautulli
|
|
tautulliEnabled: profile['tautulliEnabled'] ?? false,
|
|
tautulliHost: profile['tautulliHost'] ?? '',
|
|
tautulliKey: profile['tautulliKey'] ?? '',
|
|
tautulliHeaders: profile['tautulliHeaders'] ?? {},
|
|
//Ombi
|
|
ombiEnabled: profile['ombiEnabled'] ?? false,
|
|
ombiHost: profile['ombiHost'] ?? '',
|
|
ombiKey: profile['ombiKey'] ?? '',
|
|
ombiHeaders: profile['ombiHeaders'] ?? {},
|
|
));
|
|
}
|
|
}
|
|
|
|
static void _setIndexers(List data) {
|
|
Box<dynamic> _box = Database.indexersBox;
|
|
for(Map indexer in data) {
|
|
_box.add(IndexerHiveObject(
|
|
displayName: indexer['displayName'] ?? '',
|
|
host: indexer['host'] ?? '',
|
|
key: indexer['key'] ?? '',
|
|
headers: indexer['headers'] ?? {},
|
|
));
|
|
}
|
|
}
|
|
|
|
static bool _validate(Map config) {
|
|
if(
|
|
config['profiles'] != null &&
|
|
config['indexers'] != null &&
|
|
config['lunasea'] != null
|
|
) return true;
|
|
return false;
|
|
}
|
|
|
|
static void _clearBoxes() {
|
|
Database.clearIndexersBox();
|
|
Database.clearLunaSeaBox();
|
|
Database.clearProfilesBox();
|
|
}
|
|
|
|
static Future<bool> import(BuildContext context, String data) async {
|
|
Map _config = json.decode(data);
|
|
if(_validate(_config)) {
|
|
_clearBoxes();
|
|
_setProfiles(_config['profiles']);
|
|
_setIndexers(_config['indexers']);
|
|
_setLunaSea(context, _config['lunasea']);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|