Skip to content

Commit

Permalink
Updated Livepeer package
Browse files Browse the repository at this point in the history
  • Loading branch information
xannyxs committed Dec 19, 2024
1 parent 25ddeae commit 9104894
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 105 deletions.
62 changes: 31 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"name": "streameth-platform",
"version": "1.0.0",
"private": true,
"workspaces": {
"packages": [
"packages/app",
"packages/server",
"packages/contracts",
"packages/video-uploader"
]
},
"scripts": {
"build": "yarn workspace @streameth/streameth-app build",
"dev": "yarn workspace @streameth/streameth-app dev",
"start": "yarn workspace @streameth/streameth-app start",
"next:lint": "yarn workspace @streameth/streameth-app lint",
"next:check-types": "yarn workspace @streameth/streameth-app check-types",
"prettier:fix": "yarn workspace @streameth/streameth-app prettier:fix && yarn workspace streameth-new-server prettier:fix",
"prettier:check": "yarn workspace @streameth/streameth-app prettier:check && yarn workspace streameth-new-server prettier:check",
"precommit": "lint-staged --verbose",
"install:all": "yarn --cwd @streameth/server/ && yarn",
"build:server": "yarn workspace streameth-new-server build",
"start:server": "yarn workspace streameth-new-server start",
"prepare": "husky"
},
"devDependencies": {
"husky": "^9",
"lint-staged": "^15.2.7",
"prettier": "^3",
"prettier-plugin-tailwindcss": "^0.6.5"
}
"name": "streameth-platform",
"version": "1.0.0",
"private": true,
"workspaces": {
"packages": [
"packages/app",
"packages/server",
"packages/contracts",
"packages/video-uploader"
]
},
"scripts": {
"build": "yarn workspace @streameth/streameth-app build",
"dev": "yarn workspace @streameth/streameth-app dev",
"start": "yarn workspace @streameth/streameth-app start",
"next:lint": "yarn workspace @streameth/streameth-app lint",
"next:check-types": "yarn workspace @streameth/streameth-app check-types",
"prettier:fix": "yarn workspace @streameth/streameth-app prettier:fix && yarn workspace streameth-new-server prettier:fix",
"prettier:check": "yarn workspace @streameth/streameth-app prettier:check && yarn workspace streameth-new-server prettier:check",
"precommit": "lint-staged --verbose",
"install:all": "yarn --cwd @streameth/server/ && yarn",
"build:server": "yarn workspace streameth-new-server build",
"start:server": "yarn workspace streameth-new-server start",
"prepare": "husky"
},
"devDependencies": {
"husky": "^9",
"lint-staged": "^15.2.7",
"prettier": "^3",
"prettier-plugin-tailwindcss": "^0.6.5"
}
}
1 change: 0 additions & 1 deletion packages/app/lib/actions/stages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export const createMultistreamAction = async (
name,
targetURL: url,
targetStreamKey: streamKey,

organizationId,
});
revalidatePath('/studio');
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"http-proxy-middleware": "^3.0.3",
"joi": "^17.12.2",
"jsonwebtoken": "^9.0.2",
"livepeer": "3.0.2",
"livepeer": "3.5.0",
"mongoose": "7.6.2",
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
Expand Down
40 changes: 27 additions & 13 deletions packages/server/src/utils/livepeer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import State from '@models/state.model';
import SessionService from '@services/session.service';
import StateService from '@services/state.service';
import { Livepeer } from 'livepeer';
import { Session, Stream } from 'livepeer/dist/models/components';
import fetch from 'node-fetch';
import youtubedl from 'youtube-dl-exec';
import { createEventVideoById } from './firebase';
Expand All @@ -22,6 +21,8 @@ import { refreshAccessToken } from './oauth';
import pulse from './pulse.cron';
import { fetchAndParseVTT, getSourceType } from './util';
import { deleteYoutubeLiveStream } from './youtube';
import { Stream, Session } from 'livepeer/models/components';

