mirror of
https://github.com/cooperhammond/irs.git
synced 2024-12-21 17:25:28 +00:00
add option to apply metadata in existing file
This commit is contained in:
parent
390d59b9a0
commit
61120f21b0
|
@ -22,7 +22,8 @@ class CLI
|
|||
[["-p", "--playlist"], "playlist", "string"],
|
||||
[["-u", "--url"], "url", "string"],
|
||||
[["-S", "--select"], "select", "bool"],
|
||||
[["--ask-skip"], "ask_skip", "bool"]
|
||||
[["--ask-skip"], "ask_skip", "bool"],
|
||||
[["--apply"], "apply_file", "string"]
|
||||
]
|
||||
|
||||
@args : Hash(String, String)
|
||||
|
@ -56,6 +57,7 @@ class CLI
|
|||
#{Style.blue " "} argument is ignored, and it should be '')
|
||||
#{Style.blue "-S, --select"} Use a menu to choose each song's video source
|
||||
#{Style.blue "--ask-skip"} Before every playlist/album song, ask to skip
|
||||
#{Style.blue "--apply <file>"} Apply metadata to a existing file
|
||||
|
||||
#{Style.bold "Examples:"}
|
||||
$ #{Style.green %(irs --song "Bohemian Rhapsody" --artist "Queen")}
|
||||
|
|
|
@ -59,6 +59,7 @@ class Song
|
|||
# ```
|
||||
def grab_it(url : (String | Nil) = nil, flags = {} of String => String)
|
||||
passed_url : (String | Nil) = flags["url"]?
|
||||
passed_file : (String | Nil) = flags["apply_file"]?
|
||||
select_link = flags["select"]?
|
||||
|
||||
outputter("intro", 0)
|
||||
|
@ -92,6 +93,10 @@ class Song
|
|||
@artist_name = data["artists"][0]["name"].as_s
|
||||
@filename = "#{Pattern.parse(Config.filename_pattern, data)}.mp3"
|
||||
|
||||
if passed_file
|
||||
puts Style.green(" +") + Style.dim(" Moving file: ") + passed_file
|
||||
File.rename(passed_file, @filename)
|
||||
else
|
||||
if passed_url
|
||||
if passed_url.strip != ""
|
||||
url = passed_url
|
||||
|
@ -126,6 +131,7 @@ class Song
|
|||
outputter("download", 0)
|
||||
Ripper.download_mp3(url.as(String), @filename)
|
||||
outputter("download", 1)
|
||||
end
|
||||
|
||||
outputter("albumart", 0)
|
||||
temp_albumart_filename = ".tempalbumart.jpg"
|
||||
|
|
Loading…
Reference in a new issue