<commit_before>class Kandan.Plugins.YouTubeEmbed

  @options:
    regex: /^http(s)?.+www.youtube.com.+watch/i
    idRegex: /\Wv=([\w|\-]*)/

    template: _.template '''
      <div class="youtube-preview">
            <iframe width="560" height="315"
                    src="http://www.youtube.com/embed/<%= videoId %>"
                    frameborder="0" allowfullscreen>
            </iframe>
        <div class="name"><%= subtitle %></div>
      </div>
    '''


  @init: ()->
    Kandan.Modifiers.register @options.regex, (message, state) =>
      comment = null

      # No spaces in message content indicates just a link
      if message.content.indexOf(" ") == -1
        videoUrl = message.content
      else
      # Spaces indicate a subtitle
        comment = $.trim(message.content.substr(message.content.indexOf(" ") + 1));
        videoUrl = message.content.split(" ")[0]

      videoId = message.content.match(@options.idRegex)[1]

      thumbUrl = "http://img.youtube.com/vi/#{ videoId }/0.jpg"

      subtitle = null
      subtitle = "Youtube: #{comment}" if comment? and comment.length > 0
      subtitle ||= videoUrl

      message.content = @options.template({
        videoId: videoId
        subtitle: subtitle
      })
      return Kandan.Helpers.Activities.buildFromMessageTemplate(message)<commit_msg>Was missing a comma, not sure if it mattered though.<commit_after>class Kandan.Plugins.YouTubeEmbed

  @options:
    regex: /^http(s)?.+www.youtube.com.+watch/i
    idRegex: /\Wv=([\w|\-]*)/

    template: _.template '''
      <div class="youtube-preview">
            <iframe width="560" height="315"
                    src="http://www.youtube.com/embed/<%= videoId %>"
                    frameborder="0" allowfullscreen>
            </iframe>
        <div class="name"><%= subtitle %></div>
      </div>
    '''


  @init: ()->
    Kandan.Modifiers.register @options.regex, (message, state) =>
      comment = null

      # No spaces in message content indicates just a link
      if message.content.indexOf(" ") == -1
        videoUrl = message.content
      else
      # Spaces indicate a subtitle
        comment = $.trim(message.content.substr(message.content.indexOf(" ") + 1));

      videoId = message.content.match(@options.idRegex)[1]

      subtitle = null
      subtitle = "Youtube: #{comment}" if comment? and comment.length > 0
      subtitle ||= videoUrl

      message.content = @options.template({
        videoId: videoId,
        subtitle: subtitle
      })
      return Kandan.Helpers.Activities.buildFromMessageTemplate(message)
{'fraction_non_alphanumeric': 0.14856477889837083, 'fraction_numerical': 0.009309542280837859, 'mean_word_length': 2.3537061118335503, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '416793', 'n_tokens_mistral': 805, 'n_tokens_neox': 748, 'n_words': 165}