From 2f00cf06e778e56e4d69376c9e8f1e670499dc8b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 15 Jan 2020 10:56:39 +0000 Subject: [PATCH] Replace YouTube links, so they get less data --- inbox.py | 4 ++++ media.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/inbox.py b/inbox.py index 1f056bf8..e16dcfb7 100644 --- a/inbox.py +++ b/inbox.py @@ -59,6 +59,7 @@ from posts import sendToFollowersThread from webinterface import individualPostAsHtml from webinterface import getIconsDir from question import questionUpdateVotes +from media import replaceYouTube def storeHashTags(baseDir: str,nickname: str,postJsonObject: {}) -> None: """Extracts hashtags from an incoming post and updates the @@ -1848,6 +1849,9 @@ def inboxAfterCapabilities(recentPostsCache: {},maxRecentPosts: int, \ postJsonObject=messageJson if validPostContent(postJsonObject,maxMentions,maxEmoji): + # replace YouTube links, so they get less tracking data + replaceYouTube(postJsonObject) + # list of indexes to be updated updateIndexList=['inbox'] populateReplies(baseDir,httpPrefix,domain,postJsonObject,maxReplies,debug) diff --git a/media.py b/media.py index 5dfd5c59..ff32fb33 100644 --- a/media.py +++ b/media.py @@ -19,6 +19,19 @@ from shutil import copyfile from shutil import rmtree from shutil import move +def replaceYouTube(postJsonObject: {}): + """Replace YouTube with invidio.us + This denies Google some, but not all, tracking data + """ + if not isinstance(postJsonObject['object'], dict): + return + if not postJsonObject['object'].get('content'): + return + if 'www.youtube.com' not in postJsonObject['object']['content']: + return + postJsonObject['object']['content']= \ + postJsonObject['object']['content'].replace('www.youtube.com','invidio.us') + def removeMetaData(imageFilename: str,outputFilename: str) -> None: """Attempts to do this with pure python didn't work well, so better to use a dedicated tool if one is installed