shpotifyisasimpleBash/ApplescripttocontrolSpotifyfromthecommandlineonaMac.
Ifyoufindthisinteresting,youshouldfollowmeonTwittertolearnabouttheotherthingsIdo.
InstallationDownloadandinstalltheSpotifydesktopapplicationifyouhaven’talready.
WithHomebrewTheeasiestwaytoinstallshpotifyisbyusingtheHomebrewpackagemanager:
brewinstallshpotifyManualinstallationIfyoudon’tuseHomebrew,youcaninstallthescriptmanuallybyfollowingafewsimplesteps:
Fetchacopyofthisrepository,eitherwithgitordownloadtheziparchive.
Navigatetothefolderwhereyoufetchedtherepository(unzipifneeded)andmakesurethefilecalledspotifyisexecutable:
cdshpotifychmod+xspotifyCopythefilespotifytoaconvenientlocationinyourPATH,orsetyourPATHtoincludethefolderwherethefileislocated.
ConnectingtoSpotify’sAPIshpotifyneedstoconnecttoSpotify’sAPIinordertofindmusicbyname.Itisverylikelyyouwantthisfeature!
Togetthistowork,youfirstneedtosignup(orinto)Spotify’sdevelopersiteandcreateanApplication.Onceyou’vedoneso,youcanfinditsClientIDandClientSecretvaluesandenterthemintoyourshpotifyconfigfileat${HOME}/.shpotify.cfg.
Besuretoquoteyourvaluesanddon’taddanyextraspaces.Whendone,itshouldlooklikethefollowing(butwithyourownvalues):
CLIENT_ID="abc01de2fghijk345lmnop"CLIENT_SECRET="qr6stu789vwxyz"UsageWithshpotifyyoucancontrolSpotifywiththefollowingcommands:
spotifyplayResumesplaybackwhereSpotifylastleftoff.spotifyplay<songname>Findsasongbynameandplaysit.spotifyplayalbum<albumname>Findsanalbumbynameandplaysit.spotifyplayartist<artistname>Findsanartistbynameandplaysit.spotifyplaylist<playlistname>Findsaplaylistbynameandplaysit.spotifyplayuri<uri>Playsongsfromspecificuri.spotifynextSkipstothenextsonginaplaylist.spotifyprevReturnstotheprevioussonginaplaylist.spotifyreplayReplaysthecurrenttrackfromthebeginning.spotifypos<time>Jumptoaspecifictime(inseconds)inthecurrentsong.spotifypausePauses(orresumes)Spotifyplayback.spotifystopStopsplayback.spotifyquitStopsplaybackandquitsSpotify.spotifyvolupIncreasesthevolumeby10%.spotifyvoldownDecreasesthevolumeby10%.spotifyvol<amount>Setsthevolumetoanamountbetween0and100.spotifyvol[show]Showsthecurrentvolume.spotifystatusShowstheplaystatus,includingthecurrentsongdetails.spotifystatusartistShowsthecurrentlyplayingartist.spotifystatusalbumShowsthecurrentlyplayingalbum.spotifystatustrackShowsthecurrentlyplayingtrack.spotifyshareDisplaysthecurrentsong'sSpotifyURLandURI.spotifyshareurlDisplaysthecurrentsong'sSpotifyURLandcopiesittotheclipboard.spotifyshareuriDisplaysthecurrentsong'sSpotifyURIandcopiesittotheclipboard.spotifytoggleshuffleTogglesshuffleplaybackmode.spotifytogglerepeatTogglesrepeatplaybackmode.AuthorsandcontributingshpotifyisprimarilywrittenandmaintainedbyHarishNarayanan.
Sinceit’sanopensourceproject,itcontainsnumerouscontributionsfrommanyhelpfulpeople,including:
JorgeColindresThomasPritchardiLanEpsteinGabrieleBonettiSeanHellerEricMartinPeterFonsecaIfyou’reinterestedincontributingtoo,pleaseconsideraddressingsomeoftheissuespeoplehavepreviouslyreportedandsubmittingapullrequest.Thankyou!
CopyrightandlicenseCopyright(c)2012–2021HarishNarayanan.
Permissionisherebygranted,freeofcharge,toanypersonobtainingacopyofthissoftwareandassociateddocumentationfiles(the"Software"),todealintheSoftwarewithoutrestriction,includingwithoutlimitationtherightstouse,copy,modify,merge,publish,distribute,sublicense,and/orsellcopiesoftheSoftware,andtopermitpersonstowhomtheSoftwareisfurnishedtodoso,subjecttothefollowingconditions:
TheabovecopyrightnoticeandthispermissionnoticeshallbeincludedinallcopiesorsubstantialportionsoftheSoftware.
THESOFTWAREISPROVIDED"ASIS",WITHOUTWARRANTYOFANYKIND,EXPRESSORIMPLIED,INCLUDINGBUTNOTLIMITEDTOTHEWARRANTIESOFMERCHANTABILITY,FITNESSFORAPARTICULARPURPOSEANDNONINFRINGEMENT.INNOEVENTSHALLTHEAUTHORSORCOPYRIGHTHOLDERSBELIABLEFORANYCLAIM,DAMAGESOROTHERLIABILITY,WHETHERINANACTIONOFCONTRACT,TORTOROTHERWISE,ARISINGFROM,OUTOFORINCONNECTIONWITHTHESOFTWAREORTHEUSEOROTHERDEALINGSINTHESOFTWARE.
评论