跟踪 Steam 游戏时间(来自网络 API)

Tracking Steam Playtime (from the web API)

我正在尝试使用 Google 日历来跟踪我的游戏时间/历史记录。

这是 Steam Web API,我无法在其中找到一种方法来获取关于我究竟在什么时候玩什么的详细信息,除了 GetRecentlyPlayedGames 端点,它给了我一些有趣的数据:

理论上我可以把playtime_forever这个字段存下来,每隔5分钟cron一次,看是否涨了,如果连续2次都一样,就说明我不玩这个session了,并且我可以在日历中记录它。

所以这个问题在理论上已经解决了,但我想知道是否有任何其他 API 我可以使用它来给我提供更准确的数据,或者这是我拥有的最佳选择吗?

我对 YouTube 采用相同的方式,因为他们没有给我确切的时间,但例如 Netflix 这样做更简单,而且我不需要管理任何类型的数据(除了我已经发送到日历的内容)

除了最近的历史记录,我找不到其他方法,所以这就是我正在做的。

getPlaytime(request, response) {
  return this._getRecentHistory()
    .then(response => response.games)
    .then(games => {
      response.json(games);
      return Promise.all(games.map((game) => {
        const appRef = this.ref.child('steam').child(game.appid);
        return appRef.once('value').then(snapshot => {
          if (snapshot.exists()) {
            const value = snapshot.val();

            if (game.playtime_forever > value.playtime) {
              const sessionPlaytime = game.playtime_forever - value.playtime;
              console.log("sessionPlaytime", game.name, sessionPlaytime, "minutes");

              const endDate = new Date();
              const startDate = new Date(endDate.getTime() - sessionPlaytime * 60 * 1000);

              this.calendar.createEvent("games", game.name, startDate, endDate);

              return appRef.update({playtime: game.playtime_forever});
            }

            return Promise.resolve();
          } else {
            return appRef.set({
              name: game.name,
              playtime: game.playtime_forever
            });
          }
        });
      }));
    })
    .catch((e) => console.error(e));
}