From d5a660cb8bdd8032dbedd1816f50b3515fd5fcc2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 2 Sep 2019 09:47:56 +0100 Subject: [PATCH] Parse actors with 'profile' instead of 'user; --- utils.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/utils.py b/utils.py index a0c7d710..7a2aeadb 100644 --- a/utils.py +++ b/utils.py @@ -79,6 +79,12 @@ def getNicknameFromActor(actor: str) -> str: """Returns the nickname from an actor url """ 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 if '/@' in actor: nickStr=actor.split('/@')[1] @@ -96,12 +102,15 @@ def getDomainFromActor(actor: str) -> (str,int): """Returns the domain name from an actor url """ port=None - if '/users/' not in actor: - domain = actor.replace('https://','').replace('http://','').replace('dat://','') - if '/' in actor: - domain=domain.split('/')[0] + if '/profile/' in actor: + domain = actor.split('/profile/')[0].replace('https://','').replace('http://','').replace('dat://','') 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: port=int(domain.split(':')[1]) domain=domain.split(':')[0]