Skip to content

Commit

Permalink
Breaking change: supporting video content
Browse files Browse the repository at this point in the history
  • Loading branch information
muan committed Oct 29, 2024
1 parent 82f4d97 commit 124a585
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,19 @@ Common fields between Image Stories and Video Stories:
- `reactions` (optional, _Reactions_): Data that describes how clients can react to this video.
- `content_warning` (optional, _String_): If present, clients should display this warning before showing the story to the user.
- `duration_in_seconds` (optional, _Number_): How long the story should be displayed for. Clients are free to adjust this number.
- `alt` (required, _String_): The alt text of the video.
- `caption` (optional, _String_): The caption of the video.
- `title` (required, _String_): A description of the video.

Fields unique to Video Story:

- `mime_type` (required, _String_ beginning with `video/`): the MIME type of the video.
- `webvtt` (optional, _String_): The URL of the WEBVTT of the video.
- `tracks` (optional, an array of [_Tracks_](#tracks)): The [tracks](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTrackElement) for the video.

#### Tracks

- `url` (required, _String_): The URL of a WEBVTT file.
- `lang` (optional, _String_): A [BCP47 language subtag](https://en.wikipedia.org/wiki/IETF_language_tag#List_of_common_primary_language_subtags) for the track.
- `kind` (optional, _String_): 'captions' (default), 'subtitles', 'chapters'.
- `label` (optional, _String_): A user readable label for the track.

### Authors

Expand Down
10 changes: 9 additions & 1 deletion dist/openstories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ interface ImageStory extends OpenStory {

interface VideoStory extends OpenStory {
mime_type: `video/${string}`;
webvtt?: string;
title: string;
tracks?: Track[];
}

interface Track {
url: string;
srclang?: string;
label?: string;
kind?: 'captions' | 'subtitles' | 'chapters';
}

export default OpenStoriesFeed;
13 changes: 13 additions & 0 deletions test/valid-feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ const validFeed: OpenStoriesFeed = {
url: 'https://photos.muan.dev/cdn-cgi/imagedelivery/-wp_VgtWlgmh1JURQ8t1mg/9324c569-55a2-4f28-4c0e-dbf5ad04d000/public',
alt: 'A crocodile in stuffed animal form sitting on a scooter.',
}
},{
id: 'a1',
content_text: 'Text',
_open_stories: {
content_warning: 'Apex predator',
mime_type: 'video/mp4',
url: 'https://photos.muan.dev/cdn-cgi/imagedelivery/-wp_VgtWlgmh1JURQ8t1mg/9324c569-55a2-4f28-4c0e-dbf5ad04d000/public',
title: 'A cool video.',
tracks: [{
url: 'https://example.com',
kind: 'captions'
}]
}
}]
}

Expand Down

0 comments on commit 124a585

Please sign in to comment.