@gibme/tablo.tv
Version:
API interface for interacting with a Tablo TV device
363 lines (362 loc) • 11.3 kB
TypeScript
import TabloAPI from './tablo_api';
import Lighthouse from './lighthouse';
import type { Logo } from './types';
/**
* See https://jessedp.github.io/tablo-api-docs/#tablo-api-introduction
* for an extensive list of device endpoints
*
* Note: this implementation is currently incomplete and is unlikely to have all endpoints implemented.
*/
export declare class Tablo extends TabloAPI {
private readonly cache;
private readonly session_channels;
/**
* Attempts to discover the Tablo devices on the network from which this API is made.
* @param timeout
*/
static discover(timeout?: number): Promise<Lighthouse.Device[]>;
/**
* Returns the currently available airings
*
* Note: This method contains a loop that results in the method taking a bit of time to complete,
* you may specify a progress callback to help report the progress to the caller.
*
* Repeated calls to this method are cached for approximately 10 minutes.
*
* @param all if true, will return all airings, otherwise will only return airings that are currently playing.
* @param timeout
* @param force_refresh if set to true, will force a refresh of the cache.
* @param progress_callback
*/
airings(all?: boolean, timeout?: number, force_refresh?: boolean, progress_callback?: (total: number, received: number) => void): Promise<Tablo.Airing[]>;
/**
* Retrieves account subscription information from the device
* @param timeout
*/
accountSubscription(timeout?: number): Promise<Tablo.AccountSubscription | undefined>;
/**
* Retrieves the capabilities of the device.
* @param timeout
*/
capabilities(timeout?: number): Promise<string[]>;
channel(channel_id: string, timeout?: number): Promise<Tablo.Channel | undefined>;
/**
* Returns a list of the available channels on the device.
* @param timeout
*/
channels(timeout?: number): Promise<Tablo.Channel[]>;
/**
* Retrieves information regarding the latest (or a specified) channel scan.
*
* @param scan_idx if not specified, will pull the latest channel scan information
* @param timeout
*/
channelScanInfo(scan_idx?: number | string, timeout?: number): Promise<Tablo.ChannelScan | undefined>;
/**
* Deletes/stops an existing watch (streaming) session
* @param tokenOrPlayerSession
* @param timeout
*/
deleteSession(tokenOrPlayerSession: string | Tablo.PlayerSession, timeout?: number): Promise<boolean>;
/**
* Retrieves device subscription information.
* @param timeout
*/
deviceSubscription(timeout?: number): Promise<Tablo.DeviceSubscription | undefined>;
/**
* Retrieves the guide status from the device
* @param timeout
*/
guideStatus(timeout?: number): Promise<Tablo.GuideStatus | undefined>;
/**
* Retrieves a list of the hard drives connected to the device.
* @param timeout
*/
hardDrives(timeout?: number): Promise<Tablo.HardDrive[]>;
/**
* Retrieves device information
* @param timeout
*/
info(timeout?: number): Promise<Tablo.Info | undefined>;
/**
* Sends a watch (streaming) session keepalive request so that the session does not time out and stop
* @param tokenOrPlayerSession
* @param timeout
*/
keepaliveSession(tokenOrPlayerSession: string | Tablo.PlayerSession, timeout?: number): Promise<Tablo.PlayerSession | undefined>;
/**
* Retrieves device location information
* @param timeout
*/
location(timeout?: number): Promise<Tablo.Location | undefined>;
/**
* Attempts to retrieve an existing watch (streaming) session
* @param tokenOrPlayerSession
* @param timeout
*/
session(tokenOrPlayerSession: string | Tablo.PlayerSession, timeout?: number): Promise<Tablo.PlayerSession | undefined>;
/**
* Retrieves the settings of the device.
* @param timeout
*/
settings(timeout?: number): Promise<Tablo.Settings | undefined>;
/**
* Retrieves the list of supported storage types.
* @param timeout
*/
storage(timeout?: number): Promise<string[]>;
/**
* Retrieves tuner information of the device.
* @param timeout
*/
tuners(timeout?: number): Promise<Tablo.Tuner[]>;
/**
* Retrieves device update information.
* @param timeout
*/
updateInfo(timeout?: number): Promise<Tablo.UpdateInfo | undefined>;
/**
* Retrieves device update progress information.
* @param timeout
*/
updateProgress(timeout?: number): Promise<unknown | undefined>;
/**
* Initiates a channel watch (streaming) session on the device which must be managed via
* `keepaliveSession` and `deleteSession`
* @param channel_id
* @param device_info
* @param timeout
*/
watchChannel(channel_id: string, device_info?: Partial<Tablo.Client.Device>, timeout?: number): Promise<Tablo.PlayerSession | undefined>;
}
export declare namespace Tablo {
export namespace Client {
type DeviceExtra = {
deviceOS: string;
deviceId: string;
width: number;
deviceModel: string;
lang: string;
height: number;
deviceOSVersion: string;
limitedAdTracking: number;
deviceMake: string;
};
export type Device = {
device_id: string;
extra: Partial<DeviceExtra>;
platform: string;
bandwidth: unknown;
};
export {};
}
export type Info = {
server_id: string;
name: string;
timezone: string;
deprecated: string;
version: string;
local_address: string;
setup_completed: boolean;
build_number: number;
model: {
wifi: boolean;
tuners: number;
type: string;
name: string;
};
availability: string;
cache_key: string;
product: string;
};
export type Location = {
state: string;
location: {
postal_code: string;
name: string;
locality: string;
area: string;
state: string;
latitude: number;
longitude: number;
};
timezone: {
name: string;
raw_offset: number;
dst_offset: number;
does_dst: boolean;
};
};
export type Tuner = {
in_use: boolean;
channel: string | null;
recording: string | null;
channel_identifier: string | null;
};
export type Settings = {
led: string;
extended_live_recordings: boolean;
auto_delete_recordings: boolean;
exclude_duplicates: boolean;
preferred_audio_track: string;
data_collection: boolean;
enable_amplifier: boolean;
};
export type Channel = {
call_sign: string;
name: string;
call_sign_src: string;
major: number;
minor: number;
network: string;
flags: string[];
resolution: string;
favourite: boolean;
tms_station_id: string;
tms_affiliate_id: string;
channel_identifier: string;
source: string;
logos: Logo[];
};
export type PlayerSession<DateType = Date> = {
token: string;
expires: DateType;
keepalive: number;
playlist_url: string;
video_details: {
container_format: string;
flags: string[];
};
channel: Channel;
};
export type HardDrive = {
error: unknown | null;
connected: boolean;
format_state: string;
name: string;
busy_state: string;
kind: string;
size: number;
size_mib: number;
usage: number;
usage_mib: number;
free: number;
free_mib: number;
limit: number;
limit_mib: number;
};
export type GuideStatus<DateType = Date> = {
guide_seeded: boolean;
last_update: DateType;
limit: DateType;
download_progress: number | null;
};
export type DeviceSubscription<DateType = Date> = {
state: string;
expires: DateType | null;
url: string;
identifier: string;
};
type Subscription<DateType = Date> = {
kind: string;
state: string;
name: string;
title: string;
deprecated: string;
expires: DateType | null;
registration_url: string;
registration_identifier: string;
subtitle: string;
description: string;
actions: any[];
warnings: any[];
};
export type AccountSubscription<DateType = Date> = {
services: {
guide_data: {
selected: boolean;
active: boolean;
};
cloud_dvr: unknown | null;
deprecated: string;
};
state: string;
trial: unknown | null;
offered_option: unknown | null;
registration: {
url: string;
identifier: string;
};
subscriptions: Subscription<DateType>[];
};
export type UpdateInfo<DateType = Date> = {
details: unknown | null;
available_update: unknown | null;
last_checked: DateType;
last_update: DateType | null;
sequence: string[];
current_step: unknown | null;
state: string;
error: unknown | null;
};
export type ChannelScan<DateType = Date> = {
object_id: string;
path: string;
postal_code: string;
datetime: DateType;
completed: boolean;
progress: number;
preferred_audio_track: string;
};
export type Episode<DateType = Date> = {
title: string;
description: string;
number: number;
season_number: number;
orig_air_date: DateType;
tms_id: string;
};
export type Airing<DateType = Date> = {
show_title: string;
start_time: DateType;
end_time: DateType;
duration: number;
episode: Episode<DateType>;
channel: Channel;
};
export namespace Batched {
type Root = {
object_id: number;
path: string;
};
type Channel = {
channel: Tablo.Channel;
};
type Airing = {
series_path: string;
season_path: string;
episode: Episode<string>;
airing_details: {
show_title: string;
datetime: string;
duration: number;
channel_path: string;
channel: Root & Channel;
};
qualifiers: string[];
schedule: {
state: string;
qualifier: string;
skip_reason: string;
skip_detail: unknown | null;
offsets: {
start: number;
end: number;
source: string;
};
};
};
}
export {};
}
export default Tablo;