awasu.user
Posts: 82
Joined: Fri Jan 06, 2017 12:50 pm

Postby awasu.user » Thu Jul 13, 2017 8:11 pm

I try get JSON data from Awasu with code:


Code: Select all

phrase = "Donald Trump"
import requests

print("Check in Awasu: ", phrase)

a_search = "http://localhost:2604/search/query"

opt = {}
opt["token"] = "GYmh3B"
opt["age"] = "1"
opt["p"] = "1"
opt["ps"] = "20"
opt["l"] = "title,content"
opt["format"] = "json"
opt["feedItemDescriptionFormat"] = "excerpt"
opt["q"] = phrase

r = requests.get(a_search, params=opt)
print(r.url)
code = r.json()
code = code["searchResults"]
code = code["results"]
print(code)


But how combine using API call search result and check that search result article is unread using API?

Fx. Awasu result: "New president" and "Last speach" and I check that articles are fresh and juicy or old (= I read it before).

User avatar
support
Site Admin
Posts: 3022
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Fri Jul 14, 2017 1:29 am

There isn't an API call to get the read/unread status of an item, but you could do it like this:
  1. Use $/search/query to run the query (as you did above).
  2. Get each item's ID (code[item_no]["id"]).
  3. Get the channel's summary page (HTML) using $/channels/get (but see below).
  4. Look for a <div> with a class of "item" that has the ID you want, and it will also have the item's new/read/unread state.
However, the tricky bit is (3), since there's no way of knowing which channel an item belongs to, so you would need to start off by getting the summary page for every channel, then scanning them for items, which would be very slow. It also won't work if the item is not recent enough to be included in the page.

There is an API call $/feedItems/get that returns information about a feed item, but it currently doesn't return the item's state. I'll update this and get a new build out to you...

User avatar
support
Site Admin
Posts: 3022
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Wed Jul 19, 2017 8:23 am

I've sent you a new build, and $/feedItems/get will now return each item's state (new|unread|read).

This API call can take multiple item ID's (comma-separated), and it will be much quicker to do them all in one go, rather than calling the API for each individual item.

awasu.user
Posts: 82
Joined: Fri Jan 06, 2017 12:50 pm

Postby awasu.user » Wed Jul 19, 2017 7:14 pm

It's working! Thank you!


Return to “Awasu - Extensions”

Who is online

Users browsing this forum: No registered users and 3 guests