@muhammedaksam/easiarr 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muhammedaksam/easiarr",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "TUI tool for generating docker-compose files for the *arr media ecosystem with 41 apps, TRaSH Guides best practices, VPN routing, and Traefik reverse proxy support",
5
5
  "module": "src/index.ts",
6
6
  "type": "module",
@@ -46,6 +46,7 @@ export interface RemotePathMapping {
46
46
 
47
47
  import type { AppId } from "../config/schema"
48
48
  import { getCategoryForApp, getCategoryFieldName } from "../utils/categories"
49
+ import { TRASH_NAMING_CONFIG, type NamingConfig } from "./naming-config"
49
50
 
50
51
  // qBittorrent download client config
51
52
  export function createQBittorrentConfig(
@@ -239,11 +240,63 @@ export class ArrApiClient {
239
240
  })
240
241
  }
241
242
 
243
+ /**
244
+ * Set application URL for external access (e.g., from Jellyseerr/dashboard links)
245
+ * URL will be used when generating external links in the app
246
+ */
247
+ async setApplicationUrl(applicationUrl: string): Promise<HostConfig> {
248
+ const currentConfig = await this.getHostConfig()
249
+
250
+ const updatedConfig: HostConfig = {
251
+ ...currentConfig,
252
+ applicationUrl,
253
+ }
254
+
255
+ debugLog("ArrAPI", `Setting applicationUrl to: ${applicationUrl}`)
256
+
257
+ return this.request<HostConfig>("/config/host", {
258
+ method: "PUT",
259
+ body: JSON.stringify(updatedConfig),
260
+ })
261
+ }
262
+
242
263
  // Remote Path Mapping methods - for Docker path translation
264
+
243
265
  async getRemotePathMappings(): Promise<RemotePathMapping[]> {
244
266
  return this.request<RemotePathMapping[]>("/remotepathmapping")
245
267
  }
246
268
 
