From bdc63b4c352f129d3c05c060e2a81b9578d01b76 Mon Sep 17 00:00:00 2001 From: imsamuka Date: Sun, 2 Jan 2022 16:57:10 -0300 Subject: [PATCH] fix --url ignoring argument on song.cr --- src/bottle/cli.cr | 6 +++--- src/glue/song.cr | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/bottle/cli.cr b/src/bottle/cli.cr index 7b2b7d3..2ff974a 100755 --- a/src/bottle/cli.cr +++ b/src/bottle/cli.cr @@ -50,9 +50,9 @@ class CLI #{Style.blue "-s, --song "} Specify song name to download #{Style.blue "-A, --album "} Specify the album name to download #{Style.blue "-p, --playlist "} Specify the playlist name to download - #{Style.blue "-u, --url []"} Specify the youtube url to download from - #{Style.blue " "} (for single songs, include as an command-line - #{Style.blue " "} argument, for albums or playlists do not) + #{Style.blue "-u, --url "} Specify the youtube url to download from + #{Style.blue " "} (for albums and playlists, the command-line + #{Style.blue " "} argument is ignored, and it should be '') #{Style.blue "-S, --select"} Use a menu to choose each song's video source #{Style.bold "Examples:"} diff --git a/src/glue/song.cr b/src/glue/song.cr index c7acdad..89ee737 100755 --- a/src/glue/song.cr +++ b/src/glue/song.cr @@ -53,12 +53,12 @@ class Song # Find, downloads, and tags the mp3 song that this class represents. # Optionally takes a youtube URL to download from - # + # # ``` # Song.new("Bohemian Rhapsody", "Queen").grab_it # ``` def grab_it(url : (String | Nil) = nil, flags = {} of String => String) - ask_url = flags["url"]? + passed_url : (String | Nil) = flags["url"] select_link = flags["select"]? outputter("intro", 0) @@ -92,11 +92,15 @@ class Song @artist_name = data["artists"][0]["name"].as_s @filename = "#{Pattern.parse(Config.filename_pattern, data)}.mp3" - if ask_url - outputter("url", 4) - url = gets - if !url.nil? && url.strip == "" - url = nil + if passed_url + if passed_url.strip != "" + url = passed_url + else + outputter("url", 4) + url = gets + if !url.nil? && url.strip == "" + url = nil + end end end @@ -130,7 +134,7 @@ class Song outputter("albumart", 0) # check if song's metadata has been modded in playlist, update artist accordingly - if data["artists"][-1]["owner"]? + if data["artists"][-1]["owner"]? @artist = data["artists"][-1]["name"].as_s else @artist = data["artists"][0]["name"].as_s