Git Product home page Git Product logo

vntrssreader's Introduction

VNTRSSReader

License

This is a C++ library built on top of Qt, which allows you to consume RSS feeds, licensed under the GPL v2 terms. It is used in the SpeedReader application. If you have any ideas on how to improve the library or its code, simply write an email to me or fork the library. If you have any problems or you have found any issues or bugs, feel free to report them.

Features

  • RSS v0.91, v1.0 and v2.0 are supported
  • ATOM v1.0 is supported
  • supports redirect urls
  • nearly every attribute of the channel and entry / item object's are available through the library
  • pubDate will be parsed conveniently into QDateTime
  • option to automatically download the images and provide them for the library user
  • variety of unit tests

Further plans

  • let me know if you have any

Sample Code

If the things below are not enough information, you can have a look at the Unit Tests to get a deeper understanding.

Class.h

#include <QObject>

#include "vntrssreader.h"
#include "vntrsschannel.h"

class RSS : public QObject {
    Q_OBJECT

public slots:
    void loadedRSS(QList<VNTRSSChannel*> rssChannels);

public:
    explicit Class(QObject *parent = 0);
    ~Class();

    void loadRSS(const QUrl &url);
    void loadRSS(const QList<QUrl> &urls);

private:
    VNTRSSReader* mRSSReader;
};

Class.cpp

#include "class.h"

#include <QDebug>

Class::Class(QObject *parent) : QObject(parent) {
    mRSSReader = new VNTRSSReader();
    QObject::connect(mRSSReader, SIGNAL(loadedRSS(QList<VNTRSSChannel*>)), this, SLOT(loadedRSS(QList<VNTRSSChannel*>)));

    // Use this if you don't want to use a proxy
    QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);

    // Use this if you do want to use a specific proxy
    QNetworkProxy proxy;
    proxy.setType(QNetworkProxy::HttpProxy);
    proxy.setHostName("proxy.example.com");
    proxy.setPort(1080);
    proxy.setUser("username");
    proxy.setPassword("password");
    QNetworkProxy::setApplicationProxy(proxy);

    // Use this if you want Qt to do the work and figure the proxy out
    QNetworkProxyFactory::setUseSystemConfiguration(true);
}

Class::~Class() {
    delete mRSSReader;
}

void Class::loadRSS(const QUrl &url) {
    mRSSReader->load(url);  // will automatically download the images. pass false as a second argument if you don't want that
}

void Class::loadRSS(const QList<QUrl> &urls) {
    mRSSReader->load(urls); // will automatically download the images. pass false as a second argument if you don't want that
}

void Class::loadedRSS(QList<VNTRSSChannel*> rssChannels) {
    for (VNTRSSChannel* rssChannel : rssChannels) {
        if (!rssChannel->hasError()) {
            QList<VNTRSSItem*> items = rssChannel->getRSSItems();

            for (VNTRSSItem* item : items) {
                qDebug() << item->toString();
            }
        } else {
            qDebug() << rssChannel->getErrorMessage();
        }

        delete rssChannel;
    }
}

License

GPL v2

For more information see the LICENSE file.

Copyright 2014-2015 Vanniktech - Niklas Baudy

vntrssreader's People

Contributors

vanniktech avatar

Watchers

Kurt-0x99b8f2 avatar

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.