269
+ // Naming Configuration methods
270
+ async getNamingConfig<T extends NamingConfig>(): Promise<T> {
271
+ return this.request<T>("/config/naming")
272
+ }
273
+
274
+ async updateNamingConfig<T extends NamingConfig>(config: T): Promise<T> {
275
+ return this.request<T>("/config/naming", {
276
+ method: "PUT",
277
+ body: JSON.stringify(config),
278
+ })
279
+ }
280
+
281
+ async configureTRaSHNaming(appType: "radarr" | "sonarr"): Promise<void> {
282
+ try {
283
+ // 1. Get current configuration to preserve ID and other fields
284
+ const currentConfig = await this.getNamingConfig<NamingConfig & { id?: number }>()
285
+
286
+ // 2. Merge with TRaSH defaults
287
+ const trashConfig = TRASH_NAMING_CONFIG[appType]
288
+ const newConfig = {
289
+ ...currentConfig,
290
+ ...trashConfig,
291
+ }
292
+
293
+ // 3. Update configuration
294
+ await this.updateNamingConfig(newConfig)
295
+ } catch (e) {
296
+ throw new Error(`Failed to configure naming: ${e}`)
297
+ }
298
+ }
299
+
247
300
  async addRemotePathMapping(host: string, remotePath: string, localPath: string): Promise<RemotePathMapping> {
248
301
  return this.request<RemotePathMapping>("/remotepathmapping", {
249
302
  method: "POST",
@@ -6,6 +6,19 @@
6
6
  import { debugLog } from "../utils/debug"
7
7
  import type { IAutoSetupClient, AutoSetupOptions, AutoSetupResult } from "./auto-setup-types"
8
8
 
9
+ /**
10
+ * Bazarr Language Profile Structure
11
+ */
12
+ export interface BazarrLanguageProfile {
13
+ name: string
14
+ cutoff: string
15
+ languages: {
16
+ code: string
17
+ forced: boolean
18
+ hi: boolean
19
+ }[]
20
+ }
21
+
9
22
  /**
10
23
  * Bazarr System Settings (partial - auth related fields)
11
24
  */
@@ -232,6 +245,76 @@ export class BazarrApiClient implements IAutoSetupClient {
232
245
  }
233
246
  }
234
247
 
248
+ /**
249
+ * Configure General Settings (TRaSH Recommended)
250
+ */
251
+ async configureGeneralSettings(): Promise<boolean> {
252
+ try {
253
+ debugLog("Bazarr", "Configuring general settings")
254
+ await this.postForm("/system/settings", {
255
+ "settings-subtitles-use_embedded_subtitles": "true",
256
+ "settings-subtitles-autosearch": "true",
257
+ "settings-subtitles-path_mapping": "", // Empty = Alongside Media File
258
+ })
259
+ return true
260
+ } catch (e) {
261
+ debugLog("Bazarr", `Failed to configure general settings: ${e}`)
262
+ return false
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Get all language profiles
268
+ */
269
+ async getLanguageProfiles(): Promise<BazarrLanguageProfile[]> {
270
+ return this.get<BazarrLanguageProfile[]>("/system/languages/profiles")
271
+ }
272
+
273
+ /**
274
+ * Configure Default Language Profile
275
+ * Creates an english profile if it doesn't exist
276
+ */
277
+ async configureDefaultLanguageProfile(name = "English", language = "en"): Promise<boolean> {
278
+ try {
279
+ debugLog("Bazarr", `Configuring language profile: ${name}`)
280
+
281
+ // Get existing profiles to check and to preserve them
282
+ const profiles = (await this.getLanguageProfiles()) || []
283
+ const existing = profiles.find((p) => p.name === name)
284
+
285
+ if (existing) {
286
+ debugLog("Bazarr", `Language profile '${name}' already exists`)
287
+ return true
288
+ }
289
+
290
+ const newProfile: BazarrLanguageProfile = {
291
+ name: name,
292
+ cutoff: language,
293
+ languages: [
294
+ {
295
+ code: language,
296
+ forced: false,
297
+ hi: false,
298
+ },
299
+ ],
300
+ }
301
+
302
+ profiles.push(newProfile)
303
+
304
+ // Update settings with the new list (serialized as JSON)
305
+ // Note: Bazarr expects 'languages_profiles' as a JSON string in the form data
306
+ await this.postForm("/system/settings", {
307
+ languages_profiles: JSON.stringify(profiles),
308
+ })
309
+
310
+ debugLog("Bazarr", `Created language profile: ${name}`)
311
+ return true
312
+ } catch (e) {
313
+ debugLog("Bazarr", `Failed to configure language profile: ${e}`)
314
+ return false
315
+ }
316
+ }
317
+
235
318
  /**
236
319
  * Run the auto-setup process for Bazarr
237
320
  */
@@ -237,6 +237,15 @@ export class JellyseerrClient implements IAutoSetupClient {
237
237
  })
238
238
  }
239
239
 
240
+ /**
241
+ * Set application URL for external access
242
+ * URL will be used for links to Jellyseerr from other apps
243
+ */
244
+ async setApplicationUrl(applicationUrl: string): Promise<JellyseerrMainSettings> {
245
+ debugLog("Jellyseerr", `Setting applicationUrl to: ${applicationUrl}`)
246
+ return this.updateMainSettings({ applicationUrl })
247
+ }
248
+
240
249
  // ==========================================
241
250
  // Jellyfin Configuration
242
251
  // ==========================================
@@ -383,6 +392,13 @@ export class JellyseerrClient implements IAutoSetupClient {
383
392
  })
384
393
  }
385
394
 
395
+ async updateRadarr(id: number, settings: Partial<JellyseerrRadarrSettings>): Promise<JellyseerrRadarrSettings> {
396
+ return this.request<JellyseerrRadarrSettings>(`/settings/radarr/${id}`, {
397
+ method: "PUT",
398
+ body: JSON.stringify(settings),
399
+ })
400
+ }
401
+
386
402
  // ==========================================
