Skip to content

Instantly share code, notes, and snippets.

View rupertbates's full-sized avatar

Rupert Bates rupertbates

  • Guardian News and Media
  • London
View GitHub Profile
URL="http://content.guardianapis.com/search?api-key=test&show-fields=starRating&page-size=100&tag=tone/albumreview,tone/reviews&from-date=2015-01-03&to-date=2015-02-03"
curl -s $URL | jq '[.response.results[]|select(.fields.starRating == "4" or .fields.starRating == "5")] | length'
@rupertbates
rupertbates / music-reviews-results-array.sh
Created February 3, 2015 21:58
Music reviews results array
URL="http://content.guardianapis.com/search?api-key=test&show-fields=starRating&page-size=100&tag=tone/albumreview,tone/reviews&from-date=2015-01-03&to-date=2015-02-03"
curl -s $URL | jq '.response.results[]'
{
"webTitle": "Beck Goldsmith: Lustre & Curve review – a polite howl of pain",
"webPublicationDate": "2015-01-08T21:30:19Z",
"sectionId": "music",
"id": "music/2015/jan/08/beck-goldsmith-lustre-and-curve-review-polite-howl-of-pain",
"fields": {
"starRating": "3"
},
"webUrl": "http://www.theguardian.com/music/2015/jan/08/beck-goldsmith-lustre-and-curve-review-polite-howl-of-pain",
"apiUrl": "http://content.guardianapis.com/music/2015/jan/08/beck-goldsmith-lustre-and-curve-review-polite-howl-of-pain",
.response.results[]|{webTitle, starRating:(.fields.starRating|tonumber)}
{
"webTitle": "Bob Dylan: Shadows in the Night review – pre-rock songs imbued with romantic regret",
"starRating": 4
}
{
"webTitle": "Arias for Domenico Gizzi review – just an echo of a true castrato",
"starRating": 3
}
{
"webTitle": "Liszt: Piano Sonata, Dante Sonata, Petrarch Sonnets review – Angela Hewitt is masterful and compelling",
.response.results[]|{webTitle, starRating:(.fields.starRating|tonumber)}|select(.starRating > 3)
[.response.results[]|{webTitle, starRating:(.fields.starRating|tonumber)}|select(.starRating > 3)]|length
{
"webTitle": "Napalm Death: Apex Predator – Easy Meat review – grindcore masters on top form",
"starRating": 5
},
{
"webTitle": "Mozart: Piano Sonatas K280 and 332; Chopin: 24 Preludes, etc CD review – overflowing with vitality",
"starRating": 5
},
{
"webTitle": "Bob Dylan: Shadows in the Night review – an unalloyed pleasure",
@rupertbates
rupertbates / get-music-reviews-final.sh
Created February 6, 2015 11:35
Retrieve all 5 star album reviews from the Guardian content api
URL="http://content.guardianapis.com/search?api-key=test&show-fields=starRating&page-size=100&tag=tone/albumreview,tone/reviews&from-date=2015-01-03&to-date=2015-02-03"
curl -s $URL | jq '.response.results[]|select(.fields.starRating != null)|{webTitle, url: .webUrl, starRating: (.fields.starRating|tonumber)}|select(.starRating == 5)'
public string TestReturn(int i)
{
return "hello hello hello";
}