Skip to content

Instantly share code, notes, and snippets.

@bsag
Created August 19, 2017 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsag/f3e4ff55ad8c84ba38fe752f5168b8c3 to your computer and use it in GitHub Desktop.
Save bsag/f3e4ff55ad8c84ba38fe752f5168b8c3 to your computer and use it in GitHub Desktop.
Code to parse Goodreads feed in Huginn
{
"instructions": {
"title": "{{title}} by {{author.name}}, {{published.year}}",
"body": "<p>{% regex_replace \"^(?<pt1>.+/)(?<idcode>\\d+)s(?<pt2>/.+)$\" in %}{{cover.source}}{% with %}{{ pt1 }}{{ idcode }}l{{ pt2 }}{% endregex_replace %}<\/p><p>My rating: {{rating.num}} of 5 stars<\/p><p>{{review.text}}<\/p><p>Read all my reviews on <a href=\"https://www.goodreads.com/user/show/33331686-bsag\">Goodreads<\/a><\/p>"
},
"matchers": [
{
"path": "{{description}}",
"regexp": "author:\\s*(?<name>.+?)<br>",
"to": "author"
},
{
"path": "{{description}}",
"regexp": "book published:\\s*(?<year>\\d\\d\\d\\d?)<br>",
"to": "published"
},
{
"path": "{{description}}",
"regexp": "rating:\\s*(?<num>\\d+?)<br>",
"to": "rating"
},
{
"path": "{{description}}",
"regexp": "review:\\s*<br>(?<text>.+?)$",
"to": "review"
},
{
"path": "{{description}}",
"regexp": "(?<source><img.+?>)",
"to": "cover"
}
],
"mode": "clean"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment