public String addHighlight(String channel,String comment){
  if (channel == null || channel.isEmpty() || !Helper.isRegularChannel(channel)) {
    return "Failed adding stream highlight (no channel).";
  }
  StreamInfo streamInfo=api.getStreamInfo(Helper.toStream(channel),null);
  String streamTime="Stream Time N/A";
  if (streamInfo.isValid() && streamInfo.getOnline()) {
    streamTime=DateTime.ago(streamInfo.getTimeStarted());
  }
  if (comment == null) {
    comment="";
  }
  String line=String.format("%s %s [%s] %s",DateTime.fullDateTime(),channel,streamTime,comment);
synchronized (this) {
    if (streamInfo.getTimeStarted() != lastStreamStartWritten) {
      addToFile("-");
    }
    boolean success=addToFile(line);
    if (success) {
      lastStreamStartWritten=streamInfo.getTimeStarted();
      String shortComment="";
      if (!comment.isEmpty()) {
        shortComment="(" + StringUtil.shortenTo(comment,30) + ")";
      }
      return "Added stream highlight for " + channel + " ["+ streamTime+ "] "+ shortComment;
    }
    return "Failed adding stream highlight (write error).";
  }
}

public String addHighlight ( String channel , String comment ) { if ( channel == null || channel . isEmpty ( ) || ! Helper . isRegularChannel ( channel ) ) { return "Failed adding stream highlight (no channel)." ; } StreamInfo streamInfo = api . getStreamInfo ( Helper . toStream ( channel ) , null ) ; String streamTime = "Stream Time N/A" ; if ( streamInfo . isValid ( ) && streamInfo . getOnline ( ) ) { streamTime = DateTime . ago ( streamInfo . getTimeStarted ( ) ) ; } if ( comment == null ) { comment = "" ; } String line = String . format ( "%s %s [%s] %s" , DateTime . fullDateTime ( ) , channel , streamTime , comment ) ; synchronized ( this ) { if ( streamInfo . getTimeStarted ( ) != lastStreamStartWritten ) { addToFile ( "-" ) ; } boolean success = addToFile ( line ) ; if ( success ) { lastStreamStartWritten = streamInfo . getTimeStarted ( ) ; String shortComment = "" ; if ( ! comment . isEmpty ( ) ) { shortComment = "(" + StringUtil . shortenTo ( comment , 30 ) + ")" ; } return "Added stream highlight for " + channel + " [" + streamTime + "] " + shortComment ; } return "Failed adding stream highlight (write error)." ; } }
adds a highlight for the given channel with the given comment . thread - saftey : it should be safe to call this from several threads . instance variables and writing to the file is synchronized on this .
