Skip to content

Commit

Permalink
Merge f07abf1 into 541b580
Browse files Browse the repository at this point in the history
  • Loading branch information
jsalonen authored Oct 8, 2018
2 parents 541b580 + f07abf1 commit 83f3375
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
ApiAuth,
ApiResponse,
ApiResponseProgram,
ApiRequestPrograms,
ApiResponsePrograms,
ApiRequestProgramsNow,
ApiResponseMediaPlayouts,
Program,
ProgramPublicationEvent,
Expand Down Expand Up @@ -44,7 +46,7 @@ class Client {
}
}

async fetchPrograms (queryOptions: any = {}): Promise<ApiResponsePrograms> {
async fetchPrograms (queryOptions: ApiRequestPrograms = {}): Promise<ApiResponsePrograms> {
const url =
URI(API_URL)
.segment('programs')
Expand All @@ -57,7 +59,7 @@ class Client {
return this.retrieveJSONOrError(response);
}

async fetchProgramsNow (queryOptions: any= {}): Promise<ApiResponse> {
async fetchProgramsNow (queryOptions: ApiRequestProgramsNow = {}): Promise<ApiResponse> {
const url =
URI(API_URL)
.segment('programs')
Expand Down
42 changes: 42 additions & 0 deletions src/client.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,50 @@ export interface ApiResponsePrograms extends ApiResponse {
data: Program[];
}

export interface ApiRequestPrograms {
id?: string; // Multiple IDs can be passed as a comma separated list.
type?: 'program' | 'clip' | 'tvcontent' | 'tvprogram' | 'tvclip' | 'radiocontent' | 'radioprogram' | 'radioclip';
q?: string;
mediaobject?: 'audio' | 'video';
category?: string; // Multiple IDs can be passed as a comma separated list.
series?: string; // Multiple IDs can be passed as a comma separated list.
availability?: 'ondemand' | 'future-ondemand' | 'future-scheduled' | 'in-future';
downloadable?: 'true' | undefined;
language?: 'fi' | 'sv';
region?: 'fi' | 'world';
service?: string; // Multiple service IDs can be passes as a comma separated list.
publisher?: string;
contentprotection?: string; // Multiple IDs can be passed as a comma separated list.
order?: Order;
limit?: number;
offset?: number;
}

export interface ApiRequestProgramsNow {
service?: string; // Multiple service IDs can be passes as a comma separated list.
start?: number; // Allowed values range from -10 to 0. -1 means that the previous program will be included in the response.
end?: number; // Allowed values range from 0 to 10. 1 means that the next program will be included in the response.
mediaobject?: 'video' | 'audio';
}

export interface ApiResponseMediaPlayouts extends ApiResponse {
data: MediaPlayout[];
}

export type PlayoutProtocol = 'HLS' | 'HDS' | 'PMD' | 'RTMPE';

export type Order =
'playcount.6h:asc' |
'playcount.6h:desc' |
'playcount.24h:asc' |
'playcount.24h:desc' |
'playcount.week:asc' |
'playcount.week:desc' |
'playcount.month:asc' |
'playcount.month:desc' |
'publication.starttime:asc' |
'publication.starttime:desc' |
'publication.endtime:asc' |
'publication.endtime:desc' |
'updated:asc' |
'updated:desc';
4 changes: 2 additions & 2 deletions src/cmdline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ program
.option('-sr, --series <value>', 'Return items containing specific series')
.option('-s, --service <value>', 'Filter by service')
.option('-t, --type <type>', 'Filter by type')
.action(async (q: string, limit: string, offset: string, options: any) => {
.action(async (q: string, limit: number, offset: number, options: any) => {
const finalOptions = {
q: q,
limit: limit,
Expand All @@ -69,7 +69,7 @@ program
} else {
const programs = response.data;
const language = finalOptions.language || 'fi';
const output = programs.map(program => {
const output = programs.map((program: any) => {
const title = program.title[language];
const description = program.description[language] || '';
return `[${program.id}] ${title} ${description}`;
Expand Down

0 comments on commit 83f3375

Please sign in to comment.