NHK Program Search

Stores program information matching the keyword specified in String type data item into a String type data item, and stores its communication log in a String type data item

    A. Set NHK API KEYSingle-line inputRequired
    B. Select AREA CODEData selectString(single line)Required
    C. Select SERVICE IDData selectString(single line)Required
    D. Select DATEData selectDateRequired
    E. Select SEARCH WORDS CSVData selectString(single line)Required
    F. Select Access LogData selectString(multiple line)Required
    G. Select Match LogData selectString(multiple line)Required
    -variable namevariable label
    Aconf_DataIdASet NHK API KEY
    Bconf_DataIdBSelect AREA CODE
    Cconf_DataIdCSelect SERVICE ID
    Dconf_DataIdDSelect DATE
    Econf_DataIdESelect SEARCH WORDS CSV
    Fconf_DataIdFSelect Access Log
    Gconf_DataIdGSelect Match Log
    // TV Program search via NHK Program List API (ver. 20170411)
    // (c) 2017, Questetra, Inc. (the MIT License)
    // 情報提供: NHK
    
    //// == コンフィグ&参照 / Config & Retrieving ==
    // あなたの "NHK番組表API" の "登録済みアプリ"
    // http://api-portal.nhk.or.jp/
    var nhkKey = configs.get( "conf_DataIdA" );
    
    // http://api-portal.nhk.or.jp
    var nhkArea = data.get( configs.get( "conf_DataIdB" ) ) + "";
    var nhkService = data.get( configs.get( "conf_DataIdC" ) ) + "";
     // 総合"g1",Eテレ"e1",BS1"s1",BSプレ"s3"
    var nhkDate = data.get( configs.get( "conf_DataIdD" ) ) + "";
    var searchWordsCsv = data.get( configs.get( "conf_DataIdE" ) ) + "";
    
    var dataIdF = configs.get( "conf_DataIdF" );
    var dataIdG = configs.get( "conf_DataIdG" );
    
    //// == 演算 / Calculating ==
    var accessLog = "";
    var matchLog = "";
    
    /// -- GET program list --
    var uri = "http://api.nhk.or.jp/v2/pg/list/";
    uri += nhkArea + "/";
    uri += nhkService + "/";
    uri += nhkDate + ".json?key=";
    uri += nhkKey;
    
    // com.questetra.bpms.core.event.scripttask.HttpClientWrapper
    // https://www.questetra.com/ja/tour/m2/m230/
    // HttpRequestWrapper
    var requestMsg = httpClient.begin();
    
    // HttpResponseWrapper
    var responseMsg = requestMsg.get( uri );
    accessLog += "---GET--- " + responseMsg.getStatusCode() + " " + responseMsg.getCharset() + "\n";
    accessLog += responseMsg.getResponseAsString() + "\n\n";
    
    /// -- Word Search --
    var responseObj = JSON.parse( responseMsg.getResponseAsString() );
    var searchWords = searchWordsCsv.split(",");
    
    var tmp = "";
    for (var i = 0; i < responseObj.list[nhkService].length; i ++) { // Bracket notation
      tmp = responseObj.list[nhkService][i].start_time.slice(11, 16) + "\n";
      tmp += responseObj.list[nhkService][i].title + "\n";
      tmp += responseObj.list[nhkService][i].subtitle + "\n";
      tmp += responseObj.list[nhkService][i].content + " ";
      tmp += responseObj.list[nhkService][i].act + "\n";
    
      for (var j = 0; j < searchWords.length; j ++) {
        if ( tmp.match( searchWords[j] ) ) {
          matchLog += tmp + "\n+++ \n\n";
          break;
        }
      }
    }
    
    
    //// == ワークフローデータへの代入 / Data Updating ==
    retVal.put( dataIdF, accessLog );
    retVal.put( dataIdG, matchLog );
    
    

    • B’: Area code stored in the Data Item selected at config B
    • C’: Service ID (Broadcast channel) stored in the Data Item selected at config C
    • D’: On-air date stored in the Data Item selected at config D
    • E’: Search keyword CSV* stored in the Data Item selected at config E
    • The communication logs are stored in the Data Item selected at config F
    • Program information matching the keyword is stored in the Data Item selected at config G
    • * Separate multiple keywords with commas