Oil settles up, records weekly gain on Middle East tensions