Skip to content

Instantly share code, notes, and snippets.

@brookemckim
Created January 17, 2013 17:02
Show Gist options
  • Save brookemckim/4557540 to your computer and use it in GitHub Desktop.
Save brookemckim/4557540 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
folder = '/Users/bmckim/Desktop/pushConfigFiles'
applications = Dir.glob(folder + '/*')
applications.each do |app|
application_name = app.split('/').last
new_config = app + '/PushPublishMap.txt'
new_config_lines = []
streams = Dir.glob(app + '/*')
streams.each do |stream|
next unless stream.match(/\.cnfg$/)
name = stream.split('/').last.sub(/\.cnfg$/, '')
puts "Running #{application_name} - #{name}"
config = File.read(stream)
username = /AkamaiUsername:(.*$)/.match(config)[1]
password = /AkamaiPassword:(.*$)/.match(config)[1]
stream = /AkamaiDstStreamName:(.*$)/.match(config)[1]
hostname = /AkamaiHostName:(.*$)/.match(config)[1]
stream_name, stream_id = stream.split('@')
if username && password && stream_name && stream_id && hostname
new_config_lines << "#{name}={Profile:rtmp-akamai, StreamName:#{stream_name}, Akamai.StreamId:#{stream_id}, Application:EntryPoint, Host:#{hostname}, Port:1935, Username:#{username}, Password:#{password}, DebugLog:true, DebugPackets:true, Akamai.HDNetwork:false, Akamai.SendToBackupServer:false}"
else
puts "#{application_name} - #{name} Failed."
end
end
File.open(new_config, 'w+') do |f|
new_config_lines.each do |line|
f.write line
f.write "\n"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment