Page 1 of 1
Wiki Namespaces
Posted: Sat Apr 02, 2011 1:46 pm
by gardano
Hi all,
I'm trying to parse the update feed from the wiki, and what I'd hoped to do was to determine the kind of update via the namespace property of the returned dictionary. It seemed that
* "ns=0" gives a composition (this seems to work fine), and
* "ns=14" would give a composer. This doesn't work out so well. I get composers in most instances, but for the latest update query, I got back also "Category:User baroque flutists-3" and "Category:User baroque flutists".
Are the items with "Baroque flutists" etc an anomaly with the data, or are the namespaces not completely implemented yet?
Alternatively, if this isn't the best way to get the latest updates and additions to the wiki via the API, any other suggestions?
Here's the query I'm using:
http://imslp.org/api.php?action=query&l ... ormat=json
(rcstart is set to the last time my app pulled data from the wiki).
Thanks much,
Gardano
Re: Wiki Namespaces
Posted: Sat Apr 02, 2011 6:25 pm
by KGill
Perhaps 'ns=14' would just signify a category? Composers are not in a separate namespace than the other categories (such as those for tags, templates, etc.), so I'd imagine that it would be difficult to tell the difference using this method. Is there any way to modify the query to check what categories the page is included in? (Should be in Category:Composers in this case)
Re: Wiki Namespaces
Posted: Sat Apr 02, 2011 7:55 pm
by imslp
KGill is right. NS_CATEGORY is defined as 14. Category:Composers should contain all composer categories.
Re: Wiki Namespaces
Posted: Sun Apr 03, 2011 12:49 am
by gardano
imslp wrote:KGill is right. NS_CATEGORY is defined as 14. Category:Composers should contain all composer categories.
Oh, OK. I'm sure I made the invalid assumption purely because most new categories are of composers, but not all. I'll have to look through the API and see if I can pre-filter the requests, or alternatively, find a way to filter the requests by calling the API again. This last option of course is not optimal because I want to keep the HTTP Requests to a minimum, both for the device and for the server's sake.
I'll have to find out what unique property distinguishes a composer from, say, a user.
Thanks!
Gardano
Re: Wiki Namespaces
Posted: Sun Apr 03, 2011 1:02 am
by imslp
Hmm, would list=categorymembers on Category:Composers work?
Re: Wiki Namespaces
Posted: Sun Apr 03, 2011 2:57 am
by gardano
imslp wrote:Hmm, would list=categorymembers on Category:Composers work?
:¬) Yep, I'm doing that for the initial load of the composers. What I'm trying to do with this query is to refresh the app with all new compositions and composers since the last time the app was launched.
AHHH now that I think of it, I really only need to identify the new *compositions* that have been added. If there is no composer foreign-keyed to the new composition, then I'd know that I need to do a query on that composition to grab its composer.
So I can use the NS=0 to grab compositions and that will be all I need.
Re: Wiki Namespaces
Posted: Sun Apr 03, 2011 5:05 pm
by kalliwoda
gardano wrote
What I'm trying to do with this query is to refresh the app with all new compositions and composers since the last time the app was launched.
Now, that is something I have been looking for on imslp for a long time, would your app also work in a regular browser?
Re: Wiki Namespaces
Posted: Sun Apr 03, 2011 8:10 pm
by gardano
kalliwoda wrote:gardano wrote
What I'm trying to do with this query is to refresh the app with all new compositions and composers since the last time the app was launched.
Now, that is something I have been looking for on imslp for a long time, would your app also work in a regular browser?
Actually, I don't know. This is something for the iPad app I'm writing for IMSLP, and so it's more technical and doesn't return content appropriate for a web browser. I haven't looked into how it would work using just a web browser, I'm afraid.
--Gardano