Social Media from the Command Line, Part 3: Tumblr, Flickr, and YouTube

In the first installment of this article series, we taught you the basics of managing your Facebook and Twitter accounts from the command line. In the second installment, we introduced you to GoogleCL for managing your Google services. This time we’re going to talk about some text-mode applications for Tumblr, Flickr, and YouTube.


Although there’s more than one command-line Tumblr client in existence, the one I recommend is a Ruby gem called Tumblr-rb. It’s the only one I know of that supports YAML Ain’t Markup Language (YAML), which is a clean, human-readable way to format documents.


You must first install Ruby and RubyGems. Once that’s out of the way, you can grab Tumblr-rb with a single command:

gem install tumblr-rb

Now symlink the gem so you can use it without having to type out the complete file path every time:

sudo ln -s ~/.gem/ruby/1.8/bin/tumblr /usr/bin/tumblr

Finally, there are a couple of steps required to authorize Tumblr-rb to access your Tumblr account. You need to first register a Tumblr application; you can call it anything you want. The important thing is to get the OAuth consumer key and the secret key. Once you have those, run:

tumblr authorize

You’ll be taken to a page that looks like this:


Enter your credentials and wait for the success message. Now you can use Tumblr-rb.


Tumblr-rb has an online manual as well as some more developer-oriented documentation. Here is a quick reference for some of the commands you can run:

  • Make a text post:
    tumblr post my-formatted-post.txt
  • Post a URL and put it in your queue:
    tumblr post -q
  • Post a multimedia (image, audio, or video) file and save it as a draft:
    tumblr post -d my-new-song.wav
  • Post text from STDIN:
    tumblr post "I'm posting to Tumblr from my Raspberry Pi!"
  • Post from STDIN using a YAML file:
    cat data.yaml pretty-post.txt | tumblr

You can add metadata to your posts by incorporating YAML front-matter. Here’s an example:


Flickr is a simple Flickr client written in Python. It will allow you to upload image files from a local folder to your Flickr account.


First of all, you need Python 2.*. Now download the latest sources from GitHub:

git clone

Before proceeding, sign into this Flickr page in your browser to get an API key. Click on “Apply for a non-commercial key.”


Fill out the application with any name and description you want and agree to the terms at the bottom. Once you submit your application, you’ll get a key and a secret. Add these lines to your “~/.bashrc”, replacing “[key]” and “[secret]” appropriately, so that your system will remember them from one session to the next:

export FLICKR_UPLOADR_PY_SECRET='[secret]'

Start a new shell session to make the changes take effect. Enter the directory you downloaded from GitHub and the subdirectory “uploadr.” Run:

python ./

Substitute python with your 2.* version of Python, such as python2.7, if your default version is 3.*. This command will open an authorization page in your browser. Click “OK, I’ll authorize it.” Now we’re ready to roll!


Well, almost ready to roll. We need to edit a few lines in to give the program some instructions. On line 56, specify the directory your images are stored in:

IMG_DIR = "~/Pictures/PhotosForFLickr/"

You can also set it up to receive command-line arguments for the title, description, and tags:

"title"      : sys.argv[1],
"description": sys.argv[2],
"tags"       : sys.argv[3],
"is_public"  : "1",
"is_friend"  : "0",
"is_family"  : "0"}


Now you can upload the images from your chosen directory with a title, description, and tags:

python "Screenshot" "This is a screenshot." "screenshots, Linux"


Previously, we covered how to manage your YouTube account using GoogleCL. But what if you just want to be a consumer, not a producer? For simply watching YouTube videos from the command line, there are two notable tools: youtube-dl and youtube-viewer.

If you’re using Linux, you can probably install both of these tools with your package manager. Alternatively, you can grab the sources from GitHub and install them yourself:

Youtube-dl (requires Python 2.*):

git clone


git clone

Usage (youtube-dl):

Youtube-dl is a video downloader. All of its options have been explained. Some basic examples include:

  • Just download a video in the default FLV format:
  • Download a video in MP4 format and use the title for the file name:
    youtube-dl -f 18 -t
  • View all available formats and their codes for a video:
    youtube-dl -F
  • Download the audio from a video:
    youtube-dl --extract-audio --audio-format "vorbis"

Once you’ve downloaded a video, you can watch it in a terminal using MPlayer with an ASCII art library such as AAlib (for monochrome playback) or libcaca (for viewing in color). For example:

mplayer -vo caca videofile.flv


Usage (youtube-viewer):

Unlike youtube-dl, youtube-viewer is interactive. When you enter the command youtube-viewer, you’ll be taken to an interactive prompt where you can search for videos or enter :h for help. Searching will return the top twenty results.


To watch a video, enter its number into the prompt. You may initially get the mplayer: could not connect to socket error; just give it a moment, and the video will start playing.


If you are using youtube-viewer from a text-only console, as opposed to a terminal emulator (any “terminal” run in an X session is actually a terminal emulator), youtube-viewer will automatically play videos with aalib. Depending on the size of your console, the picture may get distorted. For example, here I split the screen using Tmux for the purpose of grabbing a screenshot, and the video appeared elongated:


These are some other commands you can run inside youtube-viewer:

  • Log in:
  • Show a video author’s latest uploads:
  • Like or dislike a video:
  • Subscribe to an author’s channel:
  • Show related videos:
  • Play videos from your search results in a specific order:
    3-5, 8 10 7 1
  • Download a video:


Congratulations! You’ve reached the end of the article series “Social Media from the Command Line.” Now go SSH into that headless server (because everyone has one, right?) and work your magic! Tell us in the comments about your experiences using command-line social media tools and which ones are your favorites. Are there any other online services you wish you could access from the command line?

Rebecca "Ruji" Chapnik

Ruji Chapnik is a freelance creator of miscellanea, including but not limited to text and images. She studied art at the University of California, Santa Cruz and writing at Portland State University. She went on to study Linux in her bedroom and also in various other people's bedrooms, crouched anti-ergonomically before abandoned Windows computers. Ruji currently lives in Portland, Oregon. You can find her experiments at and her comics at

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox