spotify-to-mp3 0.5.4 → 0.6.0

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.md CHANGED
@@ -4,7 +4,7 @@ A simple command line utility to download MP3 files of Spotify tracks
4
4
 
5
5
  ## Installation
6
6
 
7
- ### Mac OS X (Snow Leopard & Lion)
7
+ ### Mac OS X
8
8
 
9
9
  ```bash
10
10
  $ sudo gem install spotify-to-mp3
@@ -12,7 +12,7 @@ $ sudo gem install spotify-to-mp3
12
12
 
13
13
  Probably `sudo` can be ommited if using [rvm](http://beginrescueend.com/) or similar.
14
14
 
15
- ### Linux (Ubuntu 12.10 / 13.10)
15
+ ### Linux (Ubuntu)
16
16
 
17
17
  Make sure you have rubygems installed and configured:
18
18
 
@@ -21,37 +21,47 @@ $ sudo apt-get install rubygems1.9 ruby1.9.1-dev
21
21
  $ echo 'PATH=$PATH:/var/lib/gems/1.9/bin' | sudo tee /etc/profile.d/rubygems1.9.sh >/dev/null
22
22
  ```
23
23
 
24
- <span></span>
25
-
26
24
  ```bash
27
25
  $ sudo gem install spotify-to-mp3
28
26
  ```
29
27
 
30
- ### Windows (not tested)
31
-
32
- [Install Ruby](http://rubyinstaller.org/)
33
-
34
- ```
35
- gem install spotify-to-mp3
36
- ```
37
-
38
28
  ## Usage
39
29
 
40
- 1. Create a file (like `songs.txt`) and copy the Spotify songs URLs to it. Plain song names are also
30
+ 1. Create a file (like `songs.txt`) and copy the Spotify songs URLs to it. Plain song names are also
41
31
  accepted. It will look like this:
42
32
 
43
- http://open.spotify.com/track/1JqTcOjOn7gEpeC0JcRVPa
44
- spotify:track:1fE3ddAlmjJ99IIfLgZjTy
45
- The Drums - Money
33
+ ```
34
+ http://open.spotify.com/track/1JqTcOjOn7gEpeC0JcRVPa
35
+ spotify:track:1fE3ddAlmjJ99IIfLgZjTy
36
+ The Drums - Money
37
+ ```
46
38
 
47
39
  2. Download songs. They are saved to the current directory. Errors will appear in red (like when a song is not found).
48
40
 
49
- ```bash
50
- $ spotify-to-mp3 songs.txt
51
- ```
41
+ ```bash
42
+ $ spotify-to-mp3 songs.txt
43
+ ```
44
+
45
+ Also, as it's common in Unix programs, you can pipe in the songs:
46
+
47
+ ```bash
48
+ $ echo white knuckle ride | spotify-to-mp3
49
+ ```
50
+
51
+ or simply:
52
+
53
+ ```bash
54
+ $ spotify-to-mp3
55
+ ```
56
+
57
+ and drag the songs from the Spotify app to the terminal.
52
58
 
53
59
  ## Changelog
54
60
 
61
+ 2014-05-05
62
+
63
+ - Accept track IDs from stdin
64
+
55
65
  2012-08-20
56
66
 
57
67
  - Set filename artist and title from Grooveshark
@@ -2,6 +2,6 @@
2
2
 
3
3
  # To run it in development: bundle exec bin/spotify-to-mp3
4
4
 
5
- require 'spotify_to_mp3'
5
+ require 'spotify_to_mp3/dependency_container'
6
6
 
7
- SpotifyToMp3::DependencyInjection.new.app.run
7
+ SpotifyToMp3::DependencyContainer.new.app.run
@@ -1,3 +1,7 @@
1
+ require 'colorize'
2
+ require 'fileutils'
3
+ require 'spotify_to_mp3/app/stream_track_ids'
4
+
1
5
  module SpotifyToMp3
2
6
  class App
3
7
  def initialize(track_id_resolver, grooveshark)
@@ -6,8 +10,7 @@ module SpotifyToMp3
6
10
  end
7
11
 
8
12
  def run
9
- file = ARGV.first or raise "No songs file specified. Usage: #{$0} file"
10
- FileTrackIds.new(file).each do |track_id|
13
+ StreamTrackIds.new(ARGF).each do |track_id|
11
14
  begin
12
15
  puts "Resolving \"#{track_id}\""
13
16
  track = @track_id_resolver.resolve(track_id)
@@ -18,7 +21,7 @@ module SpotifyToMp3
18
21
  print "Found \"#{grooveshark_track}\""
19
22
  if File.exists?(grooveshark_track.filename)
20
23
  # To know about songs no longer in download list
21
- FileUtils.touch grooveshark_track.filename
24
+ FileUtils.touch grooveshark_track.filename
22
25
 
23
26
  puts ", already exists, skipping"
24
27
  else
@@ -0,0 +1,19 @@
1
+ module SpotifyToMp3
2
+ class App
3
+ class StreamTrackIds
4
+ include Enumerable
5
+
6
+ def initialize(stream)
7
+ @stream = stream
8
+ end
9
+
10
+ def each
11
+ @stream.each do |track_id|
12
+ track_id.strip!
13
+ next if track_id.empty?
14
+ yield track_id
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,11 @@
1
+ require 'grooveshark'
2
+ require 'spotify_to_mp3/app'
3
+ require 'spotify_to_mp3/grooveshark'
4
+ require 'spotify_to_mp3/spotify'
5
+ require 'spotify_to_mp3/track_id_resolver'
6
+
1
7
  module SpotifyToMp3
2
- class DependencyInjection
8
+ class DependencyContainer
3
9
  def track_id_resolver
4
10
  @track_id_resolver ||= TrackIdResolver.new(Spotify.new)
5
11
  end
@@ -1,3 +1,7 @@
1
+ require 'fileutils'
2
+ require 'rest-client'
3
+ require 'spotify_to_mp3/grooveshark/track'
4
+
1
5
  module SpotifyToMp3
2
6
  class Grooveshark
3
7
  def initialize(client)
@@ -1,3 +1,7 @@
1
+ require 'cgi'
2
+ require 'open-uri'
3
+ require 'spotify_to_mp3/spotify/track'
4
+
1
5
  module SpotifyToMp3
2
6
  class Spotify
3
7
  def get_track(uri)
@@ -1,3 +1,5 @@
1
+ require 'spotify_to_mp3/track'
2
+
1
3
  module SpotifyToMp3
2
4
  class TrackIdResolver
3
5
  def initialize(spotify)
@@ -1,4 +1,4 @@
1
- require 'spotify_to_mp3'
1
+ require 'spotify_to_mp3/app/file_track_ids'
2
2
  require 'tempfile'
3
3
 
4
4
  module SpotifyToMp3
@@ -1,10 +1,10 @@
1
- require 'spotify_to_mp3'
1
+ require 'spotify_to_mp3/dependency_container'
2
2
 
3
3
  module SpotifyToMp3
4
4
  describe Grooveshark do
5
5
  context "#get_track" do
6
6
  before(:each) do
7
- @grooveshark = DependencyInjection.new.grooveshark
7
+ @grooveshark = DependencyContainer.new.grooveshark
8
8
  end
9
9
 
10
10
  it "finds by plain query" do
@@ -1,4 +1,4 @@
1
- require 'spotify_to_mp3'
1
+ require 'spotify_to_mp3/spotify'
2
2
 
3
3
  module SpotifyToMp3
4
4
  describe Spotify do
@@ -1,9 +1,9 @@
1
- require 'spotify_to_mp3'
1
+ require 'spotify_to_mp3/dependency_container'
2
2
 
3
3
  module SpotifyToMp3
4
4
  describe TrackIdResolver do
5
5
  before(:each) do
6
- @resolver = DependencyInjection.new.track_id_resolver
6
+ @resolver = DependencyContainer.new.track_id_resolver
7
7
  end
8
8
 
9
9
  it "resolves Spotify HTTP URLs" do
@@ -2,7 +2,7 @@ Gem::Specification.new do |gem|
2
2
  gem.name = 'spotify-to-mp3'
3
3
  gem.summary = 'Spotify to MP3'
4
4
  gem.description = 'Download MP3 files of your Spotify tracks from Grooveshark'
5
- gem.version = '0.5.4'
5
+ gem.version = '0.6.0'
6
6
  gem.author = 'Francesc Rosàs'
7
7
  gem.email = 'francescrosasbosque@gmail.com'
8
8
  gem.homepage = 'https://github.com/frosas/spotify-to-mp3'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotify-to-mp3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-23 00:00:00.000000000 Z
12
+ date: 2014-05-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: grooveshark
@@ -104,10 +104,9 @@ files:
104
104
  - LICENSE
105
105
  - README.md
106
106
  - bin/spotify-to-mp3
107
- - lib/spotify_to_mp3.rb
108
107
  - lib/spotify_to_mp3/app.rb
109
- - lib/spotify_to_mp3/app/file_track_ids.rb
110
- - lib/spotify_to_mp3/dependency_injection.rb
108
+ - lib/spotify_to_mp3/app/stream_track_ids.rb
109
+ - lib/spotify_to_mp3/dependency_container.rb
111
110
  - lib/spotify_to_mp3/grooveshark.rb
112
111
  - lib/spotify_to_mp3/grooveshark/track.rb
113
112
  - lib/spotify_to_mp3/spotify.rb
@@ -1,16 +0,0 @@
1
- require 'grooveshark'
2
- require 'open-uri'
3
- require 'colorize'
4
- require 'rest-client'
5
- require 'fileutils'
6
- require 'cgi'
7
-
8
- require 'spotify_to_mp3/app'
9
- require 'spotify_to_mp3/app/file_track_ids'
10
- require 'spotify_to_mp3/dependency_injection'
11
- require 'spotify_to_mp3/spotify'
12
- require 'spotify_to_mp3/spotify/track'
13
- require 'spotify_to_mp3/track_id_resolver'
14
- require 'spotify_to_mp3/track'
15
- require 'spotify_to_mp3/grooveshark'
16
- require 'spotify_to_mp3/grooveshark/track'
@@ -1,21 +0,0 @@
1
- module SpotifyToMp3
2
- class App
3
- class FileTrackIds
4
- include Enumerable
5
-
6
- def initialize(file)
7
- @file = file
8
- end
9
-
10
- def each
11
- File.open(@file) do |file|
12
- file.each do |track_id|
13
- track_id.strip!
14
- next if track_id.empty?
15
- yield track_id
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end