spotify-music-importer 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +0 -4
- data/README.md +1 -1
- data/Rakefile +2 -0
- data/bin/spotify-music-importer +13 -36
- data/lib/spotify/music/importer.rb +12 -8
- data/lib/spotify/music/importer/version.rb +1 -1
- data/spotify-music-importer.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b515ce34364f422408aff7ba94df8d0baf87b652
|
4
|
+
data.tar.gz: 9c658d923536dbf56ca066e9bfa4266b7b885789
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1f3e6c13eb6cb2434bcd1bc6df9d69d54d91ddb85298e0ed0faf3a9b9bd81c734ad061d7fe56d594897d9388eddefa76ed92218f5867e2d942a8837d13c3c56
|
7
|
+
data.tar.gz: e644443e1da4970aa370ea4e90f78361e514508d7e774a0a648792cb7f8c24c8e31ef3c7f7d296e61ae77118e2329b3bad9d5cc1e19883c5e338bf9c3c35d6c4
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -9,7 +9,7 @@ If you want to import your library of music into spotify, this will help. It use
|
|
9
9
|
## Usage
|
10
10
|
|
11
11
|
```sh
|
12
|
-
bundle exec
|
12
|
+
bundle exec spotify-music-importer import -f CSV_FILE -t SPOTIFY_ACCESS_TOKEN
|
13
13
|
```
|
14
14
|
|
15
15
|
## Contributing
|
data/Rakefile
CHANGED
data/bin/spotify-music-importer
CHANGED
@@ -1,42 +1,19 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require 'optparse'
|
3
|
+
require 'thor'
|
6
4
|
require 'spotify/music/importer'
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
options[:
|
18
|
-
end
|
19
|
-
|
20
|
-
opts.on("-l", "--limit LIMIT", "Limit the number of lines to import") do |limit|
|
21
|
-
options[:limit] = limit.to_i
|
22
|
-
end
|
23
|
-
|
24
|
-
opts.on("-s", "--skip SKIP", "Skip the first X lines of import") do |skip|
|
25
|
-
options[:skip] = skip.to_i
|
26
|
-
end
|
27
|
-
|
28
|
-
opts.on("-t", "--access-token ACCESS_TOKEN", "Your access token to access the Spotify API. Find one here: https://developer.spotify.com/web-api/console/") do |token|
|
29
|
-
options[:access_token] = token
|
30
|
-
end
|
31
|
-
|
32
|
-
end.parse!
|
33
|
-
|
34
|
-
importer = Spotify::Music::Importer::Cli.new
|
35
|
-
importer.import(options[:filename], options)
|
36
|
-
|
37
|
-
if options[:missing]
|
38
|
-
File.open(options[:missing], 'w') do |f|
|
39
|
-
puts "Writing to file #{options[:missing]}"
|
40
|
-
f.write(JSON.pretty_generate(importer.missing))
|
6
|
+
class Spotify::Music::Importer::CLI < Thor
|
7
|
+
option :filename, :required => true, :aliases => :f, :desc => "The filename to import"
|
8
|
+
option :missing, :aliases => :m, :desc => 'The output filename of bad matches'
|
9
|
+
option :limit, :aliases => :l, :desc => "Limit the number of lines to import"
|
10
|
+
option :skip, :aliases => :s, :default => 0, :desc => "Skip the first X lines of import"
|
11
|
+
option :access_token, :required => true, :aliases => :t, :desc => "Your access token to access the Spotify API. Find one here: https://developer.spotify.com/web-api/console/"
|
12
|
+
desc 'import', "Import your music library into spotify"
|
13
|
+
def import
|
14
|
+
importer = Spotify::Music::Importer::Processor.new
|
15
|
+
importer.import(options[:filename], options)
|
41
16
|
end
|
42
17
|
end
|
18
|
+
|
19
|
+
Spotify::Music::Importer::CLI.start
|
@@ -6,19 +6,16 @@ require 'colorize'
|
|
6
6
|
require 'csv'
|
7
7
|
require 'spotify-client'
|
8
8
|
|
9
|
-
|
10
9
|
module Spotify
|
11
10
|
module Music
|
12
11
|
module Importer
|
13
|
-
class
|
14
|
-
def initialize
|
15
|
-
end
|
16
|
-
|
12
|
+
class Processor
|
17
13
|
def import(filename, options)
|
18
|
-
@options = options
|
14
|
+
@options = options.dup
|
19
15
|
@library = SpotifyLibrary.new(client)
|
20
|
-
|
21
|
-
|
16
|
+
require 'pry' ; binding.pry
|
17
|
+
limit = options.fetch(:limit) { nil }
|
18
|
+
skip = options.fetch(:skip) { 0 }
|
22
19
|
|
23
20
|
collection = CSV.read(filename, :headers => true)
|
24
21
|
collection.each_with_index do |row, index|
|
@@ -29,6 +26,13 @@ module Spotify
|
|
29
26
|
results = SpotifyMatch.new(client.search(:track, format_query(record)), :clean_album => true, :clean_track => true)
|
30
27
|
@library.find_and_add_to_library(record, results, index)
|
31
28
|
end
|
29
|
+
|
30
|
+
if options[:missing]
|
31
|
+
File.open(options[:missing], 'w') do |f|
|
32
|
+
puts "Writing to file #{options[:missing]}"
|
33
|
+
f.write(JSON.pretty_generate(importer.missing))
|
34
|
+
end
|
35
|
+
end
|
32
36
|
end
|
33
37
|
|
34
38
|
def missing
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spotify-music-importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: thor
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description:
|
84
98
|
email:
|
85
99
|
- nathan@globalphobia.com
|