@eluvio/elv-client-js 3.1.77 → 3.1.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,136 +0,0 @@
1
- // convert an offering to a just-started VoD-as-Live item
2
-
3
- const Utility = require("./lib/Utility");
4
-
5
- const {NewOpt} = require("./lib/options");
6
-
7
- const Client = require("./lib/concerns/Client");
8
- const ExistObjOrVer = require("./lib/concerns/ExistObjOrVer");
9
-
10
-
11
- class ChannelGetLiveUrls extends Utility {
12
- blueprint() {
13
- return {
14
- concerns: [Client, ExistObjOrVer],
15
- options: [
16
- NewOpt("offeringKey",
17
- {
18
- default: "default",
19
- descTemplate: "Which offering within channel to get URLs for",
20
- type: "string"
21
- })
22
- ]
23
- };
24
- }
25
-
26
- async body() {
27
- const logger = this.logger;
28
-
29
- // operations that need to wait on network access
30
- // ----------------------------------------------------
31
- const {libraryId, objectId, versionHash, offeringKey} = await this.concerns.ExistObjOrVer.argsProc();
32
-
33
- const offerings = await this.concerns.ExistObjOrVer.metadata({subtree:"/channel/offerings"});
34
- if(!offerings) {
35
- throw Error("No offerings found in channel");
36
- }
37
-
38
- if(!offerings[offeringKey]) {
39
- throw Error(`Offering '${offeringKey}' not found in channel`);
40
- }
41
-
42
- const client = await this.concerns.Client.get();
43
- const url = await client.FabricUrl({
44
- libraryId,
45
- objectId,
46
- versionHash,
47
- rep: "channel/options.json"
48
- });
49
-
50
- logger.data("version_hash", versionHash);
51
- logger.data("options_url", url);
52
-
53
- logger.log();
54
- logger.log(`Version hash: ${versionHash}`);
55
- logger.log();
56
- logger.log("Channel options.json URL:");
57
- logger.log();
58
- logger.log(url);
59
-
60
- const offeringUrl = await client.FabricUrl({
61
- libraryId,
62
- objectId,
63
- versionHash,
64
- rep: `channel/${offeringKey}/options.json`
65
- });
66
- logger.log();
67
- logger.log(`Offering '${offeringKey}' options.json URL:`);
68
- logger.log();
69
- logger.log(offeringUrl);
70
-
71
- // NOTE: although following line calls ElvClient.AvailableOfferings(), it is not actually
72
- // retrieving available offerings, it is retrieving all available playback formats for channel offering
73
- // (due to handler setting)
74
- const offeringOptions = await client.AvailableOfferings({
75
- libraryId,
76
- objectId,
77
- versionHash,
78
- handler: `channel/${offeringKey}`
79
- });
80
-
81
- let offUrlObj = new URL(offeringUrl);
82
- const urlBase = offUrlObj.origin + offUrlObj.pathname;
83
- const authToken = offUrlObj.searchParams.get("authorization");
84
- let sid = "";
85
- for(const [playoutFormatKey, playoutFormatInfo] of Object.entries(offeringOptions)) {
86
- const pfUrlObj = new URL(playoutFormatInfo.uri, urlBase);
87
- sid = pfUrlObj.searchParams.get("sid");
88
- const playoutUrl = new URL(playoutFormatInfo.uri, urlBase);
89
- playoutUrl.searchParams.set("authorization", authToken);
90
- playoutUrl.searchParams.set("sid", sid);
91
-
92
- logger.log();
93
- logger.log(`Sample playout URL for format '${playoutFormatKey}':`);
94
- logger.log();
95
- logger.log(playoutUrl.toString());
96
- }
97
-
98
- const viewsUrl = await client.FabricUrl({
99
- libraryId,
100
- objectId,
101
- versionHash,
102
- rep: `channel/${offeringKey}/views.json`
103
- });
104
- const viewsUrlObj = new URL(viewsUrl);
105
- viewsUrlObj.searchParams.set("sid", sid);
106
- logger.log();
107
- logger.log(`Sample offering '${offeringKey}' current available views URL (sid must be same as in playout URL):`);
108
- logger.log();
109
- logger.log(viewsUrlObj.toString());
110
-
111
-
112
- const selectViewUrl = await client.FabricUrl({
113
- libraryId,
114
- objectId,
115
- versionHash,
116
- rep: `channel/${offeringKey}/select_view`
117
- });
118
- const viewSelectUrlObj = new URL(selectViewUrl);
119
- viewSelectUrlObj.searchParams.set("sid", sid);
120
-
121
- logger.log();
122
- logger.log("Sample curl command to select view (sid must be same as in playout URL):");
123
- logger.log();
124
- logger.log(`curl -X POST '${viewSelectUrlObj.toString()}' -d '{"view":1}'`);
125
- }
126
-
127
- header() {
128
- return `Start playout of 'live' channel object ${this.args.objectId}${this.args.delay ? ` with ${this.args.delay} second(s) delay` : ""}`;
129
- }
130
- }
131
-
132
- if(require.main === module) {
133
- Utility.cmdLineInvoke(ChannelGetLiveUrls);
134
- } else {
135
- module.exports = ChannelGetLiveUrls;
136
- }