main
Bob Mottram 2021-09-18 18:20:01 +01:00
parent fc65d8e598
commit c3a95d52a3
1 changed files with 16 additions and 18 deletions

View File

@ -28,10 +28,10 @@ from shutil import move
from city import spoofGeolocation
def replaceYouTube(postJsonObject: {}, replacementDomain: str,
systemLanguage: str) -> None:
"""Replace YouTube with a replacement domain
This denies Google some, but not all, tracking data
def _replaceSiloDomain(postJsonObject: {},
siloDomain: str, replacementDomain: str,
systemLanguage: str) -> None:
"""Replace a silo domain with a replacement domain
"""
if not replacementDomain:
return
@ -40,7 +40,7 @@ def replaceYouTube(postJsonObject: {}, replacementDomain: str,
if not postJsonObject['object'].get('content'):
return
contentStr = getBaseContentFromPost(postJsonObject, systemLanguage)
if 'www.youtube.com' not in contentStr:
if siloDomain not in contentStr:
return
contentStr = contentStr.replace('www.youtube.com', replacementDomain)
postJsonObject['object']['content'] = contentStr
@ -48,24 +48,22 @@ def replaceYouTube(postJsonObject: {}, replacementDomain: str,
postJsonObject['object']['contentMap'][systemLanguage] = contentStr
def replaceYouTube(postJsonObject: {}, replacementDomain: str,
systemLanguage: str) -> None:
"""Replace YouTube with a replacement domain
This denies Google some, but not all, tracking data
"""
return _replaceSiloDomain(postJsonObject, 'www.youtube.com',
replacementDomain, systemLanguage)
def replaceTwitter(postJsonObject: {}, replacementDomain: str,
systemLanguage: str) -> None:
"""Replace Twitter with a replacement domain
This allows you to view twitter posts without having a twitter account
"""
if not replacementDomain:
return
if not hasObjectDict(postJsonObject):
return
if not postJsonObject['object'].get('content'):
return
contentStr = getBaseContentFromPost(postJsonObject, systemLanguage)
if 'twitter.com' not in contentStr:
return
contentStr = contentStr.replace('twitter.com', replacementDomain)
postJsonObject['object']['content'] = contentStr
if postJsonObject['object'].get('contentMap'):
postJsonObject['object']['contentMap'][systemLanguage] = contentStr
return _replaceSiloDomain(postJsonObject, 'twitter.com',
replacementDomain, systemLanguage)
def _removeMetaData(imageFilename: str, outputFilename: str) -> None: