-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreams_setup.cpp
More file actions
34 lines (29 loc) · 964 Bytes
/
streams_setup.cpp
File metadata and controls
34 lines (29 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: MIT
// One-shot setup: register a callback URL, subscribe to a stream, list
// what's running.
//
// AUDD_API_TOKEN=your-token ./streams_setup https://your.app/audd-callback
#include <iostream>
#include <audd/audd.hpp>
int main(int argc, char** argv) {
if (argc < 2) {
std::cerr << "usage: " << argv[0] << " <callback-url>\n";
return 2;
}
audd::AudD client(""); // pulls AUDD_API_TOKEN
try {
client.streams().set_callback_url(argv[1]);
audd::AddStreamRequest req;
req.url = "twitch:somechannel";
req.radio_id = 1;
client.streams().add(req);
for (const auto& s : client.streams().list()) {
std::cout << s.radio_id << " " << s.url
<< " running=" << s.stream_running << "\n";
}
} catch (const audd::AudDError& e) {
std::cerr << "audd: " << e.what() << "\n";
return 1;
}
return 0;
}