self.verbose = verbose
self.logfile = logfile
self.timeout = timeout
+ self.fid = None
self.login()
# retrieve FamilySearch session ID (https://familysearch.org/developers/docs/guides/oauth2)
# retrieve FamilySearch current user ID
def get_userid(self):
- url = 'https://familysearch.org/platform/users/current.json'
- data = self.get_url(url)
- return data['users'][0]['personId'] if data else None
+ if not self.fid:
+ url = 'https://familysearch.org/platform/users/current.json'
+ data = self.get_url(url)
+ self.fid = data['users'][0]['personId'] if data else None
+ return self.fid
# some GEDCOM objects
self.note.link(file, 2)
-class Ordinance():
+class Ordinance:
def __init__(self, data=None):
self.date = self.temple_code = self.status = self.famc = None
self.sources = set()
self.memories = set()
if fid and tree and tree.fs:
- url = 'https://familysearch.org/platform/tree/persons/' + self.fid + '.json'
+ url = 'https://familysearch.org/platform/tree/persons/%s.json' % self.fid
data = tree.fs.get_url(url)
if data:
x = data['persons'][0]
else:
self.sources.add((source,))
if 'evidence' in x:
- url = 'https://familysearch.org/platform/tree/persons/' + self.fid + '/memories.json'
+ url = 'https://familysearch.org/platform/tree/persons/%s/memories.json' % self.fid
data = tree.fs.get_url(url)
if data and 'sourceDescriptions' in data:
for y in data['sourceDescriptions']:
# retrieve parents
def get_parents(self):
if not self.parents:
- url = 'https://familysearch.org/platform/tree/persons/' + self.fid + '/parents.json'
+ url = 'https://familysearch.org/platform/tree/persons/%s/parents.json' % self.fid
data = self.tree.fs.get_url(url)
if data:
x = data['childAndParentsRelationships'][0]
# retrieve children relationships
def get_children(self):
if not self.children:
- url = 'https://familysearch.org/platform/tree/persons/' + self.fid + '/children.json'
+ url = 'https://familysearch.org/platform/tree/persons/%s/children.json' % self.fid
data = self.tree.fs.get_url(url)
if data:
self.children = [(x['father']['resourceId'] if 'father' in x else None,
# retrieve spouse relationships
def get_spouses(self):
if not self.spouses:
- url = 'https://familysearch.org/platform/tree/persons/' + self.fid + '/spouses.json'
+ url = 'https://familysearch.org/platform/tree/persons/%s/spouses.json' % self.fid
data = self.tree.fs.get_url(url)
if data and 'relationships' in data:
self.spouses = [(x['person1']['resourceId'], x['person2']['resourceId'], x['id']) for x in data['relationships']]
# retrieve individual notes
def get_notes(self):
- notes = self.tree.fs.get_url('https://familysearch.org/platform/tree/persons/' + self.fid + '/notes.json')
+ notes = self.tree.fs.get_url('https://familysearch.org/platform/tree/persons/%s/notes.json' % self.fid)
if notes:
for n in notes['persons'][0]['notes']:
text_note = '===' + n['subject'] + '===\n' if 'subject' in n else ''
def get_ordinances(self):
res = []
famc = False
- url = 'https://familysearch.org/platform/tree/persons/' + self.fid + '/ordinances.json'
+ url = 'https://familysearch.org/platform/tree/persons/%s/ordinances.json' % self.fid
data = self.tree.fs.get_url(url)['persons'][0]['ordinances']
if data:
for o in data:
# retrieve contributors
def get_contributors(self):
temp = set()
- data = self.tree.fs.get_url('https://familysearch.org/platform/tree/persons/' + self.fid + '/changes.json')
+ data = self.tree.fs.get_url('https://familysearch.org/platform/tree/persons/%s/changes.json' % self.fid)
for entries in data['entries']:
for contributors in entries['contributors']:
temp.add(contributors['name'])
def add_marriage(self, fid):
if not self.fid:
self.fid = fid
- url = 'https://familysearch.org/platform/tree/couple-relationships/' + self.fid + '.json'
+ url = 'https://familysearch.org/platform/tree/couple-relationships/%s.json' % self.fid
data = self.tree.fs.get_url(url)
if data and 'facts' in data['relationships'][0]:
for x in data['relationships'][0]['facts']:
# retrieve marriage notes
def get_notes(self):
if self.fid:
- notes = self.tree.fs.get_url('https://familysearch.org/platform/tree/couple-relationships/' + self.fid + '/notes.json')
+ notes = self.tree.fs.get_url('https://familysearch.org/platform/tree/couple-relationships/%s/notes.json' % self.fid)
if notes:
for n in notes['relationships'][0]['notes']:
text_note = '===' + n['subject'] + '===\n' if 'subject' in n else ''
def get_contributors(self):
if self.fid:
temp = set()
- data = self.tree.fs.get_url('https://familysearch.org/platform/tree/couple-relationships/' + self.fid + '/changes.json')
+ data = self.tree.fs.get_url('https://familysearch.org/platform/tree/couple-relationships/%s/changes.json' % self.fid)
for entries in data['entries']:
for contributors in entries['contributors']:
temp.add(contributors['name'])
if o.type == u'http://gedcomx.org/Annulment':
key = 'ANUL'
if o.type == u'http://gedcomx.org/CommonLawMarriage':
- key = 'COML'
+ key = '_COML'
if key:
o.print(file, key)
if self.sealing_spouse:
if fid:
if fid in self.sources:
return self.sources[fid]
- data = self.fs.get_url('https://familysearch.org/platform/sources/descriptions/' + fid + '.json')
+ data = self.fs.get_url('https://familysearch.org/platform/sources/descriptions/%s.json' % fid)
if data:
return Source(data['sourceDescriptions'][0], self)
return False
# check LDS account
if args.c:
- fs.get_url('https://familysearch.org/platform/tree/persons/' + fs.get_userid() + '/ordinances.json')
+ fs.get_url('https://familysearch.org/platform/tree/persons/%s/ordinances.json' % fs.get_userid())
loop = asyncio.get_event_loop()