Skip to content

Commit

Permalink
Video lexicons and appview views (#2751)
Browse files Browse the repository at this point in the history
* lexicon: initial lexicons for video embeds in bsky app

* lexicon: fix video caption file size limit

* codegen

* appview: stub out video embed view logic

* api prerelease

* api prerelease

* lexicon: video upload/processing lexicons

* tidy

* lexicon: app.bsky.video lexicons for uploads

* codegen

* api prerelease

* appview: present video embeds on posts

* appview: snaps

* changeset

* appview: fix wiring of video url config
  • Loading branch information
devinivy authored Aug 28, 2024
1 parent f1dad05 commit 80ada8f
Show file tree
Hide file tree
Showing 72 changed files with 2,858 additions and 178 deletions.
7 changes: 7 additions & 0 deletions .changeset/gorgeous-crabs-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@atproto/bsky": patch
"@atproto/api": patch
"@atproto/pds": patch
---

Lexicons and support for video embeds within bsky posts.
15 changes: 15 additions & 0 deletions lexicons/app/bsky/embed/defs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"lexicon": 1,
"id": "app.bsky.embed.defs",
"defs": {
"aspectRatio": {
"type": "object",
"description": "width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit.",
"required": ["width", "height"],
"properties": {
"width": { "type": "integer", "minimum": 1 },
"height": { "type": "integer", "minimum": 1 }
}
}
}
}
19 changes: 8 additions & 11 deletions lexicons/app/bsky/embed/images.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,10 @@
"type": "string",
"description": "Alt text description of the image, for accessibility."
},
"aspectRatio": { "type": "ref", "ref": "#aspectRatio" }
}
},
"aspectRatio": {
"type": "object",
"description": "width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit.",
"required": ["width", "height"],
"properties": {
"width": { "type": "integer", "minimum": 1 },
"height": { "type": "integer", "minimum": 1 }
"aspectRatio": {
"type": "ref",
"ref": "app.bsky.embed.defs#aspectRatio"
}
}
},
"view": {
Expand Down Expand Up @@ -68,7 +62,10 @@
"type": "string",
"description": "Alt text description of the image, for accessibility."
},
"aspectRatio": { "type": "ref", "ref": "#aspectRatio" }
"aspectRatio": {
"type": "ref",
"ref": "app.bsky.embed.defs#aspectRatio"
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions lexicons/app/bsky/embed/record.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"type": "union",
"refs": [
"app.bsky.embed.images#view",
"app.bsky.embed.video#view",
"app.bsky.embed.external#view",
"app.bsky.embed.record#view",
"app.bsky.embed.recordWithMedia#view"
Expand Down
12 changes: 10 additions & 2 deletions lexicons/app/bsky/embed/recordWithMedia.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
},
"media": {
"type": "union",
"refs": ["app.bsky.embed.images", "app.bsky.embed.external"]
"refs": [
"app.bsky.embed.images",
"app.bsky.embed.video",
"app.bsky.embed.external"
]
}
}
},
Expand All @@ -27,7 +31,11 @@
},
"media": {
"type": "union",
"refs": ["app.bsky.embed.images#view", "app.bsky.embed.external#view"]
"refs": [
"app.bsky.embed.images#view",
"app.bsky.embed.video#view",
"app.bsky.embed.external#view"
]
}
}
}
Expand Down
66 changes: 66 additions & 0 deletions lexicons/app/bsky/embed/video.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"lexicon": 1,
"id": "app.bsky.embed.video",
"description": "A video embedded in a Bluesky record (eg, a post).",
"defs": {
"main": {
"type": "object",
"required": ["video"],
"properties": {
"video": {
"type": "blob",
"accept": ["video/mp4"],
"maxSize": 50000000
},
"captions": {
"type": "array",
"items": { "type": "ref", "ref": "#caption" },
"maxLength": 20
},
"alt": {
"type": "string",
"description": "Alt text description of the video, for accessibility.",
"maxGraphemes": 1000,
"maxLength": 10000
},
"aspectRatio": {
"type": "ref",
"ref": "app.bsky.embed.defs#aspectRatio"
}
}
},
"caption": {
"type": "object",
"required": ["lang", "file"],
"properties": {
"lang": {
"type": "string",
"format": "language"
},
"file": {
"type": "blob",
"accept": ["text/vtt"],
"maxSize": 20000
}
}
},
"view": {
"type": "object",
"required": ["cid", "playlist"],
"properties": {
"cid": { "type": "string", "format": "cid" },
"playlist": { "type": "string", "format": "uri" },
"thumbnail": { "type": "string", "format": "uri" },
"alt": {
"type": "string",
"maxGraphemes": 1000,
"maxLength": 10000
},
"aspectRatio": {
"type": "ref",
"ref": "app.bsky.embed.defs#aspectRatio"
}
}
}
}
}
1 change: 1 addition & 0 deletions lexicons/app/bsky/feed/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"type": "union",
"refs": [
"app.bsky.embed.images#view",
"app.bsky.embed.video#view",
"app.bsky.embed.external#view",
"app.bsky.embed.record#view",
"app.bsky.embed.recordWithMedia#view"
Expand Down
1 change: 1 addition & 0 deletions lexicons/app/bsky/feed/post.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"type": "union",
"refs": [
"app.bsky.embed.images",
"app.bsky.embed.video",
"app.bsky.embed.external",
"app.bsky.embed.record",
"app.bsky.embed.recordWithMedia"
Expand Down
28 changes: 28 additions & 0 deletions lexicons/app/bsky/video/defs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"lexicon": 1,
"id": "app.bsky.video.defs",
"defs": {
"jobStatus": {
"type": "object",
"required": ["jobId", "did", "state"],
"properties": {
"jobId": { "type": "string" },
"did": { "type": "string", "format": "did" },
"state": {
"type": "string",
"description": "The state of the video processing job. All values not listed as a known value indicate that the job is in process.",
"knownValues": ["JOB_STATE_COMPLETED", "JOB_STATE_FAILED"]
},
"progress": {
"type": "integer",
"minimum": 0,
"maximum": 100,
"description": "Progress within the current processing state."
},
"blob": { "type": "blob" },
"error": { "type": "string" },
"message": { "type": "string" }
}
}
}
}
32 changes: 32 additions & 0 deletions lexicons/app/bsky/video/getJobStatus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"lexicon": 1,
"id": "app.bsky.video.getJobStatus",
"defs": {
"main": {
"type": "query",
"description": "Get status details for a video processing job.",
"parameters": {
"type": "params",
"required": ["jobId"],
"properties": {
"jobId": {
"type": "string"
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["jobStatus"],
"properties": {
"jobStatus": {
"type": "ref",
"ref": "app.bsky.video.defs#jobStatus"
}
}
}
}
}
}
}
24 changes: 24 additions & 0 deletions lexicons/app/bsky/video/getUploadLimits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"lexicon": 1,
"id": "app.bsky.video.getUploadLimits",
"defs": {
"main": {
"type": "query",
"description": "Get video upload limits for the authenticated user.",
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["canUpload"],
"properties": {
"canUpload": { "type": "boolean" },
"remainingDailyVideos": { "type": "integer" },
"remainingDailyBytes": { "type": "integer" },
"message": { "type": "string" },
"error": { "type": "string" }
}
}
}
}
}
}
26 changes: 26 additions & 0 deletions lexicons/app/bsky/video/uploadVideo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"lexicon": 1,
"id": "app.bsky.video.uploadVideo",
"defs": {
"main": {
"type": "procedure",
"description": "Upload a video to be processed then stored on the PDS.",
"input": {
"encoding": "video/mp4"
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["jobStatus"],
"properties": {
"jobStatus": {
"type": "ref",
"ref": "app.bsky.video.defs#jobStatus"
}
}
}
}
}
}
}
53 changes: 53 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ import * as AppBskyActorProfile from './types/app/bsky/actor/profile'
import * as AppBskyActorPutPreferences from './types/app/bsky/actor/putPreferences'
import * as AppBskyActorSearchActors from './types/app/bsky/actor/searchActors'
import * as AppBskyActorSearchActorsTypeahead from './types/app/bsky/actor/searchActorsTypeahead'
import * as AppBskyEmbedDefs from './types/app/bsky/embed/defs'
import * as AppBskyEmbedExternal from './types/app/bsky/embed/external'
import * as AppBskyEmbedImages from './types/app/bsky/embed/images'
import * as AppBskyEmbedRecord from './types/app/bsky/embed/record'
import * as AppBskyEmbedRecordWithMedia from './types/app/bsky/embed/recordWithMedia'
import * as AppBskyEmbedVideo from './types/app/bsky/embed/video'
import * as AppBskyFeedDefs from './types/app/bsky/feed/defs'
import * as AppBskyFeedDescribeFeedGenerator from './types/app/bsky/feed/describeFeedGenerator'
import * as AppBskyFeedGenerator from './types/app/bsky/feed/generator'
Expand Down Expand Up @@ -163,6 +165,10 @@ import * as AppBskyUnspeccedGetSuggestionsSkeleton from './types/app/bsky/unspec
import * as AppBskyUnspeccedGetTaggedSuggestions from './types/app/bsky/unspecced/getTaggedSuggestions'
import * as AppBskyUnspeccedSearchActorsSkeleton from './types/app/bsky/unspecced/searchActorsSkeleton'
import * as AppBskyUnspeccedSearchPostsSkeleton from './types/app/bsky/unspecced/searchPostsSkeleton'
import * as AppBskyVideoDefs from './types/app/bsky/video/defs'
import * as AppBskyVideoGetJobStatus from './types/app/bsky/video/getJobStatus'
import * as AppBskyVideoGetUploadLimits from './types/app/bsky/video/getUploadLimits'
import * as AppBskyVideoUploadVideo from './types/app/bsky/video/uploadVideo'
import * as ChatBskyActorDeclaration from './types/chat/bsky/actor/declaration'
import * as ChatBskyActorDefs from './types/chat/bsky/actor/defs'
import * as ChatBskyActorDeleteAccount from './types/chat/bsky/actor/deleteAccount'
Expand Down Expand Up @@ -291,10 +297,12 @@ export * as AppBskyActorProfile from './types/app/bsky/actor/profile'
export * as AppBskyActorPutPreferences from './types/app/bsky/actor/putPreferences'
export * as AppBskyActorSearchActors from './types/app/bsky/actor/searchActors'
export * as AppBskyActorSearchActorsTypeahead from './types/app/bsky/actor/searchActorsTypeahead'
export * as AppBskyEmbedDefs from './types/app/bsky/embed/defs'
export * as AppBskyEmbedExternal from './types/app/bsky/embed/external'
export * as AppBskyEmbedImages from './types/app/bsky/embed/images'
export * as AppBskyEmbedRecord from './types/app/bsky/embed/record'
export * as AppBskyEmbedRecordWithMedia from './types/app/bsky/embed/recordWithMedia'
export * as AppBskyEmbedVideo from './types/app/bsky/embed/video'
export * as AppBskyFeedDefs from './types/app/bsky/feed/defs'
export * as AppBskyFeedDescribeFeedGenerator from './types/app/bsky/feed/describeFeedGenerator'
export * as AppBskyFeedGenerator from './types/app/bsky/feed/generator'
Expand Down Expand Up @@ -362,6 +370,10 @@ export * as AppBskyUnspeccedGetSuggestionsSkeleton from './types/app/bsky/unspec
export * as AppBskyUnspeccedGetTaggedSuggestions from './types/app/bsky/unspecced/getTaggedSuggestions'
export * as AppBskyUnspeccedSearchActorsSkeleton from './types/app/bsky/unspecced/searchActorsSkeleton'
export * as AppBskyUnspeccedSearchPostsSkeleton from './types/app/bsky/unspecced/searchPostsSkeleton'
export * as AppBskyVideoDefs from './types/app/bsky/video/defs'
export * as AppBskyVideoGetJobStatus from './types/app/bsky/video/getJobStatus'
export * as AppBskyVideoGetUploadLimits from './types/app/bsky/video/getUploadLimits'
export * as AppBskyVideoUploadVideo from './types/app/bsky/video/uploadVideo'
export * as ChatBskyActorDeclaration from './types/chat/bsky/actor/declaration'
export * as ChatBskyActorDefs from './types/chat/bsky/actor/defs'
export * as ChatBskyActorDeleteAccount from './types/chat/bsky/actor/deleteAccount'
Expand Down Expand Up @@ -1421,6 +1433,7 @@ export class AppBskyNS {
notification: AppBskyNotificationNS
richtext: AppBskyRichtextNS
unspecced: AppBskyUnspeccedNS
video: AppBskyVideoNS

constructor(client: XrpcClient) {
this._client = client
Expand All @@ -1432,6 +1445,7 @@ export class AppBskyNS {
this.notification = new AppBskyNotificationNS(client)
this.richtext = new AppBskyRichtextNS(client)
this.unspecced = new AppBskyUnspeccedNS(client)
this.video = new AppBskyVideoNS(client)
}
}

Expand Down Expand Up @@ -3019,6 +3033,45 @@ export class AppBskyUnspeccedNS {
}
}

export class AppBskyVideoNS {
_client: XrpcClient

constructor(client: XrpcClient) {
this._client = client
}

getJobStatus(
params?: AppBskyVideoGetJobStatus.QueryParams,
opts?: AppBskyVideoGetJobStatus.CallOptions,
): Promise<AppBskyVideoGetJobStatus.Response> {
return this._client.call(
'app.bsky.video.getJobStatus',
params,
undefined,
opts,
)
}

getUploadLimits(
params?: AppBskyVideoGetUploadLimits.QueryParams,
opts?: AppBskyVideoGetUploadLimits.CallOptions,
): Promise<AppBskyVideoGetUploadLimits.Response> {
return this._client.call(
'app.bsky.video.getUploadLimits',
params,
undefined,
opts,
)
}

uploadVideo(
data?: AppBskyVideoUploadVideo.InputSchema,
opts?: AppBskyVideoUploadVideo.CallOptions,
): Promise<AppBskyVideoUploadVideo.Response> {
return this._client.call('app.bsky.video.uploadVideo', opts?.qp, data, opts)
}
}

export class ChatNS {
_client: XrpcClient
bsky: ChatBskyNS
Expand Down
Loading

0 comments on commit 80ada8f

Please sign in to comment.