Parse actors with 'profile' instead of 'user;

master
Bob Mottram 2019-09-02 09:47:56 +01:00
parent d217762b5e
commit d5a660cb8b
1 changed files with 14 additions and 5 deletions

View File

@ -79,6 +79,12 @@ def getNicknameFromActor(actor: str) -> str:
"""Returns the nickname from an actor url """Returns the nickname from an actor url
""" """
if '/users/' not in actor: if '/users/' not in actor:
if '/profile/' in actor:
nickStr=actor.split('/profile/')[1].replace('@','')
if '/' not in nickStr:
return nickStr
else:
return nickStr.split('/')[0]
# https://domain/@nick # https://domain/@nick
if '/@' in actor: if '/@' in actor:
nickStr=actor.split('/@')[1] nickStr=actor.split('/@')[1]
@ -96,12 +102,15 @@ def getDomainFromActor(actor: str) -> (str,int):
"""Returns the domain name from an actor url """Returns the domain name from an actor url
""" """
port=None port=None
if '/users/' not in actor: if '/profile/' in actor:
domain = actor.replace('https://','').replace('http://','').replace('dat://','') domain = actor.split('/profile/')[0].replace('https://','').replace('http://','').replace('dat://','')
if '/' in actor:
domain=domain.split('/')[0]
else: else:
domain = actor.split('/users/')[0].replace('https://','').replace('http://','').replace('dat://','') if '/users/' not in actor:
domain = actor.replace('https://','').replace('http://','').replace('dat://','')
if '/' in actor:
domain=domain.split('/')[0]
else:
domain = actor.split('/users/')[0].replace('https://','').replace('http://','').replace('dat://','')
if ':' in domain: if ':' in domain:
port=int(domain.split(':')[1]) port=int(domain.split(':')[1])
domain=domain.split(':')[0] domain=domain.split(':')[0]