if File.exist? @path
@data = JSON.parse(File.read(@path))
end
+ cleanup()
scan()
save()
+ pp @data
end
def save()
def cleanup()
files.each do |f|
- @db.delete(f) if not File.exist?(f)
+ if not File.exist?("#{ATV_ROOT}/#{f["path"]}")
+ puts "Cleanup #{f["path"]}"
+ @data.delete(f["path"])
+ end
end
end
# scan for videos
@dirs.each do |dir|
Dir.glob("#{@root}/#{dir}/**/*.{mp4,webm,ogg}").each do |f|
- short_path = f.sub(%r{[^/]+/}, '').sub("#{@root}/", '')
+ short_path = f.sub("#{@root}/", '')
next if @data[short_path]
puts f
duration = `#{CMD} \"#{f}\"`.chomp.to_f