Coder Social home page Coder Social logo

mammoth's Introduction

Mammoth

As developers, we spend a lot of time working in the terminal, so if we are sharing music with other developers at the office for example, it would be very helpful if each of us could control the music from the terminal.

Mammoth allows us to manage Rdio's native application from the terminal, from any computer in the LAN.

This only works on OS X systems, is tested on version 10.8.3.

What do we need?

  1. A Rdio premium account.
  2. A Server computer, for handling the terminal's requests and where the music will be played.
  3. Computers that will control the music from terminal.

Server side

The guy who will host the Rdio application and Mammoth server, needs:

  • Rdio native application, sure.
  • Rdio API Keys from developer site.
  • Set Rdio API Keys in rdio_consumer_credentials.rb.
# rdio_consumer_credentials.rb
RDIO_CONSUMER_KEY    = 'foo'
RDIO_CONSUMER_SECRET = 'bar'
RDIO_TOKENS          =  []     # Leave this empty
  • Run ruby setup.rb - this gets Rdio's oauth tokens (First time only).
  • Run ruby web.rb - this handles terminal's requests (Run every time you want to use mammoth).
  • Open Rdio.

I recommend to enable "Autoplay" function in Rdio App, this will avoid the music to stop playing.

Client side

User who want to manage the music from his terminal, needs:

  1. Set the rdio_server_ip variable at the mammoth.plugin.zsh, to the server ip (remember adding the ports).
  2. If you use zsh, add the mammoth folder containing the zsh plugin to ~/.oh-my-zsh/custom/plugins/ and don't forget to add mammoth to the plugins line at ~/.zshrc. If you don't use zsh, you can copy mammoth.plugin.zsh to ~/ directory and add this line source ~/.mammoth.plugin.zsh to your ~/.bashrc or ~/.bash_profile.
  3. Open a new terminal tab.

You are ready to go!

If you are the server guy, you can also install the zsh plugin and enjoy the play random function.

Usage

After finishing Client side step 3, we can use these functions on our terminal:

  • play
  • pause
  • next
  • previous
  • song

If you are not running web.rb, each command will return: Sinatra app is off.

Play

With this command we can unpause, search and play tracks.

$ play [query] [-p play]

The query argument contains the key words that you want to search in Rdio, use quotes for compounds queries.

$ play               # this will unpause the player
$ play Artist        # search tracks for "Artist"
... 
$ play Song          # search tracks for "Song"
... 
$ play "Song Artist" # search tracks for "Song Artist", is more likely to find a perfect match
... 

This command will return a list of tracks, with id, name and artist:

$ play "Hello world"
====0====            # id: 0
name  : Hello
artist: Artist.1     
====1====            # id: 1
name  : Hello World          
artist: Artist.2     
    ...

The -p flag, let us specify the song that we want to play, by passing the song id as argument $ play song -p id .

$ play "foo ba"     # Search for a song

====0====
name  : foo
artist: bar
====1====
name  : foo
artist: Baz
====2====
name  : foo
artist: Bar

$ play "foo ba" -p 2 # Play the song with id: 2
Now playing: foo - Baz

And last but not least, we have the play random function, that will play a random song from the heavy rotation list.

$ play random
... # new song info

Pause

Pause track

$ pause

Next

Play the next track

$ next
... # New song info

Previous

Play previous track

$ previous
... # New song info

Current track info

Display current song info.

$ song
======
Artist: Hello
  Song: World
======

MISC

If you need to renew your Rdio Application tokens, just use:

$ ruby setup.rb --renew-tokens

And restart your web.rb server.

TODO

  • Make an easy way to set server ip address in the bash script.
  • Windows compatible.
  • Linux compatible.

Author

Sebastian Vera: @verax_

Credits

Credits to Rdio, that provides the ruby Rdio API Handler, called rdio-simple for Ruby.

Licence

Licensed under MIT

mammoth's People

Contributors

sebastianvera avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.