feat: add config for auto-torrent (#1219)

This commit is contained in:
Copilot authored and GitHub committed 2026-01-22 22:18:34 +08:00
1 parent a3c1f84c2c
commit 7b840b4261
31 files changed
+742 -131

No files matched your search

@@ -10,11 +10,11 @@ class DownloaderConfig {
ExtraConfig extra = ExtraConfig();
ProxyConfig proxy = ProxyConfig();
WebhookConfig webhook = WebhookConfig();
AutoTorrentConfig autoTorrent = AutoTorrentConfig();
ArchiveConfig archive = ArchiveConfig();
// New fields for auto-management
bool autoDeleteTorrents = false;
bool autoCleanMissingFiles = false;
bool autoDeleteMissingFileTasks = false;
DownloaderConfig({
this.downloadDir = '',
@@ -234,6 +234,22 @@ class ExtraConfigGithubMirror {
Map<String, dynamic> toJson() => _$ExtraConfigGithubMirrorToJson(this);
}
@JsonSerializable()
class AutoTorrentConfig {
bool enable;
bool deleteAfterDownload;
AutoTorrentConfig({
this.enable = false,
this.deleteAfterDownload = false,
});
factory AutoTorrentConfig.fromJson(Map<String, dynamic>? json) =>
json == null ? AutoTorrentConfig() : _$AutoTorrentConfigFromJson(json);
Map<String, dynamic> toJson() => _$AutoTorrentConfigToJson(this);
}
@JsonSerializable()
class ArchiveConfig {
bool autoExtract;
@@ -248,4 +264,4 @@ class ArchiveConfig {
json == null ? ArchiveConfig() : _$ArchiveConfigFromJson(json);
Map<String, dynamic> toJson() => _$ArchiveConfigToJson(this);
}
}
@@ -17,10 +17,11 @@ DownloaderConfig _$DownloaderConfigFromJson(Map<String, dynamic> json) =>
..proxy = ProxyConfig.fromJson(json['proxy'] as Map<String, dynamic>)
..webhook =
WebhookConfig.fromJson(json['webhook'] as Map<String, dynamic>?)
..autoTorrent = AutoTorrentConfig.fromJson(
json['autoTorrent'] as Map<String, dynamic>?)
..archive =
ArchiveConfig.fromJson(json['archive'] as Map<String, dynamic>?)
..autoDeleteTorrents = json['autoDeleteTorrents'] as bool
..autoCleanMissingFiles = json['autoCleanMissingFiles'] as bool;
..autoDeleteMissingFileTasks = json['autoDeleteMissingFileTasks'] as bool;
Map<String, dynamic> _$DownloaderConfigToJson(DownloaderConfig instance) =>
<String, dynamic>{
@@ -30,9 +31,9 @@ Map<String, dynamic> _$DownloaderConfigToJson(DownloaderConfig instance) =>
'extra': instance.extra.toJson(),
'proxy': instance.proxy.toJson(),
'webhook': instance.webhook.toJson(),
'autoTorrent': instance.autoTorrent.toJson(),
'archive': instance.archive.toJson(),
'autoDeleteTorrents': instance.autoDeleteTorrents,
'autoCleanMissingFiles': instance.autoCleanMissingFiles,
'autoDeleteMissingFileTasks': instance.autoDeleteMissingFileTasks,
};
ProtocolConfig _$ProtocolConfigFromJson(Map<String, dynamic> json) =>
@@ -242,6 +243,18 @@ Map<String, dynamic> _$ExtraConfigGithubMirrorToJson(
'mirrors': instance.mirrors.map((e) => e.toJson()).toList(),
};
AutoTorrentConfig _$AutoTorrentConfigFromJson(Map<String, dynamic> json) =>
AutoTorrentConfig(
enable: json['enable'] as bool? ?? false,
deleteAfterDownload: json['deleteAfterDownload'] as bool? ?? false,
);
Map<String, dynamic> _$AutoTorrentConfigToJson(AutoTorrentConfig instance) =>
<String, dynamic>{
'enable': instance.enable,
'deleteAfterDownload': instance.deleteAfterDownload,
};
ArchiveConfig _$ArchiveConfigFromJson(Map<String, dynamic> json) =>
ArchiveConfig(
autoExtract: json['autoExtract'] as bool? ?? true,
+6 -4
View File
@@ -25,15 +25,17 @@ class Options {
@JsonSerializable()
class OptsExtraHttp {
int connections;
bool autoTorrent;
bool autoExtract;
bool? autoTorrent;
bool? deleteTorrentAfterDownload;
bool? autoExtract;
String archivePassword;
bool deleteAfterExtract;
OptsExtraHttp({
this.connections = 0,
this.autoTorrent = false,
this.autoExtract = false,
this.autoTorrent,
this.deleteTorrentAfterDownload,
this.autoExtract,
this.archivePassword = '',
this.deleteAfterExtract = false,
});
+22 -10
View File
@@ -36,17 +36,29 @@ Map<String, dynamic> _$OptionsToJson(Options instance) {
OptsExtraHttp _$OptsExtraHttpFromJson(Map<String, dynamic> json) =>
OptsExtraHttp(
connections: (json['connections'] as num?)?.toInt() ?? 0,
autoTorrent: json['autoTorrent'] as bool? ?? false,
autoExtract: json['autoExtract'] as bool? ?? false,
autoTorrent: json['autoTorrent'] as bool?,
deleteTorrentAfterDownload: json['deleteTorrentAfterDownload'] as bool?,
autoExtract: json['autoExtract'] as bool?,
archivePassword: json['archivePassword'] as String? ?? '',
deleteAfterExtract: json['deleteAfterExtract'] as bool? ?? false,
);
Map<String, dynamic> _$OptsExtraHttpToJson(OptsExtraHttp instance) =>
<String, dynamic>{
'connections': instance.connections,
'autoTorrent': instance.autoTorrent,
'autoExtract': instance.autoExtract,
'archivePassword': instance.archivePassword,
'deleteAfterExtract': instance.deleteAfterExtract,
};
Map<String, dynamic> _$OptsExtraHttpToJson(OptsExtraHttp instance) {
final val = <String, dynamic>{
'connections': instance.connections,
};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('autoTorrent', instance.autoTorrent);
writeNotNull(
'deleteTorrentAfterDownload', instance.deleteTorrentAfterDownload);
writeNotNull('autoExtract', instance.autoExtract);
val['archivePassword'] = instance.archivePassword;
val['deleteAfterExtract'] = instance.deleteAfterExtract;
return val;
}