From 8eed7b883e746d60c5839354cecb31ccdcfe2ac8 Mon Sep 17 00:00:00 2001 From: Kaylee Date: Fri, 9 Jun 2023 19:11:32 +0200 Subject: [PATCH 1/3] Allow usage with generic RSS feeds --- Sources/App/Defaults.swift | 14 +------------- Sources/Feed Helper/FeedParser.swift | 2 +- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/Sources/App/Defaults.swift b/Sources/App/Defaults.swift index 19cb8af..c91deee 100644 --- a/Sources/App/Defaults.swift +++ b/Sources/App/Defaults.swift @@ -105,9 +105,7 @@ final class Defaults: NSObject { var isFeedURLValid: Bool { guard let url = feedURL, - let scheme = url.scheme, - let host = url.host, - let query = url.query + let scheme = url.scheme else { return false } @@ -117,16 +115,6 @@ final class Defaults: NSObject { return false } - guard host.hasSuffix("showrss.info") else { - NSLog("Bad host in feed URL: \(host)") - return false - } - - guard query.contains("namespaces=true") else { - NSLog("Feed URL does not have namespaces enabled") - return false - } - return true } diff --git a/Sources/Feed Helper/FeedParser.swift b/Sources/Feed Helper/FeedParser.swift index d10cf00..c6e5f0b 100644 --- a/Sources/Feed Helper/FeedParser.swift +++ b/Sources/Feed Helper/FeedParser.swift @@ -12,7 +12,7 @@ private extension Episode { /// Try to initialize an episode with the data found in an RSS "item" element init?(itemNode: XMLNode) { // Get the .torrent URL or magnet link - guard let urlString = itemNode["enclosure/@url"] else { + guard let urlString = itemNode["enclosure/@url"] ?? itemNode["link"] else { NSLog("Missing feed item URL") return nil } From 2cc2b3ac4e6a5429d6c3475e246ff4c0329a2902 Mon Sep 17 00:00:00 2001 From: Kaylee Date: Fri, 9 Jun 2023 19:11:32 +0200 Subject: [PATCH 2/3] Only show ShowRSS UI elements when using those feeds --- Catch.xcodeproj/project.pbxproj | 4 ++-- Resources/App/Base.lproj/UI.xib | 13 ++++++++----- Resources/App/de.lproj/UI.strings | Bin 6260 -> 6244 bytes Resources/App/nl.lproj/UI.strings | Bin 5940 -> 5924 bytes Resources/App/zh-Hans.lproj/UI.strings | Bin 5416 -> 5408 bytes Resources/App/zh-Hant.lproj/UI.strings | Bin 5386 -> 5370 bytes Sources/App/Defaults.swift | 17 +++++++++++++++++ Sources/App/MenuController.swift | 7 ++++++- 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Catch.xcodeproj/project.pbxproj b/Catch.xcodeproj/project.pbxproj index 4a9336c..7ab42af 100644 --- a/Catch.xcodeproj/project.pbxproj +++ b/Catch.xcodeproj/project.pbxproj @@ -160,12 +160,12 @@ 44BA5D131DAEC3B600A9CE9A /* RecentsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RecentsController.swift; path = Sources/App/RecentsController.swift; sourceTree = ""; }; 44BA5D151DAECF1A00A9CE9A /* RecentsCellView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RecentsCellView.swift; path = Sources/App/RecentsCellView.swift; sourceTree = ""; }; 44BA5D191DB81A8E00A9CE9A /* Application.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Application.swift; path = Sources/App/Application.swift; sourceTree = ""; }; - 44BA5D1B1DB8220100A9CE9A /* MenuController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MenuController.swift; path = Sources/App/MenuController.swift; sourceTree = ""; }; + 44BA5D1B1DB8220100A9CE9A /* MenuController.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; name = MenuController.swift; path = Sources/App/MenuController.swift; sourceTree = ""; tabWidth = 2; }; 44C8926E1D1814A7008F8543 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = Sources/App/AppDelegate.swift; sourceTree = ""; }; 44E2CEA21DBC0B8F00ED7A8D /* PreferencesController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PreferencesController.swift; path = Sources/App/PreferencesController.swift; sourceTree = ""; }; 44E2CEA41DBC134E00ED7A8D /* FeedParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FeedParser.swift; path = "Sources/Feed Helper/FeedParser.swift"; sourceTree = SOURCE_ROOT; }; 44FBC67A196312A400434B01 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; - 44FFCE3E1DCB92F4006E6DF0 /* Defaults.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Defaults.swift; path = Sources/App/Defaults.swift; sourceTree = ""; }; + 44FFCE3E1DCB92F4006E6DF0 /* Defaults.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; name = Defaults.swift; path = Sources/App/Defaults.swift; sourceTree = ""; tabWidth = 2; }; 8D1107310486CEB800E47090 /* Catch-Info.plist */ = {isa = PBXFileReference; explicitFileType = text.plist.xml; fileEncoding = 4; name = "Catch-Info.plist"; path = "Resources/App/Catch-Info.plist"; sourceTree = ""; }; 8D1107320486CEB800E47090 /* Catch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Catch.app; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ diff --git a/Resources/App/Base.lproj/UI.xib b/Resources/App/Base.lproj/UI.xib index 8ded401..5ca9488 100644 --- a/Resources/App/Base.lproj/UI.xib +++ b/Resources/App/Base.lproj/UI.xib @@ -23,7 +23,9 @@ + + @@ -126,7 +128,7 @@ - + @@ -140,7 +142,7 @@ - + @@ -156,7 +158,7 @@ - + @@ -452,12 +454,13 @@ DQ + - + @@ -467,7 +470,7 @@ DQ - + diff --git a/Resources/App/de.lproj/UI.strings b/Resources/App/de.lproj/UI.strings index bbab6096fd4375f8c71a60d63de24dc564d5d356..9764ed9547321bc46d5bcb3f4dd7a14fd6e2772e 100644 GIT binary patch delta 20 ccmexj@Wfz46VK!iJR+0l@px_iz|+DF0AZp delta 20 bcmZ3WwL)tHA2)k2Lk2@WL-}T2ZecC}Jxv7m diff --git a/Resources/App/zh-Hant.lproj/UI.strings b/Resources/App/zh-Hant.lproj/UI.strings index b534f8c54bb9b2e60c1a4970e18b729620555489..8aaa613ce19b7575dcb897df2879e91ccb5d8b09 100644 GIT binary patch delta 20 acmeCu`lY!+ihHsWcN`FlY@WlN#|Z#RkOpu7 delta 32 hcmeyR*`>8Xikm%{A%h{Gp?tC=cRY-}xtzP169AbQ2-E-o diff --git a/Sources/App/Defaults.swift b/Sources/App/Defaults.swift index c91deee..07e429f 100644 --- a/Sources/App/Defaults.swift +++ b/Sources/App/Defaults.swift @@ -101,6 +101,16 @@ final class Defaults: NSObject { return true } + + var isShowRSSFeed: Bool { + guard + let host = feedURL?.host, + host.hasSuffix("showrss.info") + else { + return false + } + return true + } var isFeedURLValid: Bool { guard @@ -115,6 +125,13 @@ final class Defaults: NSObject { return false } + if isShowRSSFeed, + let query = url.query, + !query.contains("namespaces=true") { + NSLog("Feed URL does not have namespaces enabled") + return false + } + return true } diff --git a/Sources/App/MenuController.swift b/Sources/App/MenuController.swift index 07c4b3a..3be3912 100644 --- a/Sources/App/MenuController.swift +++ b/Sources/App/MenuController.swift @@ -7,7 +7,9 @@ class MenuController: NSObject { @IBOutlet private weak var menuVersion: NSMenuItem! @IBOutlet private weak var menuPauseResume: NSMenuItem! @IBOutlet private weak var menuLastUpdate: NSMenuItem! - + @IBOutlet private weak var menuLaunchShowRSS: NSMenuItem! + @IBOutlet private weak var menuTopSeparator: NSMenuItem! + private var menuBarItem: NSStatusItem! override func awakeFromNib() { @@ -79,6 +81,9 @@ class MenuController: NSObject { // Configure the "last update" item menuLastUpdate.title = FeedChecker.shared.lastCheckStatus.localizedDescription + + menuLaunchShowRSS.isHidden = !Defaults.shared.isShowRSSFeed + menuTopSeparator.isHidden = !Defaults.shared.isShowRSSFeed } deinit { From de5d7f9d888ea4a33a782c568ec581b3de7e4864 Mon Sep 17 00:00:00 2001 From: Kaylee Date: Fri, 9 Jun 2023 19:11:32 +0200 Subject: [PATCH 3/3] Refresh on Defaults change notifications --- Sources/App/MenuController.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sources/App/MenuController.swift b/Sources/App/MenuController.swift index 3be3912..29cc615 100644 --- a/Sources/App/MenuController.swift +++ b/Sources/App/MenuController.swift @@ -43,6 +43,15 @@ class MenuController: NSObject { } ) + NotificationCenter.default.addObserver( + forName: Defaults.changedNotification, + object: Defaults.shared, + queue: nil, + using: { [weak self] _ in + self?.refreshMenuContents() + } + ) + // Update UI now refreshMenuContents() }