Skip to content

illusori/bash-itunes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bash iTunes

Bash iTunes is a command-line wrapper for iTunes/Music.app, letting you easily control iTunes from the terminal or over SSH.

Since version 2.0.0, the default has been to try to control Music.app, but you can override this to control iTunes in the config file if you still run older versions of MacOS/OSX.

Currently it supports the following commands:

Navigation commands:
    play        Start or resume playing.
    pause       Pause playing.
    stop        Stop playing.
    next        Skip to next track.
    prev        Skip back to previous track.
    info        View info about current track.
    search      Search for tracks.
    shuffle     View or set shuffle status.
    repeat      View or set repeat status.
    playlist    View or choose playlist.
    playlists   List all playlists.

Volume commands:
    vol[ume]    View or adjust iTunes volume 'up', 'down' or percentage.
    mute        Mutes iTunes.
    unmute      Unmutes iTunes, restoring previous volume level.
    sysvol[ume] View or adjust system volume 'up', 'down' or percentage.
    sysmute     Mute system sound.
    sysunmute   Unmute system sound.

Application commands:
    open        Start iTunes running.
    quit        Quit iTunes.
    show        Hide the iTunes window.
    hide        Show the iTunes window.

Editing commands:
    rate        Set the iTunes star rating.
    heart       Add heart/loved status to a track.
    unheart     Remove heart/loved status from a track.
    sync        Sync ratings to or from audio files files and iTunes database.

Additional commands:
    version     Show version information and exit.
    help        Show this help and exit.
    plugins     Show a list of plugins installed.

Setup

Install the itunes script somewhere on your path, ~/bin is the usual choice, and type itunes help to get started.

Have fun.

MP3 Tags Support

If you have the Python Mutagen package installed, Bash iTunes will attempt to write any rating changes you make with itunes rate to both the iTunes database and the MP3 file.

It will also provide access to the itunes sync command that allows you to bulk sync your ratings between the iTunes database and your MP3s.

Configuration Support

You can override some configuration variables by creating a file in $HOME/.bash-itunes/config.

For example:

# If your Mutagen python package is installed somewhere weird via MacPorts or something.
id3v2_editor="mid3v2-3.10"
# If you're still running a MacOS/OSX old enough to still have iTunes rather than Music.app
itunes_app="iTunes"

Plugin Support

bash-itunes has rudimentary plugin support by creating subcommands in the $HOME/.bash-itunes/plugins directory:

  1. Create a bash script in the plugins directory named after the command name.
  2. In the main body of the script do nothing but set the PLUGIN_NAME (a full name for the plugin), PLUGIN_VERSION (the plugin version) and PLUGIN_BRIEF (an under 70-char single-line description of the plugin) variables.
  3. Create a bash function named _cmd_<plugin_name> that performs the command.

For a simple example, $HOME/.bash-itunes/plugins/party:

#!/bin/bash

PLUGIN_NAME="Party Party!"
PLUGIN_VERSION="1.0.1"
PLUGIN_BRIEF="Gets the party started in style."

function _cmd_party() {
    say -v zarvox "Party party!" &
    echo "Party party!"
}

Results in the following:

$ itunes plugins
Installed plugins:
  party - Party Party! (1.0.1)

$ itunes party
Party party!

For a more extensive tutorial on writing plugins, check the blog entry on my website: http://www.illusori.co.uk/blog/2012/06/15/bash_itunes_plugin_tutorial.html

About

Shell script to control iTunes from the command-line.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages