tagger based off of ffmpeg created

This commit is contained in:
Cooper Hammond 2019-06-14 11:39:51 -07:00
parent f82affb589
commit 219cc4bc53
3 changed files with 55 additions and 5 deletions

View file

@ -1,6 +1,10 @@
version: 1.0
shards:
spotify:
github: marceloboeira/spotify.cr
commit: 347727a4ebe4f3f4e55f6032de17cdd554a676bd
cr-taglib:
github: teknomunk/cr-taglib
commit: 5bfca75aaac31c0e4eee4c6e0d72c624af773c09
ydl_binaries:
github: cooperhammond/ydl-binaries
commit: 8a622bf9d2c0b848db8d8db2f46f09334a1f03f8

46
src/interact/tagger.cr Normal file
View file

@ -0,0 +1,46 @@
# TODO: write comments/documentation
class Tags
@BIN_LOC = Path["~/.irs/bin".sub("~", Path.home)]
@query_args = [] of String
def initialize(@filename : String)
if !File.exists?(@filename)
raise "MP3 not found at location: #{@filename}"
end
@query_args.push(%(-i "#{@filename}"))
end
def add_text_tag(key : String, value : String)
@query_args.push(%(-metadata #{key}="#{value}"))
end
def add_album_art(image_location : String)
if !File.exists?(image_location)
raise "Image file not found at location: #{image_location}"
end
@query_args.push(%(-i "#{image_location}"))
@query_args.push("-map 0:0 -map 1:0")
@query_args.push("-c copy")
@query_args.push("-id3v2_version 3")
@query_args.push(%(-metadata:s:v title="Album cover"))
@query_args.push(%(-metadata:s:v comment="Cover (front)"))
@query_args.push(%(-metadata:s:v title="Album cover"))
end
def save
@query_args.push(%("#{@filename}"))
command = @BIN_LOC.to_s + "/ffmpeg " + @query_args.join(" ")
puts command
end
end
# a = Tags.new("test.mp3")
# a.add_text_tag("title", "Warwick Avenue")
# a.add_album_art("file.png")
# a.save()