Giter VIP home page Giter VIP logo

feedkit's Introduction

FeedKit

An RSS, Atom and JSON Feed parser written in Swift

build status cocoapods compatible carthage compatible language release

Features

Requirements

xcode ios tvos watchos mac os mac os

Installation >> instructions <<

Usage

Build a URL pointing to an RSS, Atom or JSON Feed.

let feedURL = URL(string: "http://images.apple.com/main/rss/hotnews/hotnews.rss")!

FeedKit will do asynchronous parsing on the main queue by default. You can safely update your UI from within the result closure.

FeedParser(URL: feedURL)?.parseAsync { result in
    
    switch result {
    case let .atom(feed):       break
    case let .rss(feed):        break
    case let .json(feed):       break
    case let .failure(error):   break
    }

}

If a different queue is specified, you are responsible to manually bring the result closure to whichever queue is apropriate. Usually DispatchQueue.main.async. If you're unsure, don't provide the queue parameter.

FeedParser(URL: feedURL)?.parseAsync(queue: myQueue, result: { (result) in 
    // Do your thing
})

Alternatively, you can also parse synchronously.

FeedParser(URL: feedURL)?.parse()

Initializers

An aditional initializer can be found for Data objects.

FeedParser(data: data)

Feed Models

FeedKit provides strongly typed models for RSS, Atom and JSON Feed formats.

result.rssFeed      // Really Simple Syndication Feed Model
result.atomFeed     // Atom Syndication Format Feed Model
result.jsonFeed     // JSON Feed Model

Parsing Success

You can check if a Feed was successfully parsed or not.

result.isSuccess    // If parsing was a success
result.isFailure    // If parsing failed
result.error        // An error, if any

Model Preview

Safely bind a feed of your choosing:

guard let feed = result.rssFeed, result.isSuccess else {
    print(result.error)
    return
}

Then go through it's properties. The RSS, Atom and JSON Feed Models are rather extensive. These are just a preview.

RSS

feed.title
feed.link
feed.description
feed.language
feed.copyright
feed.managingEditor
feed.webMaster
feed.pubDate
feed.lastBuildDate
feed.categories
feed.generator
feed.docs
feed.cloud
feed.rating
feed.ttl
feed.image
feed.textInput
feed.skipHours
feed.skipDays
//...
feed.dublinCore
feed.syndication
feed.iTunes
// ...

let item = feed.items?.first

item?.title
item?.link
item?.description
item?.author
item?.categories
item?.comments
item?.enclosure
item?.guid
item?.pubDate
item?.source
//...
item?.dublinCore
item?.content
item?.iTunes
item?.media
// ...

Refer to the documentation for the complete model properties and description

Atom

feed.title
feed.subtitle
feed.links
feed.updated
feed.authors
feed.contributors
feed.id
feed.generator
feed.icon
feed.logo
feed.rights
// ...

let entry = feed.entries?.first

entry?.title
entry?.summary
entry?.authors
entry?.contributors
entry?.links
entry?.updated
entry?.categories
entry?.id
entry?.content
entry?.published
entry?.source
entry?.rights
// ...

Refer to the documentation for the complete model properties and description

JSON

feed.version
feed.title
feed.homePageURL
feed.feedUrl
feed.description
feed.userComment
feed.nextUrl
feed.icon
feed.favicon
feed.author
feed.expired
feed.hubs
feed.extensions
// ...

let item = feed.items?.first

item?.id
item?.url
item?.externalUrl
item?.title
item?.contentText
item?.contentHtml
item?.summary
item?.image
item?.bannerImage
item?.datePublished
item?.dateModified
item?.author
item?.url
item?.tags
item?.attachments
item?.extensions
// ...

Refer to the documentation for the complete model properties and description

License

FeedKit is released under the MIT license. See LICENSE for details.

feedkit's People

Contributors

nmdias avatar bamurph avatar udoysoumik avatar brettohland avatar

Watchers

James Cloos avatar

Forkers

tymphillips

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.