Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. Dir.chdir(File.dirname(__FILE__))
  4.  
  5. # IPod-Shuffle-4g ignores aiff files and besides, they are really, really big.
  6. # (The originals are about 10 times bigger than the output mp3 after the conversion.)
  7. # 57M vs. 5,2M
  8. Dir.glob('**/*.aiff').each do |path|
  9. command = "ffmpeg -i '#{path}' '#{path.sub('.aiff', '.mp3')}' && rm '#{path}'"
  10. puts "~ #{command}"; system(command)
  11. end
  12.  
  13. # The --rename-unicode option of ipod-shuffle-4g.py doesn't work.
  14. OK_FOLDERS = ['1 Lifeflow']
  15.  
  16. Dir.glob('**/*.mp3').each do |path|
  17. next if OK_FOLDERS.include?(File.dirname(path))
  18. random = Array.new(8) { rand(256) }.pack('C*').unpack('H*').first
  19. extension = path.split('.').last.downcase
  20. new_path = [File.dirname(path), "#{random}.#{extension}"].join('/')
  21.  
  22. unless path.match(/\/[\w\d]{16}\.mp3$/)
  23. puts "~ Renaming '#{path}' to '#{new_path}'."
  24. File.rename(path, new_path)
  25. end
  26. end
  27.  
  28. options = %w{--track-gain 33 --auto-dir-playlists --verbose}
  29. system("IPod-Shuffle-4g/ipod-shuffle-4g.py --track-voiceover --rename-unicode #{options.join(' ')} .")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement