Glanceway Glanceway
所有資料來源

TMDb Trending

娛樂 v1.0.0

Trending movies and TV shows from The Movie Database

@codytseng #movies #tv #trending #entertainment

安裝與設定方式

  1. 先在 Mac 上安裝並開啟 Glanceway,再使用上方的安裝連結。
  2. 點選「安裝到 Glanceway」。若瀏覽器無法開啟應用程式,下載 .gwsrc 檔案並在資訊源管理中匯入。
  3. 填寫以下必填欄位並儲存,設定更新間隔,等待首次成功取得內容。

設定檢查

  • TMDB_API_KEY — 必填. Free API key from themoviedb.org 填寫自己的存取憑證,請勿在截圖或公開檔案中分享。
  • MEDIA_TYPE — 選填. Type of media to show
  • TIME_WINDOW — 選填. Trending time window

沒有顯示內容時如何排查

  • 對照目前版本設定表檢查欄位、清單項目與憑證。下方範例不包含可用的真實憑證。
  • 檢查網路及上游服務狀態。認證失敗或速率限制可能使更新失敗,請依上游限制調整間隔。
  • 空清單也可能代表沒有符合條件的條目。內容與更新時間取決於資料提供方及資訊源實作。

設定項目

名稱 鍵 類型 必填 預設值 描述
API Key TMDB_API_KEY secret 是 — Free API key from themoviedb.org
Media Type MEDIA_TYPE select 否 all Type of media to show
allmovietv
Time Window TIME_WINDOW select 否 week Trending time window
dayweek

原始碼

id: codytseng/tmdb-trending
version: 1.0.0
name: TMDb Trending
description: Trending movies and TV shows from The Movie Database
author: codytseng
author_url: https://github.com/codytseng
category: Entertainment
tags:
  - movies
  - tv
  - trending
  - entertainment

config:
  - key: TMDB_API_KEY
    name: API Key
    type: secret
    required: true
    description: "Free API key from themoviedb.org"
  - key: MEDIA_TYPE
    name: Media Type
    type: select
    required: false
    default: all
    description: Type of media to show
    options:
      - all
      - movie
      - tv
  - key: TIME_WINDOW
    name: Time Window
    type: select
    required: false
    default: week
    description: Trending time window
    options:
      - day
      - week
module.exports = async (api) => {
  const apiKey = api.config.get("TMDB_API_KEY");
  const mediaType = api.config.get("MEDIA_TYPE") || "all";
  const timeWindow = api.config.get("TIME_WINDOW") || "week";

  async function fetchData() {
    const url = `https://api.themoviedb.org/3/trending/${mediaType}/${timeWindow}?api_key=${apiKey}`;

    const response = await api.fetch(url);

    if (!response.ok || !response.json) {
      throw new Error(`Failed to fetch TMDB trending (HTTP ${response.status})`);
    }

    const items = response.json.results.map((item) => ({
      id: String(item.id),
      title: item.title ?? item.name ?? "Unknown",
      subtitle: item.overview,
      url: `https://www.themoviedb.org/${item.media_type}/${item.id}`,
      timestamp: item.release_date ?? item.first_air_date,
    }));
    api.emit(items);
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};

相關資料來源