add real mhx carve data to translate site

main
Bryce Allen 10 years ago
parent a9439f2891
commit d0173157b9

@ -92,7 +92,7 @@ def _main():
gather_items = db.get_items(item_types=
("Bone", "Plant", "Ore", "Fish", "Bug", "Sac/Fluid", "Meat"))
carve_items = db.get_items(item_types=("Flesh",))
#carve_items = db.get_items(item_types=("Flesh",))
stree_path = os.path.join(_pathfix.project_path, "db",
"mhx_skill_tree_list.json")
@ -120,9 +120,16 @@ def _main():
("icon_name", "name", "name_jp"), ("icon_name", "name"),
divider_fn=item_divider_fn)
mk_html_list("items-carve.html", "Items: Carve", carve_items,
carves_path = os.path.join(_pathfix.project_path, "db", "mhx",
"monster_carves.json")
with open(carves_path) as f:
carves_list = json.load(f)
mk_html_list("items-carve-en.html", "Items: Carve (en)", carves_list,
("icon_name", "name", "name_jp"), ("icon_name", "name"),
divider_fn=item_divider_fn)
mk_html_list("items-carve-jp.html", "Items: Carve (jp)", carves_list,
("icon_name", "name_jp", "name"), ("name_jp",),
divider_fn=None)
ha_path = os.path.join(_pathfix.project_path, "db", "hunter_arts.json")
with open(ha_path) as f:

File diff suppressed because it is too large Load Diff

@ -0,0 +1,88 @@
#!/usr/bin/env python2
# vim: set fileencoding=utf8 :
import urllib
import os
import json
import sys
from lxml import etree
import _pathfix
_BASE_URL = "http://monsterhunter.wikia.com/wiki/"
_PAGE = "MHX:_Monster_Material_List"
_CIRCLE = u"\u26ab"
def extract_names_and_icons(tree):
carves = []
tables = tree.xpath(
'//*[@id="mw-content-text"]/table[contains(@class, "linetable")]'
)
for table in tables:
rows = list(table)
for row in rows:
cells = row.xpath("./td")
if not cells:
continue
icon_img = cells[0].xpath(".//*/img")
if not icon_img:
continue
icon_name = icon_img[0].attrib["alt"]
if icon_name == "Wiki":
continue
name, name_jp = [t.strip() for t in cells[1].xpath("./text()")]
carves.append(dict(
name=name,
name_jp=name_jp,
icon_name=_translate_icon_name(icon_name))
)
return carves
_SHAPE_MAP = {
"Monster Parts": "Carapace",
"Carapace": "Shell",
"Claw": "Fang",
"Ball": "Monster-Jewel",
"Medicine": "Liquid",
}
_COLOR_MAP = {
"Dark Purple": "Purple",
"Dark Green": "DarkGreen",
"Light Green": "YellowGreen",
"Dark Red": "Red",
"Dark Blue": "Blue",
"Light Blue": "Cyan",
"Brown": "Yellow",
}
def _translate_icon_name(s):
"""
Translate from wikia icon names to MH4U db icon names.
"""
prefix, name = s.split("-", 1)
shape, color = name.split(" Icon ")
if shape in _SHAPE_MAP:
shape = _SHAPE_MAP[shape]
if color in _COLOR_MAP:
color = _COLOR_MAP[color]
return "%s-%s.png" % (shape, color)
def _main():
tmp_path = os.path.join(_pathfix.project_path, "tmp")
fpath = os.path.join(tmp_path, "wikia-monster-carves.html")
parser = etree.HTMLParser()
urllib.urlretrieve(_BASE_URL + _PAGE, fpath)
with open(fpath) as f:
tree = etree.parse(f, parser)
carves = extract_names_and_icons(tree)
#print json.dumps(weapon_list, indent=2)
print json.dumps(carves, indent=2)
if __name__ == '__main__':
_main()

@ -37,7 +37,7 @@
</li>
<li class="pure-menu-item poogie-menu-item">
<a class="pure-menu-link"
href="items-carve.html">Monster Carves</a>
href="items-carve-en.html">Monster Carves</a>
</li>
<li class="pure-menu-heading poogie-menu-heading">Old Sites (searchable but slow load)</li>

@ -67,7 +67,7 @@
</li>
<li class="pure-menu-item poogie-menu-item">
<a class="pure-menu-link"
href="items-carve.html">Monster Carves</a>
href="items-carve-en.html">Monster Carves</a>
</li>
<li class="pure-menu-heading poogie-menu-heading">Old Sites (searchable but slow load)</li>

File diff suppressed because it is too large Load Diff

@ -333,6 +333,15 @@
<div class="poogie-li poogie-li-divider">D</div>
<div class="pure-g poogie-li">
<div class="pure-u-1-2">D. Fencing</div>
<div class="pure-u-1-2">北辰納豆流</div>
</div>
<div class="pure-g poogie-li">
<div class="pure-u-1-2">Daruma</div>
@ -745,15 +754,6 @@
<div class="pure-g poogie-li">
<div class="pure-u-1-2">Leaping</div>
<div class="pure-u-1-2">跳躍</div>
</div>
<div class="pure-g poogie-li">
<div class="pure-u-1-2">LightEater</div>
@ -1209,6 +1209,15 @@
</div>
<div class="pure-g poogie-li">
<div class="pure-u-1-2">Swift Bird</div>
<div class="pure-u-1-2">飛燕</div>
</div>
<div class="poogie-li poogie-li-divider">T</div>
<div class="pure-g poogie-li">

@ -421,15 +421,6 @@
<div class="pure-g poogie-li">
<div class="pure-u-1-2">跳躍</div>
<div class="pure-u-1-2">Leaping</div>
</div>
<div class="pure-g poogie-li">
<div class="pure-u-1-2">逆上</div>
@ -556,6 +547,15 @@
<div class="pure-g poogie-li">
<div class="pure-u-1-2">飛燕</div>
<div class="pure-u-1-2">Swift Bird</div>
</div>
<div class="pure-g poogie-li">
<div class="pure-u-1-2">食事</div>
@ -1180,6 +1180,15 @@
<div class="pure-g poogie-li">
<div class="pure-u-1-2">北辰納豆流</div>
<div class="pure-u-1-2">D. Fencing</div>
</div>
<div class="pure-g poogie-li">
<div class="pure-u-1-2">属強瓶追加</div>

Loading…
Cancel
Save