Skip to content

Commit

Permalink
[Release] v1.0.0 (33) (#107)
Browse files Browse the repository at this point in the history
* [API] Safe-guarded fetching quality profile (#93)
* [Build] Version 1.0.0, Changed how build number is presented (#94)
* [-rr] Check if content is already in catalogue when adding new content (#95)
* [Sonarr] Checks if series is already in Sonarr
* [Radarr] Checks if movie is already in Radarr when adding
* [Lidarr] Checks if artist is already in Lidarr
* [-rr] Ability to sort catalogue by size or alphabetical (#96)
* [Sonarr] Show size in catalogue page
* [-rr] Ability to sort catalogue by size or alphabetical
* [-rr] Sorting by size now starts sorting by largest -> smallest (#97)
* [Settings] Made the 'Save' button more obvious (#98)
* [SAB/NZBGet] Refresh timer will now stop on a connection error
* [Settings] Successful connection test now also triggers save
* [SAB/NZBGet] Manually refreshing the queue would create multiple timers
* [SAB/NZBGet] Safe-guarded percentage value for linear bar
* [TestFlight] Build 22
* [Profiles] Ability to rename a profile (#103)
* [SAB/NZBGet] Ability to pause queue for `x` amount of time (#104)
* [SABnzbd] Ability to pause queue for x amount of time
* [NZBGet] Ability to pause queue for some time
* [NZBGet] Ability to filter successful history entries (#105)
* [Settings] Adjusted and added more tips in host prompts (#106)
* [TestFlight] Build 33
* [Website] Updated changelog and version
  • Loading branch information
JagandeepBrar committed Feb 1, 2020
1 parent 22a7bfb commit 44294c4
Show file tree
Hide file tree
Showing 32 changed files with 1,599 additions and 245 deletions.
23 changes: 23 additions & 0 deletions docs/changelog.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
[
{
"version": "v1.0.0 (33)",
"new": [
"[-rr] When adding new content, checks if content is already in your library",
"[-rr] Ability to sort catalogue by size of alphabetical",
"[Settings] Ability to rename a profile",
"[SAB/NZBGet] Ability to pause the queue for some amount of time",
"[NZBGet] Ability to filter out successful history entries"
],
"fixes": [
"[Radarr] Fetching quality profiles could fail",
"[SAB/NZBGet] Percentage calculation could fail causing a grey screen",
"[SAB/NZBGet] Connection error now cancels timer until manual refresh (cleaner logs)"
],
"tweaks": [
"[Build] Adjusted how build number is presented",
"[Sonarr] Now shows size on disk on catalogue page",
"[Lidarr] Now shows size on disk on catalogue page",
"[Settings] Successful connection test now also triggers save",
"[Settings] Save button is now more obvious/clear",
"[Settings] Adjusted and added more tips when adding hosts"
]
},
{
"version": "v0.4.1+1",
"new": [
Expand Down
8 changes: 4 additions & 4 deletions docs/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"major": 0,
"minor": 4,
"revision": 1,
"code": 1
"major": 1,
"minor": 0,
"revision": 0,
"code": 33
}
32 changes: 32 additions & 0 deletions lib/configuration/profiles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ class Profiles {
profileList = profiles;
}

static Future<bool> profileExists(String name) async {
final prefs = await SharedPreferences.getInstance();
profileList = prefs.getStringList('profiles');
if(profileList.contains(name)) return true;
return false;
}

static Future<void> createProfile(String name) async {
final prefs = await SharedPreferences.getInstance();
profileList = prefs.getStringList('profiles');
Expand All @@ -37,6 +44,31 @@ class Profiles {
prefs.remove('${name}_nzbget');
}

static Future<void> renameProfile(String oldName, String newName) async {
final prefs = await SharedPreferences.getInstance();
//Set profile list, enabled_profile
profileList.add(newName);
prefs.setStringList('profiles', profileList);
if(enabledProfile == oldName) {
enabledProfile = newName;
prefs.setString('enabled_profile', enabledProfile);
}
//Set Automation
List<String> _sonarr = prefs.getStringList('${oldName}_sonarr');
List<String> _radarr = prefs.getStringList('${oldName}_radarr');
List<String> _lidarr = prefs.getStringList('${oldName}_lidarr');
prefs.setStringList('${newName}_sonarr', _sonarr);
prefs.setStringList('${newName}_radarr', _radarr);
prefs.setStringList('${newName}_lidarr', _lidarr);
//Set Clients
List<String> _nzbget = prefs.getStringList('${oldName}_nzbget');
List<String> _sabnzbd = prefs.getStringList('${oldName}_sabnzbd');
prefs.setStringList('${newName}_nzbget', _nzbget);
prefs.setStringList('${newName}_sabnzbd', _sabnzbd);
//Finally delete the old profile
await deleteProfile(oldName);
}

static Future<void> setProfile(String name) async {
final prefs = await SharedPreferences.getInstance();
prefs.setString('enabled_profile', name);
Expand Down
32 changes: 32 additions & 0 deletions lib/logic/automation/lidarr/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class LidarrAPI {
entry['genres'] ?? [],
entry['links'] ?? [],
entry['albumFolder'] ?? false,
entry['foreignArtistId'] ?? '',
entry['statistics'] != null ? entry['statistics']['sizeOnDisk'] ?? 0 : 0,
));
}
return entries;
Expand All @@ -106,6 +108,34 @@ class LidarrAPI {
return null;
}

static Future<List<String>> getAllArtistIDs() async {
List<dynamic> values = Values.lidarrValues;
if(values[0] == false) {
return null;
}
try {
String uri = '${values[1]}/api/v1/artist?apikey=${values[2]}';
http.Response response = await http.get(
Uri.encodeFull(uri),
);
if(response.statusCode == 200) {
List<String> _entries = [];
List body = json.decode(response.body);
for(var entry in body) {
_entries.add(entry['foreignArtistId'] ?? '');
}
return _entries;
} else {
logError('getAllArtistIDs', '<GET> HTTP Status Code (${response.statusCode})', null);
}
} catch (e) {
logError('getAllArtistIDs', 'Failed to fetch artist IDs', e);
return null;
}
logWarning('getAllArtistIDs', 'Failed to fetch artist IDs');
return null;
}

static Future<bool> refreshArtist(int artistID) async {
List<dynamic> values = Values.lidarrValues;
if(values[0] == false) {
Expand Down Expand Up @@ -169,6 +199,8 @@ class LidarrAPI {
body['genres'] ?? [],
body['links'] ?? [],
body['albumFolder'] ?? false,
body['foreignArtistId'] ?? '',
body['statistics'] != null ? body['statistics']['sizeOnDisk'] ?? 0 : 0,
);
} else {
logError('getArtist', '<GET> HTTP Status Code (${response.statusCode})', null);
Expand Down
7 changes: 6 additions & 1 deletion lib/logic/automation/lidarr/entry/catalogue.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:lunasea/configuration/values.dart';
import 'package:lunasea/system/functions.dart';

class LidarrCatalogueEntry {
String title;
Expand All @@ -15,6 +16,8 @@ class LidarrCatalogueEntry {
Map statistics;
List genres;
List links;
String foreignArtistID;
int sizeOnDisk;

LidarrCatalogueEntry(
this.title,
Expand All @@ -31,6 +34,8 @@ class LidarrCatalogueEntry {
this.genres,
this.links,
this.albumFolders,
this.foreignArtistID,
this.sizeOnDisk,
);

String get genre {
Expand All @@ -41,7 +46,7 @@ class LidarrCatalogueEntry {
}

String get subtitle {
return '$albums\n$tracks';
return '$albums\t\t$tracks\n${Functions.bytesToReadable(sizeOnDisk)}';
}

String get tracks {
Expand Down
45 changes: 38 additions & 7 deletions lib/logic/automation/radarr/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ class RadarrAPI {
List<RadarrCatalogueEntry> entries = [];
List body = json.decode(response.body);
for(var entry in body) {
var _quality = entry['qualityProfileId'] != null ? _qualities[entry['qualityProfileId']] : null;
entries.add(
RadarrCatalogueEntry(
entry['title'] ?? 'Unknown Title',
Expand All @@ -325,11 +326,11 @@ class RadarrAPI {
entry['downloaded'] ?? false,
entry['sizeOnDisk'] ?? 0,
entry['runtime'] ?? 0,
entry['profileId'] != null ? _qualities[entry['profileId']].name : '',
_quality != null ? _quality.name : '',
entry['downloaded'] ? entry['movieFile'] : null,
entry['overview'] ?? 'No summary is available',
entry['path'] ?? 'Unknown Path',
entry['profileId'] ?? -1,
entry['qualityProfileId'] ?? -1,
entry['minimumAvailability'] ?? '',
entry['youTubeTrailerId'] ?? '',
entry['imdbId'] ?? '',
Expand All @@ -351,6 +352,34 @@ class RadarrAPI {
return null;
}

static Future<List<int>> getAllMovieIDs() async {
List<dynamic> values = Values.radarrValues;
if(values[0] == false) {
return null;
}
try {
String uri = '${values[1]}/api/movie?apikey=${values[2]}';
http.Response response = await http.get(
Uri.encodeFull(uri),
);
if(response.statusCode == 200) {
List<int> _entries = [];
List body = json.decode(response.body);
for(var entry in body) {
_entries.add(entry['tmdbId'] ?? 0);
}
return _entries;
} else {
logError('getAllMovieIDs', '<GET> HTTP Status Code (${response.statusCode})', null);
}
} catch (e) {
logError('getAllMovieIDs', 'Failed to fetch all movie IDs', e);
return null;
}
logWarning('getAllMovieIDs', 'Failed to fetch all movie IDs');
return null;
}

static Future<RadarrCatalogueEntry> getMovie(int id) async {
List<dynamic> values = Values.radarrValues;
if(values[0] == false) {
Expand All @@ -365,6 +394,7 @@ class RadarrAPI {
);
if(response.statusCode == 200) {
Map body = json.decode(response.body);
var _quality = body['qualityProfileId'] != null ? _qualities[body['qualityProfileId']] : null;
return RadarrCatalogueEntry(
body['title'] ?? 'Unknown Title',
body['sortTitle'] ?? 'Unknown Title',
Expand All @@ -378,11 +408,11 @@ class RadarrAPI {
body['downloaded'] ?? false,
body['sizeOnDisk'] ?? 0,
body['runtime'] ?? 0,
body['profileId'] != null ? _qualities[body['profileId']].name : '',
_quality != null ? _quality.name : '',
body['downloaded'] ? body['movieFile'] : null,
body['overview'] ?? 'No summary is available',
body['path'] ?? 'Unknown Path',
body['profileId'] ?? -1,
body['qualityProfileId'] ?? -1,
body['minimumAvailability'] ?? '',
body['youTubeTrailerId'] ?? '',
body['imdbId'] ?? '',
Expand Down Expand Up @@ -446,6 +476,7 @@ class RadarrAPI {
List body = json.decode(response.body);
for(var entry in body) {
if(!entry['downloaded'] && entry['monitored']) {
var _quality = entry['qualityProfileId'] != null ? _qualities[entry['qualityProfileId']] : null;
if(entry['status'] == 'released') {
_availableEntries.add(
RadarrMissingEntry(
Expand All @@ -455,7 +486,7 @@ class RadarrAPI {
entry['studio'] ?? 'Unknown Studio',
entry['physicalRelease'] ?? '',
entry['inCinemas'] ?? '',
entry['profileId'] != null ? _qualities[entry['profileId']].name : '',
_quality != null ? _quality.name : '',
entry['year'] ?? 0,
entry['runtime'] ?? 0,
entry['status'] ?? 'Unknown Status',
Expand All @@ -471,7 +502,7 @@ class RadarrAPI {
entry['studio'] ?? 'Unknown Studio',
entry['physicalRelease'] ?? '',
entry['inCinemas'] ?? '',
entry['profileId'] != null ? _qualities[entry['profileId']].name : '',
_quality != null ? _quality.name : '',
entry['year'] ?? 0,
entry['runtime'] ?? 0,
entry['status'] ?? 'Unknown Status',
Expand All @@ -487,7 +518,7 @@ class RadarrAPI {
entry['studio'] ?? 'Unknown Studio',
entry['physicalRelease'] ?? '',
entry['inCinemas'] ?? '',
entry['profileId'] != null ? _qualities[entry['profileId']].name : '',
_quality != null ? _quality.name : '',
entry['year'] ?? 0,
entry['runtime'] ?? 0,
entry['status'] ?? 'Unknown Status',
Expand Down
32 changes: 31 additions & 1 deletion lib/logic/automation/sonarr/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ class SonarrAPI {
body['imdbId'] ?? '',
body['runtime'] ?? 0,
body['profileId'] != null ? _qualities[body['qualityProfileId']].name : '',
body['sizeOnDisk'] ?? 0,
);
return entry;
} else {
Expand All @@ -309,7 +310,7 @@ class SonarrAPI {
String uri = '${values[1]}/api/series?apikey=${values[2]}';
http.Response response = await http.get(
Uri.encodeFull(uri),
);
);
if(response.statusCode == 200) {
List body = json.decode(response.body);
for(var entry in body) {
Expand Down Expand Up @@ -339,6 +340,7 @@ class SonarrAPI {
entry['imdbId'] ?? '',
entry['runtime'] ?? 0,
entry['profileId'] != null ? _qualities[entry['qualityProfileId']].name : '',
entry['sizeOnDisk'] ?? 0,
),
);
}
Expand All @@ -355,6 +357,34 @@ class SonarrAPI {
return null;
}

static Future<List<int>> getAllSeriesIDs() async {
List<dynamic> values = Values.sonarrValues;
if(values[0] == false) {
return null;
}
try {
List<int> _entries = [];
String uri = '${values[1]}/api/series?apikey=${values[2]}';
http.Response response = await http.get(
Uri.encodeFull(uri),
);
if(response.statusCode == 200) {
List body = json.decode(response.body);
for(var entry in body) {
_entries.add(entry['tvdbId'] ?? 0);
}
return _entries;
} else {
logError('getAllSeriesIDs', '<GET> HTTP Status Code (${response.statusCode})', null);
}
} catch (e) {
logError('getAllSeriesIDs', 'Failed to fetch all series IDs', e);
return null;
}
logWarning('getAllSeriesIDs', 'Failed to fetch all series IDs');
return null;
}

static Future<Map> getUpcoming({int duration = 7}) async {
List<dynamic> values = Values.sonarrValues;
if(values[0] == false) {
Expand Down
Loading

0 comments on commit 44294c4

Please sign in to comment.