Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

jkbz64/TwitchQt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TwitchQt

The project is discontinued and publicly archived, work has been continued in this fork.

A simple Header-only Qt wrapper for the new Twitch.tv api(Helix) written using Qt5. It also supports TwitchEmotes, BTTV and FFZ.

Requirements

Qt5

  • Core
  • Network

C++11 compatible compiler

Usage

QMake

Clone this library wherever you want and just include(path/to/TwitchQt.pri) in your .pro file.

CMake

include(FetchContent)
...
FetchContent_Declare(
    TwitchQt
    GIT_REPOSITORY "https://github.com/jkbz64/TwitchQt"
    GIT_TAG "commit hash"
    )
FetchContent_MakeAvailable(TwitchQt)

Or clone the repo in your project and add add_subdirectory(path/to/TwitchQt) in your CMakeLists.txt.

Example

#include <QCoreApplication>
#include <TwitchQt/Twitch>

int main(int argc, char* argv[])
{
    QCoreApplication a(argc, argv);
    
    // Twitch::Api is aliased to New Twitch Api (Helix)
    Twitch::Api api("CLIENT-ID HERE");
    api.setBearerToken("BEARER-TOKEN HERE");

    // Note: For this endpoint stream has to be online to return the data! 
    auto reply = api.getStreamByName("forsen");
    a.connect(reply, &Twitch::Reply::finished, [&a, reply]() {
        if (reply->currentState() == Twitch::ReplyState::Success) {
            // Convert reply data to Stream struct
            auto stream = reply->data().value<Twitch::Stream>();
            qDebug() << stream.m_title; // Print title
            qDebug() << stream.m_viewerCount; // Print viewer count as int
            qDebug() << stream.m_startedAt.date(); // Print date
        }
        // Quit program after receiving reply
        a.quit();
    });

    a.exec();

    return 0;
}

Features

Look at the twitchapi.hpp file :)

Releases

No releases published

Packages

No packages published

Languages