crossfader 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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +23 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +1 -0
- data/bin/crossfader +19 -0
- data/crossfader.gemspec +28 -0
- data/lib/crossfader.rb +7 -0
- data/lib/crossfader/cli.rb +126 -0
- data/lib/crossfader/rcfile.rb +50 -0
- data/lib/crossfader/version.rb +3 -0
- metadata +147 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1a9a3ed5d6109efeacb865d5d5263e06f393c443
|
4
|
+
data.tar.gz: c9f9dcc22c7e8c88e3d314e20d0ad0b79ce106aa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2b335a4927904f71c0581ac054c84218ed4ab47b583a406bb8d837dfbe88822d451b3348a69193d0a02b8aa1a62cf8315c150de5818ca0b6e0657353137e7b4e
|
7
|
+
data.tar.gz: 3d4d864e0da662a413ac3d2f72eaa4c447b35544201708c91885973aeb35ec70fba8a583df98103759bb78d9355892a466980bcdc03f3da55e79ef80abb1fafd
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
group :development do
|
4
|
+
gem 'guard-rspec'
|
5
|
+
gem 'pry'
|
6
|
+
gem 'pry-rescue'
|
7
|
+
platforms :ruby_19, :ruby_20 do
|
8
|
+
gem 'pry-debugger'
|
9
|
+
gem 'pry-stack_explorer'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem 'coveralls', :require => false
|
15
|
+
gem 'rspec', '>= 2.14'
|
16
|
+
gem 'rubocop', '>= 0.16', :platforms => [:ruby_19, :ruby_20]
|
17
|
+
gem 'simplecov', :require => false
|
18
|
+
gem 'timecop'
|
19
|
+
gem 'webmock', '>= 1.10.1'
|
20
|
+
end
|
21
|
+
|
22
|
+
gemspec
|
23
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Adam Barber
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Crossfader
|
2
|
+
|
3
|
+
The Crossfader gem is a command line interface for the Crossfader.fm API. If you need to manage a large number of loops, then this is the tool for you.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
1. Install the LAME mp3 encoder.
|
8
|
+
2. Install this gem with `gem install crossfader`
|
9
|
+
3. Authorize this app
|
10
|
+
4. Begin managing your Crossfader library.
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
You can perform the following actions:
|
15
|
+
---
|
16
|
+
|
17
|
+
`crossfader auth` Authorize this app to work with the Crossfader.fm API.
|
18
|
+
`crossfader convert` : Convert a folder of .wav files to .mp3.
|
19
|
+
`crossfader upload` : Upload a folder of .mp3s to the server to create new loops.
|
20
|
+
`crossfader batch` : Create a new pack, convert a folder of .wav files to .mp3 files and upload them to the server in one step.
|
21
|
+
`crossfader create_pack` : Create a new empty pack.
|
22
|
+
`crossfader help` : To see this menu.
|
23
|
+
|
24
|
+
---
|
25
|
+
Have questions, comments, or feed back? Contact Adam at adam@djz.com
|
26
|
+
|
27
|
+
To get started, you must first authorize the app and get your api access token.
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/crossfader
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
Signal.trap('INT') { exit 1 }
|
4
|
+
|
5
|
+
require 'crossfader'
|
6
|
+
|
7
|
+
def pute(*args)
|
8
|
+
first = args.shift.dup
|
9
|
+
first.insert(0, "#{$PROGRAM_NAME}: ")
|
10
|
+
args.unshift(first)
|
11
|
+
$stderr.puts(*args)
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
Crossfader::CLI.start(ARGV)
|
16
|
+
rescue Interrupt
|
17
|
+
pute 'Quitting...'
|
18
|
+
exit 1
|
19
|
+
end
|
data/crossfader.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'crossfader/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "crossfader"
|
8
|
+
spec.version = Crossfader::VERSION
|
9
|
+
spec.authors = ["Adam Barber"]
|
10
|
+
spec.email = ["adam@adambarber.tv"]
|
11
|
+
spec.description = ["Crossfader allows for easy batch conversion and upload of loops for Crossfader.fm"]
|
12
|
+
spec.summary = ["Quickly convert and upload loops for Crossfader.fm"]
|
13
|
+
spec.homepage = "http://crossfader.fm"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency 'thor', ['>= 0.18.1', '< 2']
|
25
|
+
spec.add_dependency 'lame'
|
26
|
+
spec.add_dependency 'httparty'
|
27
|
+
spec.add_dependency 'httmultiparty'
|
28
|
+
end
|
data/lib/crossfader.rb
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'httmultiparty'
|
3
|
+
require 'crossfader/rcfile'
|
4
|
+
module Crossfader
|
5
|
+
class CLI < Thor
|
6
|
+
include HTTMultiParty
|
7
|
+
base_uri 'http://api.djz.com/v3'
|
8
|
+
def initialize(*)
|
9
|
+
@rcfile = Crossfader::RCFile.instance
|
10
|
+
@loop_ids = []
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'auth', 'Allow the user to get their api access token'
|
15
|
+
def auth
|
16
|
+
say "Welcome! Before you can use crossfader, you'll first need to log in"
|
17
|
+
say 'to your account and get an access token. Follow the steps below:'
|
18
|
+
email = ask 'Enter your crossdfader.fm email address: '
|
19
|
+
password = ask('Enter your crossfader.fm password: ', :echo => false)
|
20
|
+
options = { :body => {email: email, password: password } }
|
21
|
+
response = self.class.post('/users/login', options)
|
22
|
+
if response.code == 200
|
23
|
+
@rcfile[email] = { email: email, api_access_token: response['api_access_token'], dj_name: response['dj_name'] }
|
24
|
+
say "\nAuthorized successfully!\n"
|
25
|
+
else
|
26
|
+
say "\nSomething went wrong. Tell Adam.\n"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'convert', 'Batch convert .wav files to .mp3 files'
|
31
|
+
def convert
|
32
|
+
say "Let's convert wavs to MP3s!"
|
33
|
+
dir = ask('Select a folder of loops to convert: ')
|
34
|
+
dir = dir.gsub(/\\/, "").strip
|
35
|
+
Dir.foreach(dir) { |file| convert_wav_to_mp3(file, dir) }
|
36
|
+
say "The loops were converted successfully"
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'upload', 'Batch upload loops'
|
40
|
+
def upload
|
41
|
+
say "Time to upload some loops!"
|
42
|
+
dir = ask('Select a folder of loops to upload: ')
|
43
|
+
dir = dir.gsub(/\\/, "").strip
|
44
|
+
Dir.foreach(dir) { |file| create_loop_from_file(file, dir) }
|
45
|
+
say "The loops were uploaded successfully"
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'create_pack', 'Create a new pack'
|
49
|
+
def create_pack
|
50
|
+
say "Create a new pack? That's a great idea!"
|
51
|
+
pack_name = ask "What should we call this pack?"
|
52
|
+
pack_sub = ask "Enter the subtitle for this pack:"
|
53
|
+
response = create_new_pack(pack_name, pack_sub)
|
54
|
+
say response
|
55
|
+
if response.code == 200
|
56
|
+
say "Successfully created a pack named #{pack_name}"
|
57
|
+
else
|
58
|
+
say "Something went wrong."
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
desc 'help', "Show available commands."
|
63
|
+
def help
|
64
|
+
say "\nYou can perform the following actions:"
|
65
|
+
say "---\n\n"
|
66
|
+
say "\`crossfader auth\` Authorize this app to work with the Crossfader.fm API.\n"
|
67
|
+
say "\`crossfader convert\` : Convert a folder of .wav files to .mp3.\n"
|
68
|
+
say "\`crossfader upload\` : Upload a folder of .mp3s to the server to create new loops.\n"
|
69
|
+
say "\`crossfader batch\` : Create a new pack, convert a folder of .wav files to .mp3 files and upload them to the server in one step.\n"
|
70
|
+
say "\`crossfader create_pack\` : Create a new empty pack.\n\n"
|
71
|
+
say "---\n"
|
72
|
+
say "Have questions, comments, or feed back? Contact Adam at adam@djz.com\n\n"
|
73
|
+
end
|
74
|
+
|
75
|
+
desc 'batch', "Create a new pack, convert wavs to mp3s, upload mp3s/jpgs as loops, and add loops to pack."
|
76
|
+
def batch
|
77
|
+
say "Time to batch convert and upload!"
|
78
|
+
pack_name = ask "What do you want to name your new pack?"
|
79
|
+
pack_sub = ask "Enter the subtitle for this pack:"
|
80
|
+
dir = ask('Select a folder of loops to process and upload:')
|
81
|
+
clean_dir = dir.gsub(/\\/, "").strip
|
82
|
+
say clean_dir
|
83
|
+
Dir.foreach(clean_dir) { |file| convert_wav_to_mp3(file, clean_dir) }
|
84
|
+
Dir.foreach(clean_dir) { |file| create_loop_from_file(file, clean_dir) }
|
85
|
+
response = create_new_pack(pack_name, pack_sub)
|
86
|
+
if response.code == 200
|
87
|
+
say "Success!"
|
88
|
+
else
|
89
|
+
say "Something went wrong."
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def convert_wav_to_mp3(file, dir)
|
96
|
+
file_path = File.join(dir, file)
|
97
|
+
if File.file? file_path and File.extname(file_path) == ".wav"
|
98
|
+
mp3_path = "#{file_path}.mp3".gsub!('.wav', '')
|
99
|
+
system "lame -b 192 -h '#{file_path}' '#{mp3_path}'"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def create_loop_from_file(file, dir)
|
104
|
+
file_path = File.join(dir, file)
|
105
|
+
if File.file? file_path and File.extname(file_path) == ".mp3"
|
106
|
+
loop_audio = open(file_path, 'r+b')
|
107
|
+
artwork = open(file_path.gsub('.mp3', '.jpg'), 'r+b')
|
108
|
+
length, bpm, key, artist, title = file.to_s.gsub('.mp3', '').split(' - ')
|
109
|
+
headers = { 'Authorization' => "Token: #{@rcfile.api_access_token}" }
|
110
|
+
body = { title: title, type: 'loop', content: { artist_name: artist, bpm: bpm, key: key, bar_count: length, loop_type: "Instrumental Song" }, loop: loop_audio, artwork: artwork }
|
111
|
+
options = { headers: headers , body: body }
|
112
|
+
response = self.class.post('/feed_items', options)
|
113
|
+
@loop_ids << response['id']
|
114
|
+
say "New loop for #{title} created with an id of #{response['id']}"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def create_new_pack(pack_name, pack_sub)
|
119
|
+
headers = { 'Authorization' => "Token: #{@rcfile.api_access_token}" }
|
120
|
+
body = { title: pack_name, content: { subtitle: pack_sub }, type: 'pack', pack_items: @loop_ids }
|
121
|
+
options = { headers: headers , body: body }
|
122
|
+
response = self.class.post('/feed_items', options)
|
123
|
+
return response
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module Crossfader
|
4
|
+
class RCFile
|
5
|
+
include Singleton
|
6
|
+
attr_reader :path
|
7
|
+
FILE_NAME = '.crossfader'
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@path = File.join(File.expand_path('~'), FILE_NAME)
|
11
|
+
@data = load_file
|
12
|
+
end
|
13
|
+
|
14
|
+
def load_file
|
15
|
+
require 'yaml'
|
16
|
+
YAML.load_file(@path)
|
17
|
+
rescue Errno::ENOENT
|
18
|
+
default_structure
|
19
|
+
end
|
20
|
+
|
21
|
+
def []=(email, profile)
|
22
|
+
configuration['email'] = profile[:email]
|
23
|
+
configuration['api_access_token'] = profile[:api_access_token]
|
24
|
+
configuration['dj_name'] = profile[:dj_name]
|
25
|
+
write
|
26
|
+
end
|
27
|
+
|
28
|
+
def configuration
|
29
|
+
@data['configuration']
|
30
|
+
end
|
31
|
+
|
32
|
+
def api_access_token
|
33
|
+
@data['configuration']['api_access_token']
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def default_structure
|
39
|
+
{'configuration' => {}}
|
40
|
+
end
|
41
|
+
|
42
|
+
def write
|
43
|
+
require 'yaml'
|
44
|
+
File.open(@path, File::RDWR | File::TRUNC | File::CREAT, 0600) do |rcfile|
|
45
|
+
rcfile.write @data.to_yaml
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: crossfader
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Barber
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.18.1
|
48
|
+
- - <
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '2'
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 0.18.1
|
58
|
+
- - <
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: lame
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: httparty
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: httmultiparty
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
description: '["Crossfader allows for easy batch conversion and upload of loops for
|
104
|
+
Crossfader.fm"]'
|
105
|
+
email:
|
106
|
+
- adam@adambarber.tv
|
107
|
+
executables:
|
108
|
+
- crossfader
|
109
|
+
extensions: []
|
110
|
+
extra_rdoc_files: []
|
111
|
+
files:
|
112
|
+
- .gitignore
|
113
|
+
- Gemfile
|
114
|
+
- LICENSE.txt
|
115
|
+
- README.md
|
116
|
+
- Rakefile
|
117
|
+
- bin/crossfader
|
118
|
+
- crossfader.gemspec
|
119
|
+
- lib/crossfader.rb
|
120
|
+
- lib/crossfader/cli.rb
|
121
|
+
- lib/crossfader/rcfile.rb
|
122
|
+
- lib/crossfader/version.rb
|
123
|
+
homepage: http://crossfader.fm
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
|
+
metadata: {}
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
requirements: []
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 2.0.3
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: '["Quickly convert and upload loops for Crossfader.fm"]'
|
147
|
+
test_files: []
|