diff --git a/media.py b/media.py index cd8705913..3f43fdb9a 100644 --- a/media.py +++ b/media.py @@ -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: