mirror of
https://github.com/cooperhammond/irs.git
synced 2025-01-21 06:30:57 +00:00
tagger based off of ffmpeg created
This commit is contained in:
parent
efff04947c
commit
e402bcea14
BIN
2 - Warwick Avenue.mp3
Normal file
BIN
2 - Warwick Avenue.mp3
Normal file
Binary file not shown.
10
shard.lock
10
shard.lock
|
@ -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
|
||||
|
||||
|
|
|
@ -13,5 +13,5 @@ crystal: 0.28.0
|
|||
license: MIT
|
||||
|
||||
dependencies:
|
||||
ydl_binaries:
|
||||
github: cooperhammond/ydl-binaries
|
||||
ydl_binaries:
|
||||
github: cooperhammond/ydl-binaries
|
46
src/interact/tagger.cr
Normal file
46
src/interact/tagger.cr
Normal 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()
|
Loading…
Reference in a new issue