Last active
August 29, 2015 14:16
-
-
Save alexdunae/dde7e981b3aa90e2582d to your computer and use it in GitHub Desktop.
IMG 240: Loudcloud seeds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Song.destroy_all | |
| soundcloud_data = [] | |
| soundcloud_data << OpenStruct.new(title: 'Deep Electronics #71 - Faidel', track: '189683856') | |
| soundcloud_data << OpenStruct.new(title: 'SP 109 Deepmeister', track: '176212562') | |
| soundcloud_data << OpenStruct.new(title: 'Casiokids - Det Haster!', track: '24255336') | |
| soundcloud_data << OpenStruct.new(title: 'Fetty Wap - Trap Queen', track: '155798913') | |
| soundcloud_data << OpenStruct.new(title: 'Jon Hopkins - Form by Firelight', track: '170000664') | |
| soundcloud_data << OpenStruct.new(title: 'Major Lazer & DJ Snake - Lean On (feat. MØ)', track: '193781466') | |
| soundcloud_data << OpenStruct.new(title: 'Zero 7 vs Mos Def - Umi Says', track: '21694756') | |
| def soundcloud_html(data) | |
| html = <<-HTML | |
| <iframe | |
| width="100%" height="300" scrolling="no" frameborder="no" | |
| src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/#{data.track}&default_height=200&auto_play=false&hide_related=true&show_comments=false&show_user=true&show_reposts=false&visual=true"> | |
| </iframe> | |
| HTML | |
| html.strip.gsub(/\s+/, ' ') | |
| end | |
| soundcloud_data.each do |data| | |
| puts "Creating #{data.title}" | |
| song = Song.create!( | |
| title: data.title, | |
| embed_code: soundcloud_html(data) | |
| ) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment