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"],
|
[["-p", "--playlist"], "playlist", "string"],
|
||||||
[["-u", "--url"], "url", "string"],
|
[["-u", "--url"], "url", "string"],
|
||||||
[["-S", "--select"], "select", "bool"],
|
[["-S", "--select"], "select", "bool"],
|
||||||
[["--ask-skip"], "ask_skip", "bool"]
|
[["--ask-skip"], "ask_skip", "bool"],
|
||||||
|
[["--apply"], "apply_file", "string"]
|
||||||
]
|
]
|
||||||
|
|
||||||
@args : Hash(String, String)
|
@args : Hash(String, String)
|
||||||
|
@ -56,6 +57,7 @@ class CLI
|
||||||
#{Style.blue " "} argument is ignored, and it should be '')
|
#{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 "-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 "--ask-skip"} Before every playlist/album song, ask to skip
|
||||||
|
#{Style.blue "--apply <file>"} Apply metadata to a existing file
|
||||||
|
|
||||||
#{Style.bold "Examples:"}
|
#{Style.bold "Examples:"}
|
||||||
$ #{Style.green %(irs --song "Bohemian Rhapsody" --artist "Queen")}
|
$ #{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)
|
def grab_it(url : (String | Nil) = nil, flags = {} of String => String)
|
||||||
passed_url : (String | Nil) = flags["url"]?
|
passed_url : (String | Nil) = flags["url"]?
|
||||||
|
passed_file : (String | Nil) = flags["apply_file"]?
|
||||||
select_link = flags["select"]?
|
select_link = flags["select"]?
|
||||||
|
|
||||||
outputter("intro", 0)
|
outputter("intro", 0)
|
||||||
|
@ -92,40 +93,45 @@ class Song
|
||||||
@artist_name = data["artists"][0]["name"].as_s
|
@artist_name = data["artists"][0]["name"].as_s
|
||||||
@filename = "#{Pattern.parse(Config.filename_pattern, data)}.mp3"
|
@filename = "#{Pattern.parse(Config.filename_pattern, data)}.mp3"
|
||||||
|
|
||||||
if passed_url
|
if passed_file
|
||||||
if passed_url.strip != ""
|
puts Style.green(" +") + Style.dim(" Moving file: ") + passed_file
|
||||||
url = passed_url
|
File.rename(passed_file, @filename)
|
||||||
else
|
else
|
||||||
outputter("url", 4)
|
if passed_url
|
||||||
url = gets
|
if passed_url.strip != ""
|
||||||
if !url.nil? && url.strip == ""
|
url = passed_url
|
||||||
url = nil
|
else
|
||||||
|
outputter("url", 4)
|
||||||
|
url = gets
|
||||||
|
if !url.nil? && url.strip == ""
|
||||||
|
url = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if !url
|
|
||||||
outputter("url", 0)
|
|
||||||
url = Youtube.find_url(data, flags: flags)
|
|
||||||
if !url
|
if !url
|
||||||
raise("There was no url found on youtube for " +
|
outputter("url", 0)
|
||||||
%("#{@song_name}" by "#{@artist_name}. ) +
|
url = Youtube.find_url(data, flags: flags)
|
||||||
"Check your input and try again.")
|
if !url
|
||||||
|
raise("There was no url found on youtube for " +
|
||||||
|
%("#{@song_name}" by "#{@artist_name}. ) +
|
||||||
|
"Check your input and try again.")
|
||||||
|
end
|
||||||
|
outputter("url", 1)
|
||||||
|
else
|
||||||
|
outputter("url", 2)
|
||||||
|
url = Youtube.validate_url(url)
|
||||||
|
if !url
|
||||||
|
raise("The url is an invalid youtube URL " +
|
||||||
|
"Check the URL and try again")
|
||||||
|
end
|
||||||
|
outputter("url", 3)
|
||||||
end
|
end
|
||||||
outputter("url", 1)
|
|
||||||
else
|
|
||||||
outputter("url", 2)
|
|
||||||
url = Youtube.validate_url(url)
|
|
||||||
if !url
|
|
||||||
raise("The url is an invalid youtube URL " +
|
|
||||||
"Check the URL and try again")
|
|
||||||
end
|
|
||||||
outputter("url", 3)
|
|
||||||
end
|
|
||||||
|
|
||||||
outputter("download", 0)
|
outputter("download", 0)
|
||||||
Ripper.download_mp3(url.as(String), @filename)
|
Ripper.download_mp3(url.as(String), @filename)
|
||||||
outputter("download", 1)
|
outputter("download", 1)
|
||||||
|
end
|
||||||
|
|
||||||
outputter("albumart", 0)
|
outputter("albumart", 0)
|
||||||
temp_albumart_filename = ".tempalbumart.jpg"
|
temp_albumart_filename = ".tempalbumart.jpg"
|
||||||
|
|
Loading…
Reference in a new issue