@pbvision/partner-sdk 0.1.10 → 0.1.12
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 +23 -15
- package/package.json +1 -1
- package/src/index.js +24 -1
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ standard length game, so we'll notify your servers when the results are ready.
|
|
|
12
12
|
- [Send Videos](#send-videos)
|
|
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
|
+
- [Video Editors](#video-editors)
|
|
15
16
|
- [After Video Processing is Done](#after-video-processing-is-done)
|
|
16
17
|
- [Callback Data](#callback-data)
|
|
17
18
|
- [Video Guidelines](#video-guidelines)
|
|
@@ -21,10 +22,10 @@ standard length game, so we'll notify your servers when the results are ready.
|
|
|
21
22
|
|
|
22
23
|
### Step 1: Get API Access
|
|
23
24
|
|
|
24
|
-
Email **[
|
|
25
|
+
Email **[support@pb.vision](mailto:support@pb.vision)** to request API access for your
|
|
25
26
|
account. Let us know which data you need access to (e.g. insights, stats) which
|
|
26
27
|
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.
|
|
28
|
+
you an API Key after discussing your needs more in depth and laying out our billing options.
|
|
28
29
|
|
|
29
30
|
### Step 2: SDK Setup
|
|
30
31
|
|
|
@@ -78,12 +79,11 @@ Next, tell us to download and work on the video. You can do this using our SDK:
|
|
|
78
79
|
```javascript
|
|
79
80
|
import { PBVision } from '@pbvision/partner-sdk';
|
|
80
81
|
|
|
81
|
-
const pbv = new PBVision(YOUR_API_KEY);
|
|
82
|
+
const pbv = new PBVision(YOUR_API_KEY, { useProdServer: true });
|
|
82
83
|
// you can omit this metadata, or provide some or all of this object—whatever you'd like!
|
|
83
84
|
const optionalMetadata = {
|
|
84
|
-
userEmails: [],
|
|
85
|
-
name: 'Dink Championship
|
|
86
|
-
desc: 'A longer description, if you want',
|
|
85
|
+
userEmails: [], // these users will have the video in their PB Vision library
|
|
86
|
+
name: 'Dink Championship 2025',
|
|
87
87
|
gameStartEpoch: 1711393200, // when the game was played
|
|
88
88
|
};
|
|
89
89
|
await pbv.sendVideoUrlToDownload(YOUR_VIDEO_URL, optionalMetadata);
|
|
@@ -106,21 +106,31 @@ You can directly upload your video from a file using the SDK too:
|
|
|
106
106
|
```javascript
|
|
107
107
|
import { PBVision } from '@pbvision/partner-sdk';
|
|
108
108
|
|
|
109
|
-
const pbv = new PBVision(YOUR_API_KEY, { useProdServer:
|
|
109
|
+
const pbv = new PBVision(YOUR_API_KEY, { useProdServer: true });
|
|
110
110
|
// you can omit this metadata, or provide some or all of this object—whatever you'd like!
|
|
111
111
|
const optionalMetadata = {
|
|
112
|
-
userEmails: [],
|
|
113
|
-
name: 'Dink Championship
|
|
114
|
-
desc: 'A longer description, if you want',
|
|
112
|
+
userEmails: [], // these users will have the video in their PB Vision library
|
|
113
|
+
name: 'Dink Championship 2025',
|
|
115
114
|
gameStartEpoch: 1711393200, // when the game was played
|
|
116
115
|
};
|
|
117
116
|
await pbv.uploadVideo(YOUR_VIDEO_FILENAME, optionalMetadata);
|
|
118
117
|
```
|
|
119
118
|
|
|
119
|
+
### Video Editors
|
|
120
|
+
|
|
121
|
+
Editors can tag themselves and friends in the video. They also have access to
|
|
122
|
+
the video even if the video is private (to make videos uploaded by your partner
|
|
123
|
+
account private by default, please let us know via email).
|
|
124
|
+
|
|
125
|
+
You can get the current list of editors on a video by using the `getVideoEditors()`
|
|
126
|
+
method. Similarly, the `setVideoEditors()` method can be used to change the
|
|
127
|
+
email addresses which have editor access on your video.
|
|
128
|
+
|
|
120
129
|
## After Video Processing is Done
|
|
121
130
|
|
|
122
131
|
When our AI is done processing your video, we will email the players in the
|
|
123
|
-
game (_if_ their email addresses were provided via `userEmails`).
|
|
132
|
+
game (_if_ their email addresses were provided via `userEmails`). These users
|
|
133
|
+
will be "editors" on the video and be able to tag themselves and their friends.
|
|
124
134
|
|
|
125
135
|
If you [provided a webhook](#webhook-setup), then we'll send
|
|
126
136
|
an HTTP POST request to your server. Your server should acknowledge this
|
|
@@ -133,8 +143,7 @@ data is enabled for your API key, only some of these fields may be present):
|
|
|
133
143
|
```json
|
|
134
144
|
{
|
|
135
145
|
"from_url": "https://example.com/my-video.mp4",
|
|
136
|
-
"webpage": "https://pb.vision/video/
|
|
137
|
-
"cutVideo": "https://storage.googleapis.com/pbv-pro/xyz/f50272db-69a8-49ed-9d92-3a4d067af87c/rallies.mp4",
|
|
146
|
+
"webpage": "https://pb.vision/video/83gyqyc10y8f",
|
|
138
147
|
"cv": CV_DATA,
|
|
139
148
|
"insights": INSIGHTS_DATA,
|
|
140
149
|
"stats": STATS_DATA,
|
|
@@ -158,7 +167,6 @@ data is enabled for your API key, only some of these fields may be present):
|
|
|
158
167
|
- `stats` various stats about the game for advanced players
|
|
159
168
|
- Explore the _stats_ schema at <https://pbv-public.github.io/stats?s=~stats~game>
|
|
160
169
|
- Schema changes and diffs are in our [`pbv-public/stats` repo](https://github.com/pbv-public/stats/blob/dev/CHANGELOG.md)
|
|
161
|
-
- `cutVideo` contains a link to the rally-sliced (dead time removed) .mp4.
|
|
162
170
|
- only included if `insights` is included:
|
|
163
171
|
- `vid` - the unique ID of the video in our system
|
|
164
172
|
- `aiEngineVersion` - the version number of our AI used to process the video
|
|
@@ -179,7 +187,7 @@ For best results, we also recommend:
|
|
|
179
187
|
- Audio Encoding: MPEG-4 AAC
|
|
180
188
|
- Resolution: 1080p
|
|
181
189
|
- Frame Rate: 30 FPS
|
|
182
|
-
- Max Bitrate:
|
|
190
|
+
- Max Bitrate: 4 Mbps
|
|
183
191
|
- Max File Size: 2GB
|
|
184
192
|
|
|
185
193
|
## Reference Guide
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -47,6 +47,28 @@ export class PBVision {
|
|
|
47
47
|
return this.__callAPI('webhook/set', { url: webhookUrl })
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Gets the email addresses (if any) which have editor access to a video your
|
|
52
|
+
* partner account uploaded.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} vid video id
|
|
55
|
+
*/
|
|
56
|
+
async getVideoEditors (vid) {
|
|
57
|
+
return this.__callAPI('video/editors/get', { vid })
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Sets the email addresses (if any) which have editor access to a video your
|
|
62
|
+
* partner account uploaded.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} vid video id
|
|
65
|
+
* @param {Array<string>} editorEmails a list of 0 to 4 email addresses to
|
|
66
|
+
* allow edit access to the video (replaces any previous editors list).
|
|
67
|
+
*/
|
|
68
|
+
async setVideoEditors (vid, editorEmails) {
|
|
69
|
+
return this.__callAPI('video/editors/set', { vid, editorEmails })
|
|
70
|
+
}
|
|
71
|
+
|
|
50
72
|
/**
|
|
51
73
|
* @typedef {Object} VideoUrlToDownloadResponse
|
|
52
74
|
* @property {string} vid the ID of the new video
|
|
@@ -118,7 +140,8 @@ export class PBVision {
|
|
|
118
140
|
async uploadVideo (mp4Filename, { userEmails = [], name, desc, gameStartEpoch, facility, court, fid } = {}) {
|
|
119
141
|
const pieces = mp4Filename.split('.')
|
|
120
142
|
const ext = pieces[pieces.length - 1]
|
|
121
|
-
const
|
|
143
|
+
const platform = { name: 'api', version: '0.1.12' }
|
|
144
|
+
const makeVIDResp = await this.__callAPI('make_video_id', { platform, userEmails, name, desc, gameStartEpoch, facility, court, fid, fileExt: ext })
|
|
122
145
|
const { hasCredits, vid } = JSON.parse(makeVIDResp)
|
|
123
146
|
if (hasCredits === false) {
|
|
124
147
|
return { hasCredits }
|