【问题标题】:Filtering a list crashes without throwing an error过滤列表崩溃而不抛出错误
【发布时间】:2023-03-04 00:36:01
【问题描述】:

我有这个 google-apps-script 代码,用于获取一些 YT 频道并过滤其中一些:

    var popularChannels = YouTube.Channels.list('id, snippet, statistics', {
        id: resultsParentChannelIds.slice(i * 50, (i + 1) * 50)
    }).getItems().
    filter(
      ch => 
    ((channelIdFilter == "" || ch.id == channelIdFilter)
    && (subCountFilter == "" || ch.statistics.subscriberCount > subCountFilter)
    && (channelLocationFilter == "" || channel.snippet.country == undefined || channel.snippet.country == channelLocationFilter)
    && (channelNegativeLocationFilter == "" || channel.snippet.country == undefined || channel.snippet.country != channelNegativeLocationFilter)));

除了最后一个 NegativeLocation 过滤器之外,所有过滤器都是 ""

但调试器在第一个过滤器之后停止而没有写入任何错误。

如何调试或了解问题所在?

【问题讨论】:

    标签: javascript google-apps-script youtube-api filtering


    【解决方案1】:

    您在中途将 currentValue 变量从 ch 更改为 channel

    var popularChannels = YouTube.Channels.list('id, snippet, statistics', {
      id: resultsParentChannelIds.slice(i * 50, (i + 1) * 50)
    }).getItems().
    filter(
    ch => 
    ((channelIdFilter == "" || ch.id == channelIdFilter)
    && (subCountFilter == "" || ch.statistics.subscriberCount > subCountFilter)
    && (channelLocationFilter == "" || ch.snippet.country == undefined || ch.snippet.country == channelLocationFilter)
    && (channelNegativeLocationFilter == "" || ch.snippet.country == undefined || ch.snippet.country != channelNegativeLocationFilter)));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-08
      • 2015-01-04
      • 1970-01-01
      • 2014-10-19
      • 1970-01-01
      • 2017-12-15
      • 1970-01-01
      相关资源
      最近更新 更多