Tumblr
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.
Installation
You must first install Ruby and RubyGems. Once that’s out of the way, you can grab Tumblr-rb with a single command: Now symlink the gem so you can use it without having to type out the complete file path every time: 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: 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.
Usage
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 https://www.maketecheasier.com 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 –host=myblawg.tumblr.com
You can add metadata to your posts by incorporating YAML front-matter. Here’s an example:
Flickr
Uploadr.py is a simple Flickr client written in Python. It will allow you to upload image files from a local folder to your Flickr account.
Installation
First of all, you need Python 2.*. Now download the latest Uploadr.py sources from GitHub: 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: Start a new shell session to make the changes take effect. Enter the uploadr.py directory you downloaded from GitHub and the subdirectory “uploadr.” Run: 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!
Usage
Well, almost ready to roll. We need to edit a few lines in uploadr.py to give the program some instructions. On line 56, specify the directory your images are stored in: You can also set it up to receive command-line arguments for the title, description, and tags:
Now you can upload the images from your chosen directory with a title, description, and tags:
YouTube
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.*): Youtube-viewer:
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: youtube-dl http://www.youtube.com/watch?v=p6Mq8pXNAfA Download a video in MP4 format and use the title for the file name: youtube-dl -f 18 -t http://www.youtube.com/watch?v=p6Mq8pXNAfA View all available formats and their codes for a video: youtube-dl -F http://www.youtube.com/watch?v=p6Mq8pXNAfA 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:
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: :login Show a video author’s latest uploads: :a(uthor)=i,i Like or dislike a video: :(dis)like=i Subscribe to an author’s channel: :subscribe=i Show related videos: :r(related)=i Play videos from your search results in a specific order: 3-5, 8 10 7 1 Download a video: d18
Conclusion
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?