@cliff-studio/sanity-plugin-bunny-input 1.0.8 → 1.1.0
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/dist/_chunks-es/index.js +2 -2
- package/dist/_chunks-es/index.js.map +1 -1
- package/package.json +2 -2
- package/src/api.js +7 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cliff-studio/sanity-plugin-bunny-input",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Sanity Studio plugin for uploading videos to Bunny Stream",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Cliff Studio",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"prepublishOnly": "npm run build"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"sanity": "^3.0.0 || ^5.0.0",
|
|
31
|
+
"sanity": "^3.0.0 || ^5.0.0 || ^6.0.0",
|
|
32
32
|
"react": "^18.0.0 || ^19.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
package/src/api.js
CHANGED
|
@@ -45,13 +45,15 @@ export function getPlaybackUrl(cdnHostname, videoId) {
|
|
|
45
45
|
* Get the direct MP4 URL (if available)
|
|
46
46
|
* @param {string} cdnHostname - The CDN hostname (e.g., 'vz-fbd37838-a6a.b-cdn.net')
|
|
47
47
|
* @param {string} videoId
|
|
48
|
-
* @param {
|
|
48
|
+
* @param {string} availableResolutions - Comma-separated string (e.g. "360p,480p,240p")
|
|
49
49
|
* @returns {string}
|
|
50
50
|
*/
|
|
51
|
-
export function getMp4Url(cdnHostname, videoId, availableResolutions =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.
|
|
51
|
+
export function getMp4Url(cdnHostname, videoId, availableResolutions = '') {
|
|
52
|
+
// Parse to numbers so we can pick the highest; URL format requires "480p" etc.
|
|
53
|
+
const parsedResolutions = (availableResolutions || '')
|
|
54
|
+
.split(',')
|
|
55
|
+
.map((s) => Number.parseInt(String(s.trim()).replace(/p$/i, ''), 10))
|
|
56
|
+
.filter((n) => Number.isFinite(n))
|
|
55
57
|
|
|
56
58
|
const bestResolution = parsedResolutions.length ? Math.max(...parsedResolutions) : 720
|
|
57
59
|
return `https://${cdnHostname}/${videoId}/play_${bestResolution}p.mp4`
|