何かやってみるブログ

興味をもったこと、趣味のこと、技術について色々書きます。

[メモ] oh-my-zshのosx pluginを使ってspotifyの音楽を操作する

oh-my-zshというリポジトリを眺めてたら、spotifyを操作できるCLIツールをosx pluginが提供してくれているということを見つけたので試してみた。

github.com

設定

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(... osx)

使い方

使い方はhelpを見れば分かる。音楽をsearchするときに設定が必要。

 spotify
Usage:

  showHelp <command>

Commands:

  play                         # Resumes playback where Spotify last left off.
  play <song name>             # Finds a song by name and plays it.
  play album <album name>      # Finds an album by name and plays it.
  play artist <artist name>    # Finds an artist by name and plays it.
  play list <playlist name>    # Finds a playlist by name and plays it.
  play uri <uri>               # Play songs from specific uri.

  next                         # Skips to the next song in a playlist.
  prev                         # Returns to the previous song in a playlist.
  replay                       # Replays the current track from the beginning.
  pos <time>                   # Jumps to a time (in secs) in the current song.
  pause                        # Pauses (or resumes) Spotify playback.
  stop                         # Stops playback.
  quit                         # Stops playback and quits Spotify.

  vol up                       # Increases the volume by 10%.
  vol down                     # Decreases the volume by 10%.
  vol <amount>                 # Sets the volume to an amount between 0 and 100.
  vol [show]                   # Shows the current Spotify volume.

  status                       # Shows the current player status.
  status artist                # Shows the currently playing artist.
  status album                 # Shows the currently playing album.
  status track                 # Shows the currently playing track.

  share                        # Displays the current song's Spotify URL and URI.
  share url                    # Displays the current song's Spotify URL and copies it to the clipboard.
  share uri                    # Displays the current song's Spotify URI and copies it to the clipboard.

  toggle shuffle               # Toggles shuffle playback mode.
  toggle repeat                # Toggles repeat playback mode.

Connecting to Spotify's API:

  This command line application needs to connect to Spotify's API in order to
  find music by name. It is very likely you want this feature!

  To get this to work, you need to sign up (or in) and create an 'Application' at:
  https://developer.spotify.com/my-applications/#!/applications/create

  Once you've created an application, find the 'Client ID' and 'Client Secret'
  values, and enter them into your shpotify config file at '/Users/t-sugiyama/.shpotify.cfg'

  Be sure to quote your values and don't add any extra spaces!
  When done, it should look like this (but with your own values):
  CLIENT_ID="abc01de2fghijk345lmnop"
  CLIENT_SECRET="qr6stu789vwxyz"

感想

RubuildとかドングリFMといったポッドキャストを操作できたら良いなぁと思っていたがポッドキャストには対応していないみたいだった。 SpotifyのReferenceを調べてみたらポッドキャストの情報を取得できるAPI(Episodes API) が提供されているみたいなので、自分でCLIアプリを作ってみても良いかもしれないなぁと思った。

developer.spotify.com

open.spotify.com

open.spotify.com

natsumeg.blog.jp