-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sabnzbd): rewrite SABnzbd API interface
[skip ci]
- Loading branch information
1 parent
2adfe59
commit a1b736a
Showing
30 changed files
with
958 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:lunasea/api/sabnzbd/types/clear_history.dart'; | ||
import 'package:lunasea/vendor.dart'; | ||
|
||
extension SABnzbdClearHistoryExtension on SABnzbdClearHistory { | ||
String get readable { | ||
switch (this) { | ||
case SABnzbdClearHistory.ALL: | ||
return 'sabnzbd.All'.tr(); | ||
case SABnzbdClearHistory.COMPLETED: | ||
return 'sabnzbd.Completed'.tr(); | ||
case SABnzbdClearHistory.FAILED: | ||
return 'sabnzbd.Failed'.tr(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:lunasea/api/sabnzbd/types/on_complete_action.dart'; | ||
import 'package:lunasea/vendor.dart'; | ||
|
||
extension SABnzbdOnCompleteActionExtension on SABnzbdOnCompleteAction { | ||
String get readable { | ||
switch (this) { | ||
case SABnzbdOnCompleteAction.SHUTDOWN_PROGRAM: | ||
return 'sabnzbd.ShutdownSABnzbd'.tr(); | ||
case SABnzbdOnCompleteAction.SHUTDOWN_PC: | ||
return 'sabnzbd.ShutdownPC'.tr(); | ||
case SABnzbdOnCompleteAction.HIBERNATE_PC: | ||
return 'sabnzbd.HibernatePC'.tr(); | ||
case SABnzbdOnCompleteAction.STANDBY_PC: | ||
return 'sabnzbd.StandbyPC'.tr(); | ||
case SABnzbdOnCompleteAction.NONE: | ||
return 'sabnzbd.None'.tr(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:lunasea/api/sabnzbd/types/post_processing.dart'; | ||
import 'package:lunasea/vendor.dart'; | ||
|
||
extension SABnzbdPostProcessingExtension on SABnzbdPostProcessing { | ||
String get readable { | ||
switch (this) { | ||
case SABnzbdPostProcessing.DEFAULT: | ||
return 'sabnzbd.CategoryDefault'.tr(); | ||
case SABnzbdPostProcessing.NONE: | ||
return 'sabnzbd.None'.tr(); | ||
case SABnzbdPostProcessing.REPAIR: | ||
return 'sabnzbd.Repair'.tr(); | ||
case SABnzbdPostProcessing.REPAIR_UNPACK: | ||
return 'sabnzbd.RepairUnpack'.tr(); | ||
case SABnzbdPostProcessing.REPAIR_UNPACK_DELETE: | ||
return 'sabnzbd.RepairUnpackDelete'.tr(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:lunasea/api/sabnzbd/types/priority.dart'; | ||
import 'package:lunasea/vendor.dart'; | ||
|
||
extension SABnzbdPriorityExtension on SABnzbdPriority { | ||
String get readable { | ||
switch (this) { | ||
case SABnzbdPriority.FORCE: | ||
return 'sabnzbd.Force'.tr(); | ||
case SABnzbdPriority.HIGH: | ||
return 'sabnzbd.High'.tr(); | ||
case SABnzbdPriority.NORMAL: | ||
return 'sabnzbd.Normal'.tr(); | ||
case SABnzbdPriority.LOW: | ||
return 'sabnzbd.Low'.tr(); | ||
case SABnzbdPriority.STOP: | ||
return 'sabnzbd.Stop'.tr(); | ||
case SABnzbdPriority.DEFAULT: | ||
return 'sabnzbd.CategoryDefault'.tr(); | ||
case SABnzbdPriority.PAUSED: | ||
return 'sabnzbd.Paused'.tr(); | ||
case SABnzbdPriority.DUPLICATE: | ||
return 'sabnzbd.Duplicate'.tr(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:lunasea/api/sabnzbd/types/sort_category.dart'; | ||
import 'package:lunasea/vendor.dart'; | ||
|
||
extension SABnzbdSortCategoryExtension on SABnzbdSortCategory { | ||
String get readable { | ||
switch (this) { | ||
case SABnzbdSortCategory.AGE: | ||
return 'sabnzbd.Age'.tr(); | ||
case SABnzbdSortCategory.NAME: | ||
return 'sabnzbd.Name'.tr(); | ||
case SABnzbdSortCategory.SIZE: | ||
return 'sabnzbd.Size'.tr(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:lunasea/api/sabnzbd/types/sort_direction.dart'; | ||
import 'package:lunasea/vendor.dart'; | ||
|
||
extension SABnzbdSortDirectionExtension on SABnzbdSortDirection { | ||
String get readable { | ||
switch (this) { | ||
case SABnzbdSortDirection.ASCENDING: | ||
return 'sabnzbd.Ascending'.tr(); | ||
case SABnzbdSortDirection.DESCENDING: | ||
return 'sabnzbd.Descending'.tr(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export 'models/action_result.dart'; | ||
export 'models/categories.dart'; | ||
export 'models/history.dart'; | ||
export 'models/queue.dart'; | ||
export 'models/server.dart'; | ||
export 'models/server_stats.dart'; | ||
export 'models/stage_log.dart'; | ||
export 'models/status.dart'; | ||
export 'models/version.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'dart:convert'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'action_result.g.dart'; | ||
|
||
@JsonSerializable(explicitToJson: true, includeIfNull: false) | ||
class SABnzbdActionResult { | ||
bool status; | ||
|
||
SABnzbdActionResult({ | ||
required this.status, | ||
}); | ||
|
||
@override | ||
String toString() => json.encode(this.toJson()); | ||
|
||
factory SABnzbdActionResult.fromJson(Map<String, dynamic> json) { | ||
return _$SABnzbdActionResultFromJson(json); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return _$SABnzbdActionResultToJson(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'dart:convert'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'categories.g.dart'; | ||
|
||
@JsonSerializable(explicitToJson: true, includeIfNull: false) | ||
class SABnzbdCategories { | ||
List<String> categories; | ||
|
||
SABnzbdCategories({ | ||
required this.categories, | ||
}); | ||
|
||
@override | ||
String toString() => json.encode(this.toJson()); | ||
|
||
factory SABnzbdCategories.fromJson(Map<String, dynamic> json) { | ||
return _$SABnzbdCategoriesFromJson(json); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return _$SABnzbdCategoriesToJson(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import 'dart:convert'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'package:lunasea/api/sabnzbd/models.dart'; | ||
|
||
part 'history.g.dart'; | ||
|
||
@JsonSerializable(explicitToJson: true, includeIfNull: false) | ||
class SABnzbdHistory { | ||
SABnzbdHistoryResult history; | ||
|
||
SABnzbdHistory({ | ||
required this.history, | ||
}); | ||
|
||
@override | ||
String toString() => json.encode(this.toJson()); | ||
|
||
factory SABnzbdHistory.fromJson(Map<String, dynamic> json) { | ||
return _$SABnzbdHistoryFromJson(json); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return _$SABnzbdHistoryToJson(this); | ||
} | ||
} | ||
|
||
@JsonSerializable(explicitToJson: true, includeIfNull: false) | ||
class SABnzbdHistoryResult { | ||
List<SABnzbdHistorySlot> slots; | ||
|
||
@JsonKey(name: 'day_size') | ||
String dailySize; | ||
|
||
@JsonKey(name: 'week_size') | ||
String weeklySize; | ||
|
||
@JsonKey(name: 'month_size') | ||
String monthlySize; | ||
|
||
@JsonKey(name: 'total_size') | ||
String totalSize; | ||
|
||
SABnzbdHistoryResult({ | ||
required this.slots, | ||
required this.dailySize, | ||
required this.weeklySize, | ||
required this.monthlySize, | ||
required this.totalSize, | ||
}); | ||
|
||
@override | ||
String toString() => json.encode(this.toJson()); | ||
|
||
factory SABnzbdHistoryResult.fromJson(Map<String, dynamic> json) { | ||
return _$SABnzbdHistoryResultFromJson(json); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return _$SABnzbdHistoryResultToJson(this); | ||
} | ||
} | ||
|
||
@JsonSerializable(explicitToJson: true, includeIfNull: false) | ||
class SABnzbdHistorySlot { | ||
String name; | ||
String status; | ||
String script; | ||
String category; | ||
String storage; | ||
|
||
@JsonKey(name: 'completed') | ||
int timestamp; | ||
|
||
@JsonKey(name: 'nzo_id') | ||
String nzoId; | ||
|
||
@JsonKey(name: 'bytes') | ||
int size; | ||
|
||
@JsonKey(name: 'fail_message') | ||
String failMessage; | ||
|
||
@JsonKey(name: 'action_line') | ||
String actionLine; | ||
|
||
@JsonKey(name: 'download_time') | ||
int downloadTime; | ||
|
||
@JsonKey(name: 'stage_log') | ||
List<SABnzbdStageLog> stageLog; | ||
|
||
SABnzbdHistorySlot({ | ||
required this.name, | ||
required this.status, | ||
required this.script, | ||
required this.category, | ||
required this.nzoId, | ||
required this.size, | ||
required this.failMessage, | ||
required this.timestamp, | ||
required this.actionLine, | ||
required this.downloadTime, | ||
required this.stageLog, | ||
required this.storage, | ||
}); | ||
|
||
@override | ||
String toString() => json.encode(this.toJson()); | ||
|
||
factory SABnzbdHistorySlot.fromJson(Map<String, dynamic> json) { | ||
return _$SABnzbdHistorySlotFromJson(json); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return _$SABnzbdHistorySlotToJson(this); | ||
} | ||
} |
Oops, something went wrong.