<commit_before>#!/usr/bin/env ruby

# This script listens to the specified audio stream and lets you know through
# Terminal and OS X's Notification Center when the song changes.

require "shoutout"
require "terminal-notifier"
require "active_support/all"

unless ARGV[0]
  STDERR.puts "Usage: now_playing.rb [STREAM URL]"
  exit 1
end

stream = Shoutout::Stream.new(ARGV[0])

stream.connect

puts "Listening to #{stream.name}"

stream.metadata_change do |metadata|
  now_playing = [metadata.artist.titleize, metadata.song.titleize].join(" - ")

  puts "Now playing: #{now_playing}"

  TerminalNotifier.notify(now_playing,  title:    stream.name,
                                        sender:   "com.apple.iTunes",
                                        activate: "com.apple.iTunes",
                                        group:    Process.pid)
end

trap("INT") { stream.disconnect }
stream.listen<commit_msg>fixed example so it works<commit_after>#!/usr/bin/env ruby

# This script listens to the specified audio stream and lets you know through
# Terminal and OS X's Notification Center when the song changes.

require "shoutout"

unless ARGV[0]
  STDERR.puts "Usage: now_playing.rb [STREAM URL]"
  exit 1
end

stream = Shoutout::Stream.new(ARGV[0])

stream.connect

puts "Listening to #{stream.name}"

stream.metadata_change do |metadata|
  now_playing = [metadata.artist, metadata.song].join(" - ")

  puts "Now playing: #{now_playing}"

end

trap("INT") { stream.disconnect }
stream.listen
{'fraction_non_alphanumeric': 0.10873915943962642, 'fraction_numerical': 0.004002668445630421, 'mean_word_length': 3.189944134078212, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5684169', 'n_tokens_mistral': 486, 'n_tokens_neox': 454, 'n_words': 132}