const { host, secretKey } = config.livepeer;
const livepeer = new Livepeer({
apiKey: secretKey,
Expand Down Expand Up @@ -276,28 +277,41 @@ export const getStreamRecordings = async (streamId: string): Promise<any> => {

export const createMultiStream = async (data: IMultiStream): Promise<void> => {
try {
const response = await livepeer.stream.createMultistreamTarget(
data.streamId,
const response = await fetch(
`https://livepeer.studio/api/stream/${data.streamId}/create-multistream-target`,
{
spec: {
name: data.name,
url: data.targetURL + '/' + data.targetStreamKey,
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.LIVEPEER_API_KEY}`,
'Content-Type': 'application/json',
},
profile: 'source',
body: JSON.stringify({
profile: 'source',
spec: {
name: data.name,
url: data.targetURL + '/' + data.targetStreamKey,
},
}),
},
);
const multistream = JSON.parse(response.rawResponse.data.toString());

if (!response.ok) {
throw new HttpException(response.status, 'Error creating multistream');
}

const multistream = await response.json();

console.log(multistream);

const stage = await Stage.findOne({
'streamSettings.streamId': data.streamId,
});

await stage.updateOne({
$push: {
'streamSettings.targets': {
id: multistream.id,
name: multistream.name,
socialId: data.socialId ?? '',
socialType: data.socialType ?? '',
broadcastId: data.broadcastId ?? '',
},
},
});
Expand Down Expand Up @@ -379,8 +393,8 @@ export const getSessionMetrics = async (
playbackId: string,
): Promise<{ viewCount: number; playTimeMins: number }> => {
try {
const metrics = await livepeer.metrics.getPublicTotalViews(playbackId);
if (!metrics.object) {
const metrics = await livepeer.metrics.getPublicViewership(playbackId);
if (!metrics.rawResponse.ok) {
return {
viewCount: 0,
playTimeMins: 0,
Expand Down
73 changes: 14 additions & 59 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7052,7 +7052,7 @@ axe-core@^4.9.1:
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.9.1.tgz#fcd0f4496dad09e0c899b44f6c4bb7848da912ae"
integrity sha512-QbUdXJVTpvUTHU7871ppZkdOLBeGUKBQWHkHrvN2V9IQWGMt61zf3B45BtzjxEJzYuj0JBjBZP/hmYS/R9pmAw==

axios@^1.1.3, axios@^1.5.1:
axios@^1.5.1:
version "1.7.4"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.4.tgz#4c8ded1b43683c8dd362973c393f3ede24052aa2"
integrity sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==
Expand Down Expand Up @@ -9584,18 +9584,6 @@ [email protected]:
optionalDependencies:
source-map "~0.2.0"

escodegen@^1.8.1:
version "1.14.3"
resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.14.3.tgz#4e7b81fba61581dc97582ed78cab7f0e8d63f503"
integrity sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==
dependencies:
esprima "^4.0.1"
estraverse "^4.2.0"
esutils "^2.0.2"
optionator "^0.8.1"
optionalDependencies:
source-map "~0.6.1"

escodegen@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-2.1.0.tgz#ba93bbb7a43986d29d6041f99f5262da773e2e17"
Expand Down Expand Up @@ -9800,11 +9788,6 @@ espree@^9.6.0, espree@^9.6.1:
acorn-jsx "^5.3.2"
eslint-visitor-keys "^3.4.1"

[email protected]:
version "1.2.2"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-1.2.2.tgz#76a0fd66fcfe154fd292667dc264019750b1657b"
integrity sha512-+JpPZam9w5DuJ3Q67SqsMGtiHKENSMRVoxvArfJZK01/BfLEObtZ6orJa/MtoGNR/rfMgp5837T41PAmTwAv/A==

[email protected], esprima@^2.7.1:
version "2.7.3"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581"
Expand Down Expand Up @@ -9834,11 +9817,6 @@ estraverse@^1.9.1:
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44"
integrity sha512-25w1fMXQrGdoquWnScXZGckOv+Wes+JDnuN/+7ex3SauFRS72r2lFDec0EKPt2YD1wUJ/IrfEex+9yp4hfSOJA==

estraverse@^4.2.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d"
integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==

estraverse@^5.1.0, estraverse@^5.2.0, estraverse@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123"
Expand Down Expand Up @@ -13052,15 +13030,6 @@ jsonp@^0.2.1:
dependencies:
debug "^2.1.3"

jsonpath@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/jsonpath/-/jsonpath-1.1.1.tgz#0ca1ed8fb65bb3309248cc9d5466d12d5b0b9901"
integrity sha512-l6Cg7jRpixfbgoWgkrl77dgEj8RPvND0wMH6TwQmi9Qs4TFfS9u5cUFnbeKTwj5ga5Y3BTGGNI28k117LJ009w==
dependencies:
esprima "1.2.2"
static-eval "2.0.2"
underscore "1.12.1"

jsonschema@^1.2.4:
version "1.4.1"
resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.4.1.tgz#cc4c3f0077fb4542982973d8a083b6b34f482dab"
Expand Down Expand Up @@ -13357,16 +13326,14 @@ [email protected], lit@^2.2.3:
lit-element "^3.3.0"
lit-html "^2.8.0"

livepeer@3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/livepeer/-/livepeer-3.0.2.tgz#169daf9651db29c20ff387a0693884e245142c10"
integrity sha512-+PiM4BKLFYK2JAO16rZPdrTUq5PF40KP7vztq44OafwLR3ousawqOm+Kr4/+V4WoCXdhve5BU/atyTRrcjvHvA==
livepeer@3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/livepeer/-/livepeer-3.5.0.tgz#703ed1121063dbb08a2f8e8aa2af884dc197013a"
integrity sha512-SfvrnAFneQMhF2iSONGfvg1uutw7x2+QPh6UZvp1FVDBVBDEYTMTTrEG/xYYbAn66DoYeP7q049Wdjim77vfog==
dependencies:
axios "^1.1.3"
class-transformer "^0.5.1"
form-data "^4.0.0"
jsonpath "^1.1.1"
reflect-metadata "^0.1.13"
jest "^29.7.0"
jest-junit "^16.0.0"
ts-jest "^29.1.4"

livepeer@^3.4.0:
version "3.4.0"
Expand Down Expand Up @@ -14757,7 +14724,12 @@ n-gram@^2.0.0:
resolved "https://registry.yarnpkg.com/n-gram/-/n-gram-2.0.2.tgz#e544a7dffefc49c22d898b2f491e787941b3a2ba"
integrity sha512-S24aGsn+HLBxUGVAUFOwGpKs7LBcG4RudKU//eWzt/mQ97/NMKQxDWHyHx63UNWk/OOdihgmzoETn1tf5nQDzQ==

[email protected], nanoid@^3.3.6, nanoid@^3.3.7:
[email protected]:
version "3.3.8"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.8.tgz#b1be3030bee36aaff18bacb375e5cce521684baf"
integrity sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==

nanoid@^3.3.6, nanoid@^3.3.7:
version "3.3.7"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8"
integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==
Expand Down Expand Up @@ -16622,11 +16594,6 @@ reduce-flatten@^2.0.0:
resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27"
integrity sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==

reflect-metadata@^0.1.13:
version "0.1.14"
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.14.tgz#24cf721fe60677146bb77eeb0e1f9dece3d65859"
integrity sha512-ZhYeb6nRaXCfhnndflDK8qI6ZQ/YcWZCISRAWICW9XYqMUwjZM9Z0DveWX/ABN01oxSHwVxKQmxeYZSsm0jh5A==

reflect-metadata@^0.2.1:
version "0.2.2"
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.2.2.tgz#400c845b6cba87a21f2c65c4aeb158f4fa4d9c5b"
Expand Down Expand Up @@ -17680,13 +17647,6 @@ stacktrace-parser@^0.1.10:
dependencies:
type-fest "^0.7.1"

[email protected]:
version "2.0.2"
resolved "https://registry.yarnpkg.com/static-eval/-/static-eval-2.0.2.tgz#2d1759306b1befa688938454c546b7871f806a42"
integrity sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==
dependencies:
escodegen "^1.8.1"

[email protected]:
version "2.0.1"
resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63"
Expand Down Expand Up @@ -18937,11 +18897,6 @@ undefsafe@^2.0.5:
resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c"
integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==

[email protected]:
version "1.12.1"
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.12.1.tgz#7bb8cc9b3d397e201cf8553336d262544ead829e"
integrity sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==

undici-types@~5.26.4:
version "5.26.5"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
Expand Down

0 comments on commit 9104894

Please sign in to comment.