Replace YouTube links, so they get less data

main
Bob Mottram 2020-01-15 10:56:39 +00:00
parent 5cf74595dd
commit 2f00cf06e7
2 changed files with 17 additions and 0 deletions

View File

@ -59,6 +59,7 @@ from posts import sendToFollowersThread
from webinterface import individualPostAsHtml from webinterface import individualPostAsHtml
from webinterface import getIconsDir from webinterface import getIconsDir
from question import questionUpdateVotes from question import questionUpdateVotes
from media import replaceYouTube
def storeHashTags(baseDir: str,nickname: str,postJsonObject: {}) -> None: def storeHashTags(baseDir: str,nickname: str,postJsonObject: {}) -> None:
"""Extracts hashtags from an incoming post and updates the """Extracts hashtags from an incoming post and updates the
@ -1848,6 +1849,9 @@ def inboxAfterCapabilities(recentPostsCache: {},maxRecentPosts: int, \
postJsonObject=messageJson postJsonObject=messageJson
if validPostContent(postJsonObject,maxMentions,maxEmoji): if validPostContent(postJsonObject,maxMentions,maxEmoji):
# replace YouTube links, so they get less tracking data
replaceYouTube(postJsonObject)
# list of indexes to be updated # list of indexes to be updated
updateIndexList=['inbox'] updateIndexList=['inbox']
populateReplies(baseDir,httpPrefix,domain,postJsonObject,maxReplies,debug) populateReplies(baseDir,httpPrefix,domain,postJsonObject,maxReplies,debug)

View File

@ -19,6 +19,19 @@ from shutil import copyfile
from shutil import rmtree from shutil import rmtree
from shutil import move 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: def removeMetaData(imageFilename: str,outputFilename: str) -> None:
"""Attempts to do this with pure python didn't work well, """Attempts to do this with pure python didn't work well,
so better to use a dedicated tool if one is installed so better to use a dedicated tool if one is installed