Glanceway Glanceway
所有信息源

TVMaze Schedule

娱乐 v1.0.0

Today's TV episode schedule by country

@codytseng #tv #schedule #entertainment

配置项

名称 类型 必填 默认值 描述
Country COUNTRY select US Country for TV schedule
USGBCAAU

源代码

version: 1.0.0
name: TVMaze Schedule
description: Today's TV episode schedule by country
author: codytseng
author_url: https://github.com/codytseng
category: Entertainment
tags:
  - tv
  - schedule
  - entertainment

config:
  - key: COUNTRY
    name: Country
    type: select
    required: false
    default: US
    description: Country for TV schedule
    options:
      - US
      - GB
      - CA
      - AU
module.exports = async (api) => {
  const country = api.config.get("COUNTRY") || "US";

  async function fetchData() {
    const res = await api.fetch(
      `https://api.tvmaze.com/schedule?country=${country}`,
    );
    if (!res.ok || !res.json) {
      throw new Error(`Failed to fetch TV schedule (HTTP ${res.status})`);
    }

    const items = res.json.map((episode) => ({
      id: String(episode.id),
      title: episode.show.name,
      subtitle: episode.name,
      url: episode.show.url,
      timestamp: episode.airstamp,
    }));

    api.emit(items);
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};