387
403
  // Sonarr Configuration
388
404
  // ==========================================
@@ -411,6 +427,13 @@ export class JellyseerrClient implements IAutoSetupClient {
411
427
  })
412
428
  }
413
429
 
430
+ async updateSonarr(id: number, settings: Partial<JellyseerrSonarrSettings>): Promise<JellyseerrSonarrSettings> {
431
+ return this.request<JellyseerrSonarrSettings>(`/settings/sonarr/${id}`, {
432
+ method: "PUT",
433
+ body: JSON.stringify(settings),
434
+ })
435
+ }
436
+
414
437
  // ==========================================
415
438
  // Full Setup Wizard
416
439
  // ==========================================
@@ -453,14 +476,32 @@ export class JellyseerrClient implements IAutoSetupClient {
453
476
 
454
477
  /**
455
478
  * Configure Radarr connection with auto-detection of profiles
479
+ * @param externalUrl - Optional external URL for navigation (e.g., https://radarr.example.com)
456
480
  */
457
481
  async configureRadarr(
458
482
  hostname: string,
459
483
  port: number,
460
484
  apiKey: string,
461
- rootFolder: string
485
+ rootFolder: string,
486
+ externalUrl?: string
462
487
  ): Promise<JellyseerrRadarrSettings | null> {
463
488
  try {
489
+ // Check if Radarr is already configured
490
+ const existingConfigs = await this.getRadarrSettings()
491
+ const existingConfig = existingConfigs.find((c) => c.hostname === hostname && c.port === port)
492
+
493
+ if (existingConfig?.id) {
494
+ // Update existing configuration (just update externalUrl)
495
+ // Note: id must be excluded from body - it's read-only in the API
496
+ debugLog("Jellyseerr", `Updating existing Radarr config (id: ${existingConfig.id})`)
497
+ const { id, ...configWithoutId } = existingConfig
498
+ return await this.updateRadarr(id, {
499
+ ...configWithoutId,
500
+ externalUrl,
501
+ })
502
+ }
503
+
504
+ // Test connection and get profiles
464
505
  const testResult = await this.testRadarr({
465
506
  hostname,
466
507
  port,
@@ -487,6 +528,7 @@ export class JellyseerrClient implements IAutoSetupClient {
487
528
  is4k: false,
488
529
  minimumAvailability: "announced",
489
530
  isDefault: true,
531
+ externalUrl,
490
532
  })
491
533
  } catch (e) {
492
534
  debugLog("Jellyseerr", `Radarr config failed: ${e}`)
@@ -496,14 +538,32 @@ export class JellyseerrClient implements IAutoSetupClient {
496
538
 
497
539
  /**
498
540
  * Configure Sonarr connection with auto-detection of profiles
541
+ * @param externalUrl - Optional external URL for navigation (e.g., https://sonarr.example.com)
499
542
  */
500
543
  async configureSonarr(
501
544
  hostname: string,
502
545
  port: number,
503
546
  apiKey: string,
504
- rootFolder: string
547
+ rootFolder: string,
548
+ externalUrl?: string
505
549
  ): Promise<JellyseerrSonarrSettings | null> {
506
550
  try {
551
+ // Check if Sonarr is already configured
552
+ const existingConfigs = await this.getSonarrSettings()
553
+ const existingConfig = existingConfigs.find((c) => c.hostname === hostname && c.port === port)
554
+
555
+ if (existingConfig?.id) {
556
+ // Update existing configuration (just update externalUrl)
557
+ // Note: id must be excluded from body - it's read-only in the API
558
+ debugLog("Jellyseerr", `Updating existing Sonarr config (id: ${existingConfig.id})`)
559
+ const { id, ...configWithoutId } = existingConfig
560
+ return await this.updateSonarr(id, {
561
+ ...configWithoutId,
562
+ externalUrl,
563
+ })
564
+ }
565
+
566
+ // Test connection and get profiles
507
567
  const testResult = await this.testSonarr({
508
568
  hostname,
509
569
  port,
@@ -530,6 +590,7 @@ export class JellyseerrClient implements IAutoSetupClient {
530
590
  is4k: false,
531
591
  enableSeasonFolders: true,
532
592
  isDefault: true,
593
+ externalUrl,
533
594
  })
534
595
  } catch (e) {
535
596
  debugLog("Jellyseerr", `Sonarr config failed: ${e}`)
@@ -550,10 +611,27 @@ export class JellyseerrClient implements IAutoSetupClient {
550
611
  return { success: false, message: "Jellyseerr not reachable" }
551
612
  }
552
613
 
614
+ // Get Jellyfin connection details from env
615
+ const jellyfinHost = env["JELLYFIN_HOST"] || "jellyfin"
616
+ const jellyfinPort = parseInt(env["JELLYFIN_PORT"] || "8096", 10)
617
+
553
618
  // Check if already initialized
554
619
  const initialized = await this.isInitialized()
555
620
  if (initialized) {
556
- // Get API key from settings
621
+ // Authenticate first to get session cookie (needed for protected endpoints)
622
+ try {
623
+ await this.authenticateJellyfin(username, password, jellyfinHost, jellyfinPort)
624
+ debugLog("Jellyseerr", "Authenticated to already-initialized instance")
625
+ } catch (authError) {
626
+ debugLog("Jellyseerr", `Auth failed on initialized instance: ${authError}`)
627
+ // Still return success, just without API key access
628
+ return {
629
+ success: true,
630
+ message: "Already configured (could not authenticate)",
631
+ }
632
+ }
633
+
634
+ // Now we can access protected endpoints with our session cookie
557
635
  const settings = await this.getMainSettings()
558
636
  return {
559
637
  success: true,
@@ -563,11 +641,7 @@ export class JellyseerrClient implements IAutoSetupClient {
563
641
  }
564
642
  }
565
643
 
566
- // Get Jellyfin connection details from env
567
- const jellyfinHost = env["JELLYFIN_HOST"] || "jellyfin"
568
- const jellyfinPort = parseInt(env["JELLYFIN_PORT"] || "8096", 10)
569
-
570
- // Run the setup wizard
644
+ // Run the setup wizard (authenticates as part of setup)
571
645
  const apiKey = await this.runJellyfinSetup(jellyfinHost, jellyfinPort, username, password)
572
646
 
573
647
  // Mark as initialized
@@ -0,0 +1,67 @@
1
+ export interface RadarrNamingConfig {
2
+ renameMovies: boolean
3
+ replaceIllegalCharacters: boolean
4
+ colonReplacementFormat: "dash" | "spaceDash" | "spaceDashSpace" | "smart" | "delete" | number
5
+ standardMovieFormat: string
6
+ movieFolderFormat: string
7
+ includeQuality: boolean
8
+ replaceSpaces: boolean
9
+ }
10
+
11
+ export interface SonarrNamingConfig {
12
+ renameEpisodes: boolean
13
+ replaceIllegalCharacters: boolean
14
+ colonReplacementFormat: "dash" | "spaceDash" | "spaceDashSpace" | "smart" | "delete" | number
15
+ multiEpisodeStyle: "extend" | "duplicate" | "repeat" | "scene" | "range" | "prefixedRange" | number
16
+ dailyEpisodeFormat: string
17
+ animeEpisodeFormat: string
18
+ seriesFolderFormat: string
19
+ seasonFolderFormat: string
20
+ standardEpisodeFormat: string
21
+ includeSeriesTitle: boolean
22
+ includeEpisodeTitle: boolean
23
+ includeQuality: boolean
24
+ replaceSpaces: boolean
25
+ separator: string
26
+ numberStyle: string
27
+ }
28
+
29
+ export type NamingConfig = RadarrNamingConfig | SonarrNamingConfig
30
+
31
+ // TRaSH Guides Recommended Naming Schemes
32
+ // Source: https://trash-guides.info/Radarr/Radarr-recommended-naming-scheme/
33
+ // Source: https://trash-guides.info/Sonarr/Sonarr-recommended-naming-scheme/
34
+
35
+ export const TRASH_NAMING_CONFIG = {
36
+ radarr: {
37
+ renameMovies: true,
38
+ replaceIllegalCharacters: true,
39
+ colonReplacementFormat: "dash",
40
+ standardMovieFormat:
41
+ "{Movie CleanTitle} ({Release Year}) {edition-{Edition Tags}} {[Custom Formats]}{[Quality Full]}{[MediaInfo 3D]}{[Mediainfo AudioCodec}{ Mediainfo AudioChannels]}{[MediaInfo VideoDynamicRangeType]}{[Mediainfo VideoCodec]}{-Release Group}",
42
+ movieFolderFormat: "{Movie CleanTitle} ({Release Year})",
43
+ includeQuality: true,
44
+ replaceSpaces: false,
45
+ } as RadarrNamingConfig,
46
+
47
+ sonarr: {
48
+ renameEpisodes: true,
49
+ replaceIllegalCharacters: true,
50
+ colonReplacementFormat: 1, // 1 = Dash
51
+ multiEpisodeStyle: 5, // 5 = Prefixed Range
52
+ standardEpisodeFormat:
53
+ "{Series TitleYear} - S{season:00}E{episode:00} - {Episode CleanTitle} {[Custom Formats]}{[Quality Full]}{[Mediainfo AudioCodec}{ Mediainfo AudioChannels]}{[MediaInfo VideoDynamicRangeType]}{[Mediainfo VideoCodec]}{-Release Group}",
54
+ dailyEpisodeFormat:
55
+ "{Series TitleYear} - {Air-Date} - {Episode CleanTitle} {[Custom Formats]}{[Quality Full]}{[MediaInfo 3D]}{[Mediainfo AudioCodec}{ Mediainfo AudioChannels]}{[MediaInfo VideoDynamicRangeType]}{[Mediainfo VideoCodec]}{-Release Group}",
56
+ animeEpisodeFormat:
57
+ "{Series TitleYear} - S{season:00}E{episode:00} - {absolute:000} - {Episode CleanTitle} {[Custom Formats]}{[Quality Full]}{[MediaInfo 3D]}{[Mediainfo AudioCodec}{ Mediainfo AudioChannels]}{MediaInfo AudioLanguages}{[MediaInfo VideoDynamicRangeType]}[{Mediainfo VideoCodec }{MediaInfo VideoBitDepth}bit]{-Release Group}",
58
+ seriesFolderFormat: "{Series TitleYear}",
59
+ seasonFolderFormat: "Season {season:00}",
60
+ includeSeriesTitle: true,
61
+ includeEpisodeTitle: true,
62
+ includeQuality: true,
63
+ replaceSpaces: false,
64
+ separator: " - ",
65
+ numberStyle: "S{season:00}E{episode:00}",
66
+ } as SonarrNamingConfig,
67
+ }
@@ -254,6 +254,30 @@ export class OverseerrClient implements IAutoSetupClient {
254
254
  return null
255
255
  }
256
256
 
257
+ /**
258
+ * Set application URL for external access
259
+ * URL will be used for links to Overseerr from other apps
260
+ */
261
+ async setApplicationUrl(applicationUrl: string): Promise<boolean> {
262
+ debugLog("OverseerrApi", `Setting applicationUrl to: ${applicationUrl}`)
263
+
264
+ try {
265
+ const response = await fetch(`${this.baseUrl}/api/v1/settings/main`, {
266
+ method: "POST",
267
+ headers: this.getHeaders(),
268
+ body: JSON.stringify({ applicationUrl }),
269
+ })
270
+
271
+ if (response.ok) {
272
+ debugLog("OverseerrApi", "Application URL set successfully")
273
+ return true
274
+ }
275
+ } catch (error) {
276
+ debugLog("OverseerrApi", `Failed to set application URL: ${error}`)
277
+ }
278
+ return false
279
+ }
280
+
257
281
  /**
258
282
  * Sync Plex libraries
259
283
  */
@@ -14,6 +14,33 @@ export interface QBittorrentPreferences {
14
14
  auto_tmm_enabled?: boolean
15
15
  category_changed_tmm_enabled?: boolean
16
16
  save_path_changed_tmm_enabled?: boolean
17
+ max_ratio?: number
18
+ max_ratio_enabled?: boolean
19
+ max_ratio_act?: number // 0 = Pause, 1 = Remove
20
+ max_seeding_time?: number
21
+ max_seeding_time_enabled?: boolean
22
+ queueing_enabled?: boolean
23
+ web_ui_username?: string
24
+ web_ui_password?: string
25
+ // Connection & Speed
26
+ listen_port?: number
27
+ upnp?: boolean
28
+ natpmp?: boolean
29
+ dl_limit?: number
30
+ up_limit?: number
31
+ limit_utp_rate?: boolean
32
+ limit_tcp_overhead?: boolean
33
+ limit_lan_peers?: boolean
34
+ // Bittorrent
35
+ enable_dht?: boolean
36
+ enable_pex?: boolean
37
+ enable_lsd?: boolean
38
+ encryption_mode?: number // 0=Prefer, 1=Force, 2=Allow (check API docs for exact enum, typically 1=Force or Allow)
39
+ anonymous_mode?: boolean
40
+ add_trackers_enabled?: boolean
41
+ pre_allocate_all?: boolean
42
+ incomplete_files_ext?: boolean
43
+ create_subfolder_enabled?: boolean
17
44
  }
18
45
 
19
46
  export interface QBittorrentCategory {
@@ -197,6 +224,37 @@ export class QBittorrentClient implements IAutoSetupClient {
197
224
  auto_tmm_enabled: true,
198
225
  category_changed_tmm_enabled: true,
199
226
  save_path_changed_tmm_enabled: true,
227
+
228
+ // Downloads
229
+ pre_allocate_all: false, // Recommended disabled for unRaid/cache drives, safe default
230
+ incomplete_files_ext: true, // Recommended: Enabled
231
+ create_subfolder_enabled: true, // Recommended: Enabled
232
+
233
+ // Connection
234
+ upnp: false, // Recommended: Disabled (use manual port forward)
235
+ natpmp: false, // Recommended: Disabled
236
+
237
+ // Speed
238
+ dl_limit: -1, // Unlimited
239
+ up_limit: -1, // Unlimited (User should tune if needed)
240
+ limit_utp_rate: true, // Recommended: Enabled
241
+ limit_tcp_overhead: false, // Recommended: Disabled
242
+ limit_lan_peers: true, // Recommended: Enabled
243
+
244
+ // Bittorrent
245
+ enable_dht: true, // Implied enabled
246
+ enable_pex: true, // Implied enabled
247
+ enable_lsd: true, // Implied enabled
248
+ encryption_mode: 0, // 0 = Prefer Encryption (closest to "Allow encryption" usually, need to verify enum. 1=Force, 2=None usually. Let's assume 0 is safe/default or check docs if possible. TRaSH says "Allow encryption")
249
+ anonymous_mode: false, // Recommended: Disabled
250
+ add_trackers_enabled: false, // Recommended: Disabled for private trackers
251
+ queueing_enabled: true, // Recommended: Personal preference, enabled by default
252
+
253
+ // Seeding Limits (TRaSH Recommended: Disable globally)
254
+ max_ratio: -1, // -1 = Unlimited
255
+ max_ratio_enabled: false,
256
+ max_seeding_time_enabled: false,
257
+ max_ratio_act: 0, // 0 = Pause (Safe fallback)
200
258
  }
201
259
 
202
260
  if (auth) {
@@ -1,8 +1,15 @@
1
1
  /**
2
2
  * Quality Profile API Client
3
- * Manages Quality Profiles and Custom Format scoring for Radarr/Sonarr
3
+ * Manages Quality Profiles and Custom Format scoring for Radarr/Sonarr/Lidarr
4
4
  */
5
5
 
6
+ import { debugLog } from "../utils/debug"
7
+ import {
8
+ TRASH_RADARR_QUALITY_DEFINITIONS,
9
+ TRASH_SONARR_QUALITY_DEFINITIONS,
10
+ TRASH_LIDARR_QUALITY_DEFINITIONS,
11
+ } from "../config/trash-quality-definitions"
12
+
6
13
  export interface QualityItem {
7
14
  id?: number
8
15
  name?: string
@@ -112,10 +119,23 @@ export class QualityProfileClient {
112
119
  }
113
120
 
114
121
  async updateQualityDefinitions(definitions: QualityDefinition[]): Promise<QualityDefinition[]> {
115
- return this.request<QualityDefinition[]>("/qualitydefinition/update", {
116
- method: "PUT",
117
- body: JSON.stringify(definitions),
118
- })
122
+ const updated: QualityDefinition[] = []
123
+
124
+ // Update each definition individually as bulk update is not reliably supported across all versions
125
+ for (const def of definitions) {
126
+ if (!def.id) continue
127
+
128
+ try {
129
+ const result = await this.request<QualityDefinition>(`/qualitydefinition/${def.id}`, {
130
+ method: "PUT",
131
+ body: JSON.stringify(def),
132
+ })
133
+ updated.push(result)
134
+ } catch (e) {
135
+ debugLog("QualityProfile", `Failed to update definition ${def.id}: ${e}`)
136
+ }
137
+ }
138
+ return updated
119
139
  }
120
140
 
121
141
  // Helper: Get quality by name from existing profiles
@@ -202,4 +222,48 @@ export class QualityProfileClient {
202
222
 
203
223
  return this.updateQualityProfile(profileId, profile)
204
224
  }
225
+
226
+ // Apply TRaSH/Davo Quality Definitions (File Size Limits)
227
+ async updateTrashQualityDefinitions(appType: "radarr" | "sonarr" | "lidarr"): Promise<void> {
228
+ try {
229
+ debugLog("QualityProfile", `Updating Quality Definitions for ${appType}`)
230
+ const definitions = await this.getQualityDefinitions()
231
+
232
+ // Get appropriate definitions based on app type
233
+ let trashDefs
234
+ if (appType === "radarr") {
235
+ trashDefs = TRASH_RADARR_QUALITY_DEFINITIONS
236
+ } else if (appType === "sonarr") {
237
+ trashDefs = TRASH_SONARR_QUALITY_DEFINITIONS
238
+ } else {
239
+ trashDefs = TRASH_LIDARR_QUALITY_DEFINITIONS
240
+ }
241
+
242
+ let updatedCount = 0
243
+
244
+ const newDefinitions = definitions.map((def) => {
245
+ const trashDef = trashDefs.find((t) => t.quality === def.quality.name)
246
+ if (trashDef) {
247
+ updatedCount++
248
+ return {
249
+ ...def,
250
+ minSize: trashDef.min,
251
+ maxSize: trashDef.max,
252
+ preferredSize: trashDef.preferred,
253
+ }
254
+ }
255
+ return def
256
+ })
257
+
258
+ if (updatedCount > 0) {
259
+ await this.updateQualityDefinitions(newDefinitions)
260
+ debugLog("QualityProfile", `Successfully updated ${updatedCount} quality definitions`)
261
+ } else {
262
+ debugLog("QualityProfile", "No matching quality definitions found to update")
263
+ }
264
+ } catch (e) {
265
+ debugLog("QualityProfile", `Failed to update quality definitions: ${e}`)
266
+ throw e
267
+ }
268
+ }
205
269
  }