* support for drumma boy storage jamtracks

This commit is contained in:
Seth Call 2016-03-13 16:46:09 -05:00
parent df4c0fba26
commit dbf4ae777b
4 changed files with 84 additions and 4 deletions

View File

@ -103,7 +103,7 @@ module JamRuby
# https://docs.google.com/spreadsheets/d/1dyUOjWkeU8BXwnJl-ws1Kvxq_twWEG7E78F29haYkLc/edit#gid=987457683
# cross-check against marks_approved
if JamTrackImporter.marks_approved.has_key?(jam_track.slug)
if JamTrackImporter.marks_approved && JamTrackImporter.marks_approved.has_key?(jam_track.slug)
@@log.info("Found track in mark approved list. skipping")
finish('success', 'mark@jamkazam.com created')
return
@ -515,6 +515,11 @@ module JamRuby
@storage_format == 'TimTracks'
end
def is_drumma_storage?
assert_storage_set
@storage_format == 'Drumma'
end
def assert_storage_set
raise "no storage_format set" if @storage_format.nil?
end
@ -522,7 +527,30 @@ module JamRuby
def parse_metalocation(metalocation)
# metalocation = mapped/4 Non Blondes - What's Up - 6475/meta.yml
if is_tency_storage? || is_tim_tracks_storage?
if is_drumma_storage?
suffix = '/meta.yml'
unless metalocation.end_with? suffix
finish("invalid_metalocation", "metalocation not valid #{metalocation}")
return nil
end
metalocation = metalocation[0...-suffix.length]
bits = ['audio']
first_dash = metalocation.index(' - ')
if first_dash
artist = metalocation[0...(first_dash)].strip
bits << artist
else
finish("invalid_metalocation", "metalocation not valid #{metalocation}")
return nil
end
song = metalocation[(first_dash+3)..-1].strip
bits << song
elsif is_tency_storage? || is_tim_tracks_storage?
suffix = '/meta.yml'
@ -853,6 +881,9 @@ module JamRuby
elsif is_tim_tracks_storage?
jam_track.vendor_id = metadata[:id]
jam_track.licensor = JamTrackLicensor.find_by_name!('Tim Waurick')
elsif is_drumma_storage?
jam_track.vendor_id = metadata[:id]
jam_track.licensor = JamTrackLicensor.find_by_name!('Drumma Boy')
end
jam_track.slug = metadata['slug']
if jam_track.slug.nil?
@ -1652,6 +1683,8 @@ module JamRuby
synchronize_audio_track(jam_track, tmp_dir, skip_audio_upload, track)
end
end
generate_jmep(jam_track)
rescue Exception => e
finish("sync_audio_exception", e.to_s)
return false
@ -2196,6 +2229,8 @@ module JamRuby
paris_s3_manager
elsif is_tim_tracks_storage?
tim_tracks_s3_manager
elsif is_drumma_storage?
drumma_s3_manager
else
s3_manager
end
@ -2205,6 +2240,10 @@ module JamRuby
@summaries ||= {unknown_filetype: 0, no_instrument: 0, no_part: 0, total_tracks: 0, no_instrument_detail: {}, no_precount_num: 0, no_precount_detail: [], unique_artists: SortedSet.new, multiple_masters: 0, total: 0}
end
def drumma_s3_manager
@drumma_s3_manager ||= S3Manager.new('jamkazam-drumma', APP_CONFIG.aws_access_key_id, APP_CONFIG.aws_secret_access_key)
end
def tency_s3_manager
@tency_s3_manager ||= S3Manager.new('jamkazam-tency', APP_CONFIG.aws_access_key_id, APP_CONFIG.aws_secret_access_key)
end
@ -2269,6 +2308,11 @@ module JamRuby
@storage_format == 'default'
end
def is_drumma_storage?
assert_storage_set
@storage_format == 'Drumma'
end
def is_tency_storage?
assert_storage_set
@storage_format == 'Tency'
@ -2361,6 +2405,19 @@ module JamRuby
end
end
def iterate_drumma_song_storage(&blk)
song_storage_manager.list_directories.each do |song|
@@log.debug("searching through song directory '#{song}'")
metalocation = "#{song}meta.yml"
metadata = load_metalocation(metalocation)
blk.call(metadata, metalocation)
end
end
def iterate_song_storage(&blk)
if is_tency_storage?
iterate_tency_song_storage do |metadata, metalocation|
@ -2374,6 +2431,10 @@ module JamRuby
iterate_tim_tracks_song_storage do |metadata, metalocation|
blk.call(metadata, metalocation)
end
elsif is_drumma_storage?
iterate_drumma_song_storage do |metadata, metalocation|
blk.call(metadata, metalocation)
end
else
iterate_default_song_storage do |metadata, metalocation|
blk.call(metadata, metalocation)
@ -3308,6 +3369,17 @@ module JamRuby
end
return paris_data
elsif is_drumma_storage?
data = {}
begin
data = drumma_s3_manager.read_all(metalocation)
rescue AWS::S3::Errors::NoSuchKey
return nil
end
meta = YAML.load(data)
meta[:genres] = ['r&b'] if !meta[:genres]
meta
else
begin
data = s3_manager.read_all(metalocation)

View File

@ -112,7 +112,7 @@ module JamRuby
tree.children.select(&:leaf?).collect(&:key)
end
def list_directories(prefix)
def list_directories(prefix = nil)
tree = s3_bucket.as_tree(prefix: prefix)
tree.children.select(&:branch?).collect(&:prefix)
end

View File

@ -8,5 +8,6 @@ require 'resque/tasks'
require 'resque/scheduler/tasks'
require 'sitemap_generator/tasks'
require File.expand_path('../config/application', __FILE__)
SampleApp::Application.load_tasks

View File

@ -31,6 +31,11 @@ namespace :jam_tracks do
JamTrackImporter.dry_run
end
task drumma_dry_run: :environment do |task, args|
JamTrackImporter.storage_format = 'Drumma'
JamTrackImporter.dry_run
end
task paris_create_masters: :environment do |task, args|
JamTrackImporter.storage_format = 'Paris'
JamTrackImporter.create_masters
@ -78,7 +83,9 @@ namespace :jam_tracks do
exit(1)
end
if path.start_with?('mapped')
if ENV['STORAGE_FORMAT']
JamTrackImporter.storage_format = ENV['STORAGE_FORMAT']
elsif path.start_with?('mapped')
JamTrackImporter.storage_format = 'Tency'
end