2024-08-19 06:03:26 +02:00
|
|
|
//
|
|
|
|
// OPMLItem.swift
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 8/18/24.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import os
|
|
|
|
|
2024-08-26 07:00:27 +02:00
|
|
|
public class OPMLItem {
|
2024-08-19 06:03:26 +02:00
|
|
|
|
2024-08-27 04:27:30 +02:00
|
|
|
public let feedSpecifier: OPMLFeedSpecifier?
|
2024-08-19 06:03:26 +02:00
|
|
|
|
2024-08-27 04:27:30 +02:00
|
|
|
public let attributes: [String: String]?
|
2024-08-19 06:03:26 +02:00
|
|
|
public let titleFromAttributes: String?
|
|
|
|
|
2024-08-19 07:07:17 +02:00
|
|
|
public var items: [OPMLItem]?
|
|
|
|
public var isFolder: Bool {
|
2024-08-27 04:27:30 +02:00
|
|
|
(items?.count ?? 0) > 0
|
2024-08-19 07:07:17 +02:00
|
|
|
}
|
2024-08-19 06:03:26 +02:00
|
|
|
|
2024-08-24 03:06:18 +02:00
|
|
|
init(attributes: [String : String]?) {
|
2024-08-19 06:03:26 +02:00
|
|
|
|
2024-08-27 04:27:30 +02:00
|
|
|
self.titleFromAttributes = attributes?.opml_title ?? attributes?.opml_text
|
2024-08-24 03:06:18 +02:00
|
|
|
self.attributes = attributes
|
2024-08-19 06:03:26 +02:00
|
|
|
|
2024-08-27 04:27:30 +02:00
|
|
|
if let feedURL = attributes?.opml_xmlUrl {
|
|
|
|
self.feedSpecifier = OPMLFeedSpecifier(title: self.titleFromAttributes, feedDescription: attributes?.opml_description, homePageURL: attributes?.opml_htmlUrl, feedURL: feedURL)
|
2024-08-27 07:39:46 +02:00
|
|
|
} else {
|
|
|
|
self.feedSpecifier = nil
|
2024-08-27 04:27:30 +02:00
|
|
|
}
|
2024-08-19 07:07:17 +02:00
|
|
|
}
|
|
|
|
|
2024-08-27 05:03:58 +02:00
|
|
|
func add(_ item: OPMLItem) {
|
2024-08-19 06:03:26 +02:00
|
|
|
|
2024-08-19 07:07:17 +02:00
|
|
|
if items == nil {
|
|
|
|
items = [OPMLItem]()
|
|
|
|
}
|
|
|
|
items?.append(item)
|
2024-08-19 06:03:26 +02:00
|
|
|
}
|
|
|
|
}
|