Skip to content

Commit

Permalink
Merge pull request #157 from chrisballinger/generic-rss
Browse files Browse the repository at this point in the history
Allow usage with generic RSS feeds
  • Loading branch information
Kaylee committed Jun 9, 2023
2 parents 71b706d + de5d7f9 commit 60ae76d
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Catch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@
44BA5D131DAEC3B600A9CE9A /* RecentsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RecentsController.swift; path = Sources/App/RecentsController.swift; sourceTree = "<group>"; };
44BA5D151DAECF1A00A9CE9A /* RecentsCellView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RecentsCellView.swift; path = Sources/App/RecentsCellView.swift; sourceTree = "<group>"; };
44BA5D191DB81A8E00A9CE9A /* Application.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Application.swift; path = Sources/App/Application.swift; sourceTree = "<group>"; };
44BA5D1B1DB8220100A9CE9A /* MenuController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MenuController.swift; path = Sources/App/MenuController.swift; sourceTree = "<group>"; };
44BA5D1B1DB8220100A9CE9A /* MenuController.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; name = MenuController.swift; path = Sources/App/MenuController.swift; sourceTree = "<group>"; tabWidth = 2; };
44C8926E1D1814A7008F8543 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = Sources/App/AppDelegate.swift; sourceTree = "<group>"; };
44E2CEA21DBC0B8F00ED7A8D /* PreferencesController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PreferencesController.swift; path = Sources/App/PreferencesController.swift; sourceTree = "<group>"; };
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 = "<group>"; };
44FFCE3E1DCB92F4006E6DF0 /* Defaults.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; name = Defaults.swift; path = Sources/App/Defaults.swift; sourceTree = "<group>"; 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 = "<group>"; };
8D1107320486CEB800E47090 /* Catch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Catch.app; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand Down
13 changes: 8 additions & 5 deletions Resources/App/Base.lproj/UI.xib
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
<connections>
<outlet property="menu" destination="523" id="529"/>
<outlet property="menuLastUpdate" destination="540" id="813"/>
<outlet property="menuLaunchShowRSS" destination="524" id="hOA-LO-Q3f"/>
<outlet property="menuPauseResume" destination="541" id="812"/>
<outlet property="menuTopSeparator" destination="531" id="Hbt-dA-qRM"/>
<outlet property="menuVersion" destination="545" id="657"/>
</connections>
</customObject>
Expand Down Expand Up @@ -126,7 +128,7 @@
<window title="Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="552" userLabel="Preferences">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<rect key="contentRect" x="310" y="248" width="700" height="317"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1080"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<view key="contentView" id="553">
<rect key="frame" x="0.0" y="0.0" width="700" height="317"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand All @@ -140,7 +142,7 @@
<rect key="frame" x="0.0" y="0.0" width="660" height="236"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<box autoresizesSubviews="NO" borderType="line" title="ShowRSS Feed" translatesAutoresizingMaskIntoConstraints="NO" id="621">
<box autoresizesSubviews="NO" borderType="line" title="RSS Feed" translatesAutoresizingMaskIntoConstraints="NO" id="621">
<rect key="frame" x="-3" y="123" width="666" height="113"/>
<view key="contentView" id="bQf-OL-1yY">
<rect key="frame" x="3" y="3" width="660" height="95"/>
Expand All @@ -156,7 +158,7 @@
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="787">
<rect key="frame" x="86" y="59" width="526" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="http://showrss.info/..." drawsBackground="YES" id="788">
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="https://showrss.info/..." drawsBackground="YES" id="788">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand Down Expand Up @@ -452,12 +454,13 @@ DQ
<toolbarItem reference="613"/>
</defaultToolbarItems>
</toolbar>
<point key="canvasLocation" x="139" y="119.5"/>
</window>
<customObject id="392" customClass="NSFontManager"/>
<window title="Recent Episodes" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="aQN-n7-TBr" userLabel="Recent Episodes" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="120" y="64" width="431" height="435"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1080"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<value key="minSize" type="size" width="200" height="300"/>
<view key="contentView" id="gSi-VU-gYd">
<rect key="frame" x="0.0" y="0.0" width="431" height="435"/>
Expand All @@ -467,7 +470,7 @@ DQ
<rect key="frame" x="0.0" y="0.0" width="431" height="435"/>
<clipView key="contentView" drawsBackground="NO" id="KtZ-hY-aan">
<rect key="frame" x="0.0" y="0.0" width="431" height="435"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="55" viewBased="YES" id="oof-vB-WHt">
<rect key="frame" x="0.0" y="0.0" width="431" height="435"/>
Expand Down
Binary file modified Resources/App/de.lproj/UI.strings
Binary file not shown.
Binary file modified Resources/App/nl.lproj/UI.strings
Binary file not shown.
Binary file modified Resources/App/zh-Hans.lproj/UI.strings
Binary file not shown.
Binary file modified Resources/App/zh-Hant.lproj/UI.strings
Binary file not shown.
27 changes: 16 additions & 11 deletions Sources/App/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,21 @@ 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
let url = feedURL,
let scheme = url.scheme,
let host = url.host,
let query = url.query
let scheme = url.scheme
else {
return false
}
Expand All @@ -117,14 +125,11 @@ 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
if isShowRSSFeed,
let query = url.query,
!query.contains("namespaces=true") {
NSLog("Feed URL does not have namespaces enabled")
return false
}

return true
Expand Down
16 changes: 15 additions & 1 deletion Sources/App/MenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -41,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()
}
Expand Down Expand Up @@ -79,6 +90,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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Feed Helper/FeedParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 60ae76d

Please sign in to comment.