benschwarz-muxtape 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +29 -0
- data/bin/muxtape +4 -0
- data/lib/muxtape.rb +82 -0
- data/muxtape-rb.gemspec +20 -0
- metadata +82 -0
data/README
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Download your favorite muxtapes using this command line tool.
|
2
|
+
|
3
|
+
Select a 'featured' tape or bash in the name of one of your favorites.
|
4
|
+
Tracks will download and add to a new iTunes playlist.
|
5
|
+
|
6
|
+
Bits and pieces, stolen, chopped and skewed from multiple sources.
|
7
|
+
Highline CLI menus added by the prevalent `hassox`, Daniel Neighman
|
8
|
+
|
9
|
+
Mashed up and packaged by Ben Schwarz
|
10
|
+
|
11
|
+
Installation:
|
12
|
+
|
13
|
+
`gem sources -a http://gems.github.com/`
|
14
|
+
`sudo gem install benschwarz-muxtape-rb`
|
15
|
+
|
16
|
+
Usage:
|
17
|
+
|
18
|
+
Homeslice:Muxtapes ben$ muxtape
|
19
|
+
|
20
|
+
1. featured
|
21
|
+
2. custom
|
22
|
+
3. quit
|
23
|
+
Would you like to select from the featured playlists or enter your own?
|
24
|
+
2
|
25
|
+
Which One?
|
26
|
+
hiphop
|
27
|
+
Downloading HIPHOP, (remember it?)
|
28
|
+
Downloading 1 of 12
|
29
|
+
... You get the idea
|
data/bin/muxtape
ADDED
data/lib/muxtape.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'hpricot'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'ostruct'
|
6
|
+
require "appscript"
|
7
|
+
require 'highline/import'
|
8
|
+
include Appscript
|
9
|
+
|
10
|
+
def get_featured_tapes
|
11
|
+
doc = Hpricot(open("http://muxtape.com"))
|
12
|
+
(doc/"ul.featured a").map{|e| e[:href].scan(/http:\/\/(.*?).muxtape.com/); $1 }.sort
|
13
|
+
end
|
14
|
+
|
15
|
+
HighLine.track_eof = false
|
16
|
+
$terminal.page_at = 20
|
17
|
+
|
18
|
+
def choose_tape
|
19
|
+
choose do |m|
|
20
|
+
m.prompt = "Which tape would you like"
|
21
|
+
m.choices(*get_featured_tapes)
|
22
|
+
m.choice(:quit){ say("Orright... Seeya!"); exit(0)}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_tape
|
27
|
+
choose do |menu|
|
28
|
+
menu.prompt = "Would you like to select from the featured playlists or enter your own?"
|
29
|
+
menu.choice(:featured){ say("Loading List. Please Wait"); choose_tape }
|
30
|
+
menu.choice(:custom){ ask("Which One?", String)}
|
31
|
+
menu.choice(:quit){ say("Orright... Seeya!"); exit(0)}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
uri = "http://#{get_tape}.muxtape.com/"
|
37
|
+
|
38
|
+
page = Hpricot(open(uri))
|
39
|
+
|
40
|
+
muxtape = (page/:h1).inner_text
|
41
|
+
|
42
|
+
puts "Downloading #{muxtape}, (#{(page/:h2).inner_text})"
|
43
|
+
|
44
|
+
# Get the song names if need be
|
45
|
+
#song_names = (page/"li.song .name").map do |song|
|
46
|
+
# song.inner_text.strip
|
47
|
+
#end
|
48
|
+
|
49
|
+
songs = []
|
50
|
+
(page/"script").each do |script|
|
51
|
+
src = script.inner_text
|
52
|
+
if src =~ /new\s+Kettle\(\[([^\]]+)\],\[([^\]]+)\]/
|
53
|
+
ids, codes = [$1, $2].map {|a| a.gsub("'",'').split(",") }
|
54
|
+
ids.zip(codes).each do |ic|
|
55
|
+
songs << OpenStruct.new(:sid =>"#{ic[0]}.mp3", :url => "http://muxtape.s3.amazonaws.com/songs/#{ic[0]}?#{ic[1]}")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
FileUtils.mkdir_p muxtape
|
61
|
+
|
62
|
+
# Keep an array of song files to add to iTunes later
|
63
|
+
@song_files = []
|
64
|
+
|
65
|
+
songs.each_with_index do |song, index|
|
66
|
+
puts "Downloading #{index.next} of #{songs.size}"
|
67
|
+
song_file = "#{muxtape}/#{song.sid}"
|
68
|
+
open(song.url) do |f|
|
69
|
+
open(song_file,"wb") {|mp3| mp3.write f.read }
|
70
|
+
end
|
71
|
+
|
72
|
+
@song_files << song_file
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
# Add to iTunes
|
77
|
+
i_tunes = app('iTunes')
|
78
|
+
return if i_tunes.playlists[its.name.eq(muxtape)].exists #skip if exists
|
79
|
+
pl = i_tunes.make(:new => :user_playlist, :with_properties => {:name => muxtape})
|
80
|
+
@song_files.each do |sf|
|
81
|
+
i_tunes.add(MacTypes::FileURL.path(File.expand_path(File.dirname(__FILE__) + "/#{sf}")), :to => pl)
|
82
|
+
end
|
data/muxtape-rb.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "muxtape"
|
3
|
+
s.version = "0.0.1"
|
4
|
+
s.date = "2008-04-26"
|
5
|
+
s.summary = "Download your favorite muxtapes with ease"
|
6
|
+
s.email = "ben@germanforblack.com"
|
7
|
+
s.homepage = "http://github.com/benschwarz/muxtape-rb"
|
8
|
+
s.description = "A command line ruby based tool to download muxtapes from muxtape.com"
|
9
|
+
s.authors = ["Ben Schwarz"]
|
10
|
+
s.files = ["README", "muxtape-rb.gemspec", "lib/muxtape.rb", "bin/muxtape"]
|
11
|
+
|
12
|
+
# Deps
|
13
|
+
s.add_dependency("hpricot", [">= 0.6"])
|
14
|
+
s.add_dependency("highline", [">= 1.4.0"])
|
15
|
+
s.add_dependency("rb-appscript", [">= 0.5.1"])
|
16
|
+
|
17
|
+
# 'Binary' goodness
|
18
|
+
s.default_executable = 'bin/muxtape'
|
19
|
+
s.executables = ["muxtape"]
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: benschwarz-muxtape
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Schwarz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-04-26 00:00:00 -07:00
|
13
|
+
default_executable: bin/muxtape
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hpricot
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0.6"
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: highline
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 1.4.0
|
32
|
+
version:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rb-appscript
|
35
|
+
version_requirement:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.5.1
|
41
|
+
version:
|
42
|
+
description: A command line ruby based tool to download muxtapes from muxtape.com
|
43
|
+
email: ben@germanforblack.com
|
44
|
+
executables:
|
45
|
+
- muxtape
|
46
|
+
extensions: []
|
47
|
+
|
48
|
+
extra_rdoc_files: []
|
49
|
+
|
50
|
+
files:
|
51
|
+
- README
|
52
|
+
- muxtape-rb.gemspec
|
53
|
+
- lib/muxtape.rb
|
54
|
+
- bin/muxtape
|
55
|
+
has_rdoc: false
|
56
|
+
homepage: http://github.com/benschwarz/muxtape-rb
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
version:
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.0.1
|
78
|
+
signing_key:
|
79
|
+
specification_version: 2
|
80
|
+
summary: Download your favorite muxtapes with ease
|
81
|
+
test_files: []
|
82
|
+
|