@pbvision/partner-sdk 0.1.8 → 0.1.10
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.
- package/README.md +8 -5
- package/package.json +1 -1
- package/src/index.js +5 -4
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ standard length game, so we'll notify your servers when the results are ready.
|
|
|
13
13
|
- [Option 1: PBV downloads your video from a URL](#option-1-pbv-downloads-your-video-from-a-url)
|
|
14
14
|
- [Option 2: Upload your video](#option-2-upload-your-video)
|
|
15
15
|
- [After Video Processing is Done](#after-video-processing-is-done)
|
|
16
|
+
- [Callback Data](#callback-data)
|
|
16
17
|
- [Video Guidelines](#video-guidelines)
|
|
17
18
|
- [Reference Guide](#reference-guide)
|
|
18
19
|
|
|
@@ -21,7 +22,9 @@ standard length game, so we'll notify your servers when the results are ready.
|
|
|
21
22
|
### Step 1: Get API Access
|
|
22
23
|
|
|
23
24
|
Email **[dev@pb.vision](mailto:dev@pb.vision)** to request API access for your
|
|
24
|
-
account.
|
|
25
|
+
account. Let us know which data you need access to (e.g. insights, stats) which
|
|
26
|
+
is documented below in the [Callback Data](#callback-data) section. We'll send
|
|
27
|
+
you an API Key after discussing your needs more in depth.
|
|
25
28
|
|
|
26
29
|
### Step 2: SDK Setup
|
|
27
30
|
|
|
@@ -60,7 +63,7 @@ curl -X POST \
|
|
|
60
63
|
-H 'x-api-key: YOUR_API_KEY' \
|
|
61
64
|
-H 'Content-Type: application/json' \
|
|
62
65
|
-d '{"url": "https://YOUR_WEBHOOK_URL"}' \
|
|
63
|
-
https://api-
|
|
66
|
+
https://api-2o2klzx4pa-uc.a.run.app/partner/webhook/set
|
|
64
67
|
```
|
|
65
68
|
|
|
66
69
|
### Send Videos
|
|
@@ -93,11 +96,9 @@ curl -X POST \
|
|
|
93
96
|
-H 'x-api-key: YOUR_API_KEY' \
|
|
94
97
|
-H 'Content-Type: application/json' \
|
|
95
98
|
-d '{"url": "https://YOUR_VIDEO_URL", "userEmails": ["test@example.com"]}' \
|
|
96
|
-
https://api-
|
|
99
|
+
https://api-2o2klzx4pa-uc.a.run.app/partner/add_video_by_url
|
|
97
100
|
```
|
|
98
101
|
|
|
99
|
-
To use the production server instead of the test server, change `ko3kowqi6a` to `2o2klzx4pa`.
|
|
100
|
-
|
|
101
102
|
#### Option 2: Upload your video
|
|
102
103
|
|
|
103
104
|
You can directly upload your video from a file using the SDK too:
|
|
@@ -145,6 +146,8 @@ data is enabled for your API key, only some of these fields may be present):
|
|
|
145
146
|
}
|
|
146
147
|
```
|
|
147
148
|
|
|
149
|
+
### Callback Data
|
|
150
|
+
|
|
148
151
|
- `from_url` is the video url you sent us in [step 3](#send-videos)
|
|
149
152
|
- `webpage` is a link to our web app where the stats can be explored
|
|
150
153
|
- `error` is only present if your video could not be processed
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -62,13 +62,13 @@ export class PBVision {
|
|
|
62
62
|
* @param {VideoMetadata} [metadata]
|
|
63
63
|
* @returns {VideoUrlToDownloadResponse}
|
|
64
64
|
*/
|
|
65
|
-
async sendVideoUrlToDownload (videoUrl, { userEmails = [], name, desc, gameStartEpoch, facility, court } = {}) {
|
|
65
|
+
async sendVideoUrlToDownload (videoUrl, { userEmails = [], name, desc, gameStartEpoch, facility, court, fid } = {}) {
|
|
66
66
|
assert(typeof videoUrl === 'string' && videoUrl.startsWith('http'),
|
|
67
67
|
'URL must be a string beginning with http')
|
|
68
68
|
assert(videoUrl.split('?')[0].endsWith('.mp4'), 'video URL must have the .mp4 extension')
|
|
69
69
|
const resp = await this.__callAPI(
|
|
70
70
|
'add_video_by_url',
|
|
71
|
-
{ url: videoUrl, userEmails, name, desc, gameStartEpoch, facility, court })
|
|
71
|
+
{ url: videoUrl, userEmails, name, desc, gameStartEpoch, facility, court, fid })
|
|
72
72
|
return JSON.parse(resp)
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -102,6 +102,7 @@ export class PBVision {
|
|
|
102
102
|
* @property {integer} [gameStartEpoch] the epoch at which the game started
|
|
103
103
|
* @property {string} [facility] the facility where the game was recorded (e.g., "Cool Club #3 - Barcelona")
|
|
104
104
|
* @property {string} [court] the court where the game was recorded (e.g., "11A")
|
|
105
|
+
* @property {integer} [fid] the ID of the folder in which this video should be added
|
|
105
106
|
*/
|
|
106
107
|
|
|
107
108
|
/**
|
|
@@ -114,10 +115,10 @@ export class PBVision {
|
|
|
114
115
|
* @param {VideoMetadata} [metadata]
|
|
115
116
|
* @returns {VideoUrlToDownloadResponse}
|
|
116
117
|
*/
|
|
117
|
-
async uploadVideo (mp4Filename, { userEmails = [], name, desc, gameStartEpoch, facility, court } = {}) {
|
|
118
|
+
async uploadVideo (mp4Filename, { userEmails = [], name, desc, gameStartEpoch, facility, court, fid } = {}) {
|
|
118
119
|
const pieces = mp4Filename.split('.')
|
|
119
120
|
const ext = pieces[pieces.length - 1]
|
|
120
|
-
const makeVIDResp = await this.__callAPI('make_video_id', { userEmails, name, desc, gameStartEpoch, facility, court, fileExt: ext })
|
|
121
|
+
const makeVIDResp = await this.__callAPI('make_video_id', { userEmails, name, desc, gameStartEpoch, facility, court, fid, fileExt: ext })
|
|
121
122
|
const { hasCredits, vid } = JSON.parse(makeVIDResp)
|
|
122
123
|
if (hasCredits === false) {
|
|
123
124
|
return { hasCredits }
|