osrsbox / osrsbox-db

A complete and up-to-date database of Old School Runescape (OSRS) items, monsters and prayers
https://www.osrsbox.com/projects/osrsbox-db/
GNU General Public License v3.0
227 stars 83 forks source link

item URL's #119

Closed gc closed 5 years ago

gc commented 5 years ago

Currently, Items have a url property which is the wikipedia URL, I'd propose that this be renamed to reflect its the wiki url, and a new url be added for the official G.E link.

For example: before:

{
    "url": "https://oldschool.runescape.wiki/w/Twisted_buckler"
}

after:

{
    "wiki_url": "https://oldschool.runescape.wiki/w/Twisted_buckler",
    "ge_url": "http://services.runescape.com/m=itemdb_oldschool/viewitem?obj=21000"
}
gc commented 5 years ago

Note: ge_url will be a dead link if the item is not tradeable. Include it only for tradeable items?

Same for wiki_url for items that have no wiki page, which I'm assuming there's atleast a few.

osrsbox commented 5 years ago

Hey @gc - I like the idea of adding extra small tweaks like this, but I think adding this URL is a little redundant for a couple of reasons. The main reason, the GE URL can be constructed using the the base URL (http://services.runescape.com/m=itemdb_oldschool/viewitem?obj=) and appending the item ID number. I think that this is a fine method, as the additional url field is not very useful (if someone is writing a program)... and adding this URL will take a lot of additional space.

The following Python code should find all items tradeable on the GE, and construct a URL for querying:

from osrsbox import items_api

all_db_items = items_api.load()
base_url = "http://services.runescape.com/m=itemdb_oldschool/viewitem?obj="

for item in all_db_items:
    if item.tradeable_on_ge:
        print(base_url + item.id)

Also - to answer your most recent comment - the OSRS Wiki URL should always be correct. Even if there is no dedicated wiki page and there is only a related page, the URL should point to the correct wiki page. If there is no wiki page, the value should be null in JSON, or None when loaded in Python. A lot of this is handled by my big list of normalized names which correlates the naming conventions used in the OSRS cache, to the naming conventions used on the OSRS wiki.

EDIT: Just to summarize... I actually use valid wiki pages for the url entry, and not just the OSRS Wiki base URL and the item name concatenated.

gc commented 5 years ago

I see. Perhaps still worth considering renaming to wiki_url just for brevity? Otherwise, happy for this to be closed. Thanks!