Permalink
Browse files

quick change to the selection algorithm

realized that i'd be missing all those singles that I downloaded just
because I liked just that song.

now if track is the only one in a given album, so long as it beats the
delimiter (instead of the avg + the delimiter), it also gets included.
  • Loading branch information...
plukevdh committed Mar 2, 2012
1 parent abd6602 commit 12c6b1153747f9b53d1ac813eb2ff49b07ef6b91
Showing with 5 additions and 3 deletions.
  1. +2 −0 README.md
  2. +3 −3 counter.rb
View
@@ -1,3 +1,5 @@
+> "It's like a better genius playlist generator because it makes you the genius"
+
Based on this tweet: https://twitter.com/joshaber/status/175230633033994240
__For realz.__
View
@@ -28,12 +28,12 @@ def [](value)
# get counts and reject minmax
counts = tracks.map &:playedCount
- counts -= counts.minmax unless counts.count < 2
+ counts -= counts.minmax unless counts.count < 3
- next if counts.empty? || counts == 0
+ next if counts.empty?
avg = ( counts.inject(0,&:+) / counts.count )
- tracks.select { |track| track.playedCount > (avg + DELIMITER) }
+ tracks.select { |track| track.playedCount >= (avg + DELIMITER) || ( counts.count == 1 && track.playedCount > DELIMITER ) }
end
itunes.add top_tracks.compact.map(&:location), to: itunes.sources["Library"].playlists[PLAYLIST]

0 comments on commit 12c6b11

Please sign in to comment.