alexanderepstein / Bash-Snippets

A collection of small bash scripts for heavy terminal users
MIT License
9.57k stars 845 forks source link

Lyrics script fails when it finds the lyrics #218

Open Hickory420 opened 4 years ago

Hickory420 commented 4 years ago

Issue Label:

Description:

If its a bug make sure to include this section.

OS and OS version:

OS Version: uname -a Darwin MacBook-Pro 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64

Issue is with lyrics It doesn't successfully output the lyrics. There is something wrong with the logic in checking if the variable $lyrics is populated. See output below

$ bash -x lyrics -a street sweeper social club -s clap for the killers
+ currentVersion=1.23.0
+ configuredClient=
+ artist=false
+ song=false
+ filePath=
++ uname
+ [[ Darwin != \D\a\r\w\i\n ]]
+ getopts f:a:s:uvh opt
+ case "$opt" in
+ artist=true
++ echo -a street sweeper social club -s clap for the killers
++ grep -Eo '\-s'
+ [[ -s == \-\s ]]
+ song=true
++ echo -a street sweeper social club -s clap for the killers
++ grep -Eo '\-f'
+ [[ '' == \-\f ]]
+ getopts f:a:s:uvh opt
+ [[ 10 == \0 ]]
+ [[ 10 == \1 ]]
+ true
+ true
+ true
+ true
+ true
+ true
++ echo -a street sweeper social club -s clap for the killers
++ grep -Eo '\-s [ a-z A-Z 0-9 . \ ]*[ -]?'
++ sed s/-s//g
++ sed s/-//g
++ sed 's/^ //g'
+ song='clap for the killers'
+ [[ clap for the killers == '' ]]
++ echo -a street sweeper social club -s clap for the killers
++ grep -Eo '\-a [ a-z A-Z 0-9 . \ ]*[ -]?'
++ sed s/-a//g
++ sed s/-//g
++ sed 's/^ //g'
+ artist='street sweeper social club '
+ [[ street sweeper social club  == '' ]]
+ getConfiguredClient
+ command -v curl
+ configuredClient=curl
++ uname
+ [[ Darwin != \D\a\r\w\i\n ]]
+ checkInternet
+ httpGet github.com
+ getLyrics 'street sweeper social club ' 'clap for the killers'
++ echo street sweeper social club
++ sed 's/ /%20/g'
++ sed 's/&/%26/g'
++ sed s/,/%2C/g
++ sed s/-/%2D/g
+ encodedArtist=street%20sweeper%20social%20club
++ echo clap for the killers
++ sed 's/ /%20/g'
++ sed 's/&/%26/g'
++ sed s/,/%2C/g
++ sed s/-/%2D/g
+ encodedSong=clap%20for%20the%20killers
++ httpGet https://api.lyrics.ovh/v1/street%20sweeper%20social%20club/clap%20for%20the%20killers
++ case "$configuredClient" in
++ curl -A curl -s https://api.lyrics.ovh/v1/street%20sweeper%20social%20club/clap%20for%20the%20killers
+ response='{"lyrics":"Now can you clap for the killers?\nGive it up for them gangsters\nOne time for the killers\nDouble up for them gangsters\n\nWell I wrote this for criminals\nBut all of y'\''all should listen at me\nNow if you ever catch me snitchin'\''\nJust haul off and slap me\n\nThey on the other team\n\"Let'\''s rumble,\" is my thoughts exactly\nThey work for gangsters\nAnd they whacked Fred Hampton Jr.'\''s pappy\n\nAy playboy, pop '\''em with a pistol and get executed\nAy mama, murder '\''em with missiles and you get saluted\nGo '\''head and gank em for a grand, it'\''s DNA computed\nBut bankers bathe in the Bahamas off of billions looted\n\nNow can you clap?\nNow can you clap?\n\nNow can you clap for them killers?\nGive it up for them gangsters\nOne time for the killers\nDouble up for them gangsters\n\nWell I wrote this for criminals\nBut they the ones who wrote the laws\nThey ain'\''t on TV gettin'\'' arrested\nAll up in their draws\n\nThey stick their hands up politicians\nMake '\''em move their jaws\nAnd they be starving folks for bread\nUntil their breath pause\n\nAy take a memo Moneypenny, say the deed is done\nAnd you can bcc DC and say our leaders won\nBut first we fax the photograph of the opponents son\nAdjust the image, '\''cause it'\''s hard to see the gag and gun\n\nNow can you clap?\nNow can you clap?\nNow can you clap?\nNow can you clap?\n\nNow can you clap for them killers?\nGive it up for them gangsters\nOne time for the killers\nDouble up for them gangsters\n\nWell I wrote this for gangsters\nWhile I sprinted through your backyard\nNot for them Coppola criminals, they just act hard\nTony Montana had a stylist and a SAG card\nWhen he reloaded slaves forgot they had back scars\n\nAy, M-M-Mister DeNiro what kind of gun is that?\nCan you look more like a menace?\nTake two, now run it back\nAy s-s-so what Scorsese, got all them money stacks\nLong as his lens never looks at the real maniacs\n\nClap for them killers\nGive it up for them gangsters\nOne time for the killers\nDouble up for them gangsters\n\nCan you clap for them killers?\nGive it up for them gangsters\nOne time for the killers\nDouble up for them gangsters"}'
++ AccessJsonElement '{"lyrics":"Now' can you clap for the 'killers?\nGive' it up for them 'gangsters\nOne' time for the 'killers\nDouble' up for them 'gangsters\n\nWell' I wrote this for 'criminals\nBut' all of 'y'\''all' should listen at 'me\nNow' if you ever catch me 'snitchin'\''\nJust' haul off and slap 'me\n\nThey' on the other 'team\n\"Let'\''s' 'rumble,\"' is my thoughts 'exactly\nThey' work for 'gangsters\nAnd' they whacked Fred Hampton 'Jr.'\''s' 'pappy\n\nAy' playboy, pop ''\''em' with a pistol and get 'executed\nAy' mama, murder ''\''em' with missiles and you get 'saluted\nGo' ''\''head' and gank em for a grand, 'it'\''s' DNA 'computed\nBut' bankers bathe in the Bahamas off of billions 'looted\n\nNow' can you 'clap?\nNow' can you 'clap?\n\nNow' can you clap for them 'killers?\nGive' it up for them 'gangsters\nOne' time for the 'killers\nDouble' up for them 'gangsters\n\nWell' I wrote this for 'criminals\nBut' they the ones who wrote the 'laws\nThey' 'ain'\''t' on TV 'gettin'\''' 'arrested\nAll' up in their 'draws\n\nThey' stick their hands up 'politicians\nMake' ''\''em' move their 'jaws\nAnd' they be starving folks for 'bread\nUntil' their breath 'pause\n\nAy' take a memo Moneypenny, say the deed is 'done\nAnd' you can bcc DC and say our leaders 'won\nBut' first we fax the photograph of the opponents 'son\nAdjust' the image, ''\''cause' 'it'\''s' hard to see the gag and 'gun\n\nNow' can you 'clap?\nNow' can you 'clap?\nNow' can you 'clap?\nNow' can you 'clap?\n\nNow' can you clap for them 'killers?\nGive' it up for them 'gangsters\nOne' time for the 'killers\nDouble' up for them 'gangsters\n\nWell' I wrote this for 'gangsters\nWhile' I sprinted through your 'backyard\nNot' for them Coppola criminals, they just act 'hard\nTony' Montana had a stylist and a SAG 'card\nWhen' he reloaded slaves forgot they had back 'scars\n\nAy,' M-M-Mister DeNiro what kind of gun is 'that?\nCan' you look more like a 'menace?\nTake' two, now run it 'back\nAy' s-s-so what Scorsese, got all them money 'stacks\nLong' as his lens never looks at the real 'maniacs\n\nClap' for them 'killers\nGive' it up for them 'gangsters\nOne' time for the 'killers\nDouble' up for them 'gangsters\n\nCan' you clap for them 'killers?\nGive' it up for them 'gangsters\nOne' time for the 'killers\nDouble' up for them 'gangsters"}' lyrics
+ lyrics=
+ [[ '' == '' ]]
+ echo 'Error: no lyrics found!'
Error: no lyrics found!
+ return 1
+ exit 1
Hickory420 commented 4 years ago

This applies to any artist and song...

alexanderepstein commented 4 years ago

Looks like the lyrics extraction is failing, will have to look into this. Thanks for the heads up 👍

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically closed because it has been inactive for 30 days.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically closed because it has been inactive for 30 days.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically closed because it has been inactive for 30 days.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been automatically closed because it has been inactive for 30 days.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been automatically closed because it has been inactive for 30 days.

navanchauhan commented 3 years ago

I think the API is rate limited. I ran the script once and it successfully printed the lyrics, but instantly running it again gave the error