Skip to content

Commit 30f6165

Browse files
authored
Rumble - New Live Stream (#16285)
* new-live-stream * pnpm-lock.yaml
1 parent 696d83f commit 30f6165

File tree

5 files changed

+114
-5
lines changed

5 files changed

+114
-5
lines changed

components/rumble/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/rumble",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Rumble Components",
55
"main": "rumble.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
1518
}

components/rumble/rumble.app.mjs

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "rumble",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
_baseUrl() {
9+
return "https://rumble.com/-livestream-api";
10+
},
11+
_makeRequest({
12+
$ = this,
13+
path,
14+
params = {},
15+
...opts
16+
}) {
17+
return axios($, {
18+
url: `${this._baseUrl()}${path}`,
19+
params: {
20+
...params,
21+
key: this.$auth.live_streaming_api_key,
22+
},
23+
...opts,
24+
});
25+
},
26+
getData(opts = {}) {
27+
return this._makeRequest({
28+
path: "/get-data",
29+
...opts,
30+
});
931
},
1032
},
1133
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import rumble from "../../rumble.app.mjs";
2+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3+
import sampleEmit from "./test-event.mjs";
4+
5+
export default {
6+
key: "rumble-new-live-stream",
7+
name: "New Live Stream",
8+
description: "Emit new event when a livestream becomes live in Rumble. [See the documentation](https://rumblefaq.groovehq.com/help/how-to-use-rumble-s-live-stream-api)",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
props: {
13+
rumble,
14+
db: "$.service.db",
15+
timer: {
16+
type: "$.interface.timer",
17+
default: {
18+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
19+
},
20+
},
21+
},
22+
methods: {
23+
_getLastTs() {
24+
return this.db.get("lastTs") || 0;
25+
},
26+
_setLastTs(lastTs) {
27+
this.db.set("lastTs", lastTs);
28+
},
29+
generateMeta(livestream) {
30+
return {
31+
id: livestream.id,
32+
summary: `${livestream.title} is live`,
33+
ts: Date.parse(livestream.created_on),
34+
};
35+
},
36+
},
37+
async run() {
38+
const lastTs = this._getLastTs();
39+
let maxTs = lastTs;
40+
41+
const { livestreams } = await this.rumble.getData();
42+
43+
for (const livestream of livestreams) {
44+
const ts = Date.parse(livestream.created_on);
45+
if (livestream?.is_live && ts > lastTs) {
46+
const meta = this.generateMeta(livestream);
47+
this.$emit(livestream, meta);
48+
maxTs = Math.max(ts, maxTs);
49+
}
50+
}
51+
52+
this._setLastTs(maxTs);
53+
},
54+
sampleEmit,
55+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export default {
2+
"id": "6pw8hx",
3+
"title": "Livestream",
4+
"created_on": "2025-04-14T17:07:27+00:00",
5+
"is_live": true,
6+
"visibility": "unlisted",
7+
"categories": {
8+
"primary": {
9+
"slug": "technology",
10+
"title": "Technology"
11+
},
12+
"secondary": null
13+
},
14+
"server_url": "",
15+
"stream_key": "",
16+
"likes": 0,
17+
"dislikes": 0,
18+
"watching_now": 0,
19+
"chat": {
20+
"latest_message": null,
21+
"recent_messages": [],
22+
"latest_rant": null,
23+
"recent_rants": []
24+
}
25+
}

pnpm-lock.yaml

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)