#shellscripts

dredmorbius@joindiaspora.com

unjsonify-diaspora: A shell script for extracting post Markdown source

I've needed to do this often enough, and gotten it wrong sufficiently many times, that I've finally written a simple shell script using jq and sed, to return straight Markdown from a Diaspora post. It mostly makes re-editing typos easier.

#!/bin/sh

jq -M .text | sed 's/^"//; s/"$//; s/\\r\\n/\n/g; s/\\"/"/g'

Saved as unjsonify-diaspora.

This extracts the '.text' element, trims leading and trailing quotes, replaces \r\n sequences with linefeeds, and unescapes quotes. Some further substitutions may be required though so far it seems good.

"But how do you get the JSON" you ask? Simple: append .json to any Diaspora URL.

For example: https://joindiaspora.com/posts/c7415d50e97f01385366002590d8e506

Becomes: https://joindiaspora.com/posts/c7415d50e97f01385366002590d8e506.json

You can either copy/paste the rendered content to the script, or (preferable) use a web uttility such as curl or wget to pipe directly to the script:

curl --silent https://joindiaspora.com/posts/c7415d50e97f01385366002590d8e506.json |
     unjsonify-diaspora

Usually I'm doing this to fix typos, so you could send this on to an editor:

curl --silent <url> | unjsonify-diaspora | vim -

Then delete your old, buggy post and replace it with a new buggy one.

#json #jq #ShellScripts #JustLinuxThings #linux #diaspoa #tips

dredmorbius@joindiaspora.com

A rudimentary G+ post content extractor (JSON format)

Following the YouTube Anschluss in which Google forcibly integrated G+ and YouTube accounts (among other properties), against my express wishes, pretty much forever violating my trust in the company, I made the conscious decision to largely exit G+, removing my content, while archiving what I'd previously posted.

Pulling useful information out of those archives has been ... interesting.

Continued at the dreddit

http://www.reddit.com/r/dredmorbius/comments/21t7im/a_rudimentary_g_post_content_extractor_json_format/

#googleplustips #archives #json #pandoc #shellscripts #linuxhacks