Skip to content

Commit

Permalink
Merge pull request #260 from vitalygashkov/next
Browse files Browse the repository at this point in the history
Added extension types to `@streamyx/api`
  • Loading branch information
vitalygashkov authored Dec 1, 2024
2 parents 1be32bf + 9bbf86a commit 5d02582
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamyx/api",
"version": "0.0.5",
"version": "0.0.6",
"description": "Type definitions for the latest Streamyx API",
"main": "streamyx.js",
"types": "streamyx.d.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/api/streamyx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './types/http';
export * from './types/logger';
export * from './types/question';
export * from './types/common';
export * from './types/extension';
94 changes: 94 additions & 0 deletions packages/api/types/extension.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
export interface Extension {
/**
* Extension name (e.g. Netflix, Prime Video, Apple TV+, etc.)
*/
name: string;

/**
* Short tag which will be used in filename (e.g. NF, AMZN, ATVP, etc.)
*/
tag?: string;

/**
* Logo icon URL
*/
icon?: string;

/**
* Substring pattern to match URL host handled by this plugin
*/
match?: string;

/**
* Performs initialization of extension (e.g. loading auth data from storage or token refresh)
*/
init?: () => void | Promise<void>;

/**
* Fetches content metadata from URL
*/
fetchContentMetadata: (
url: string,
options: Options,
) => Promise<ContentMetadata[]>;

/**
* Fetches data about content source (e.g. manifest URL, external subtitles, etc.)
*/
fetchContentSource?: (
contentId: string,
options: Options,
) => Promise<ContentSource | null>;

/**
* Fetches just content DRM config (e.g. license server URL, request headers, etc.)
*/
fetchContentDrm?: (payload: any, options: Options) => Promise<DrmConfig>;
}

export interface CommonContentMetadata {
tag?: string;
/**
* Required if no `fetchContentSource` method is provided
*/
source?: ContentSource;
}

export interface MovieMetadata extends CommonContentMetadata {
id?: string;
title?: string;
}

export interface EpisodeMetadata extends CommonContentMetadata {
id?: string;
title?: string;
episodeNumber: number;
seasonNumber?: number;
episodeTitle?: string;
}

export type ContentMetadata = MovieMetadata | EpisodeMetadata;

export type ContentSource = {
/**
* URL of the content: manifest URL / playlist URL / direct link to media file
*/
url: string;
headers?: Record<string, string>;
http2?: boolean;
type?: 'video' | 'audio' | 'subtitle' | 'any';
audioLanguage?: string;
audioType?: string;
subtitles?: any[];
drm?: DrmConfig;
};

export type DrmConfig =
| {
server: string;
headers?: Record<string, string>;
params?: object;
template?: string;
http2?: boolean;
}
| { payload: any };

0 comments on commit 5d02582

Please sign in to comment.