Node.RED setup to export favs and retweets that contain URLs to pinboard.in

Export favs and retweets that contain URLs to pinboard.in

The tweet itself (minus the URL) will become the description.

The flow tries to download the URL to extract a title. If that fails, it will use "Twitter" as the title.

This flow needs the pinboard node

[{"id":"b8e5580d.f6e7f8","type":"pinboard out","z":"36c32101.772e1e","user":"11b5da1e.9ee906","tags":"from:twitter","private":false,"toread":true,"name":"","x":1360,"y":280,"wires":[]},{"id":"f6aa3b2b.c74158","type":"change","z":"36c32101.772e1e","name":"Format HTTP Response for pinboard.in","rules":[{"t":"move","p":"payload","pt":"msg","to":"title","tot":"msg"},{"t":"move","p":"url","pt":"msg","to":"payload","tot":"msg"},{"t":"delete","p":"headers","pt":"msg"},{"t":"delete","p":"statusCode","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1220,"y":180,"wires":[["b8e5580d.f6e7f8"]]},{"id":"f8ebdf0.b0a162","type":"change","z":"36c32101.772e1e","name":"Format failed HTTP response","rules":[{"t":"move","p":"url","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"title","pt":"msg","to":"Twitter","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":260,"wires":[["b8e5580d.f6e7f8"]]},{"id":"2e6d3afd.baae16","type":"html","z":"36c32101.772e1e","name":"Extract title","property":"payload","tag":"head title","ret":"text","as":"multi","x":890,"y":180,"wires":[["f6aa3b2b.c74158"]]},{"id":"8da01fbd.9ac0e","type":"switch","z":"36c32101.772e1e","name":"Check if URL request was successful","property":"statusCode","propertyType":"msg","rules":[{"t":"eq","v":"200","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":240,"wires":[["2e6d3afd.baae16"],["f8ebdf0.b0a162"]]},{"id":"df447f54.218f","type":"http request","z":"36c32101.772e1e","name":"Get URL","method":"GET","ret":"txt","url":"","tls":"","x":120,"y":240,"wires":[["8da01fbd.9ac0e"]]},{"id":"4f2769ca.836a48","type":"function","z":"36c32101.772e1e","name":"Extract URLs from tweet, one msg each","func":"if ( !msg.tweet || \n    !msg.tweet.target_object || \n    !msg.tweet.target_object.entities ||\n    !msg.tweet.target_object.entities.urls ||\n    msg.tweet.target_object.entities.urls.length === 0 ) {\n        return null;\n    }\nvar messages = [],\n    text = msg.tweet.target_object.text,\n    urls = msg.tweet.target_object.entities.urls;\nfor ( var i = 0; i < urls.length; i++ ) {\n    messages.push( {\n        payload: urls[i].expanded_url,\n        url: urls[i].expanded_url,\n        description: text.substring( 0, urls[i].indices[0] ) + text.substr( urls[i].indices[1] ),\n        tweet: msg.tweet\n    } );\n}\nreturn [ messages ];","outputs":1,"noerr":0,"x":220,"y":140,"wires":[["df447f54.218f"]]},{"id":"35538e2a.388dd2","type":"twitter in","z":"36c32101.772e1e","twitter":"","tags":"","user":"event","name":"","topic":"tweets","inputs":0,"x":120,"y":40,"wires":[["4f2769ca.836a48"]]},{"id":"11b5da1e.9ee906","type":"pinboard-user","z":"","user":"archangel"}]

Flow Info

Created 6 years, 8 months ago
Updated 4 years, 3 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x2)
  • function (x1)
  • html (x1)
  • http request (x1)
  • switch (x1)
Other
  • pinboard out (x1)
  • pinboard-user (x1)
  • twitter in (x1)

Tags

  • twitter
  • pinboard
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option