Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: stevenchanin/itunes-playlist-to-usb
base: 24c6fddecf
...
head fork: stevenchanin/itunes-playlist-to-usb
compare: a8ca89a822
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 16 additions and 5 deletions.
  1. +16 −5 playlist_exporter.rb
View
21 playlist_exporter.rb
@@ -79,9 +79,9 @@ def process_tracks
def add_track_to_catalog(info)
name = clean_string(info["Name"])
- album = clean_string(info["Album"][0,25])
- genre = clean_string(info["Genre"][0,20])
- track_number = info["Track Number"]
+ album = clean_string(info["Album"], 25)
+ genre = clean_string(info["Genre"], 20)
+ track_number = info["Track Number"] || 0
file_uri = URI(info["Location"])
original_file = URI.decode(file_uri.path)
@@ -91,12 +91,23 @@ def add_track_to_catalog(info)
@catalog[genre] ||= {}
@catalog[genre][album] ||= []
+ if options.verbose?
+ puts " Cataloging : #{name} / #{album} / #{genre} / #{track_number}"
+ end
target_name = "%02d-#{name}.#{file_type}" % track_number
@catalog[genre][album] << {:name => target_name, :file => original_file}
end
- def clean_string(s)
- s.gsub(/\/|\(|\)/, '_')
+ def clean_string(s, cutoff_at = nil)
+ unless s.is_a?(String)
+ s = 'Blank'
+ end
+
+ if cutoff_at
+ s = s[0, cutoff_at]
+ end
+
+ s && s.gsub(/\/|\(|\)/, '_')
end
def copy_catalog

No commit comments for this range

Something went wrong with that request. Please try again.