Skip to content

Commit e01be92

Browse files
committed
moderation added (a simple post filter replacing swear words with *****, useful to quickly filter out bad stuff you own way)
1 parent 9b2089a commit e01be92

File tree

5 files changed

+469
-6
lines changed

5 files changed

+469
-6
lines changed

config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ author: "UglyFeed"
9292
category: "Technology"
9393
copyright: "UglyFeed"
9494

95+
## Moderation (replace bad words listed on the words_file with *****)
96+
moderation:
97+
enabled: true
98+
words_file: 'bad_words.txt'
99+
95100
## scheduler
96101
scheduling_enabled: false
97102
scheduling_interval: 4

json2rss.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ def read_json_files(directory):
5454
logging.error(f"Error decoding JSON from file {filename}: {e}")
5555
return json_data
5656

57+
def load_moderated_words(file_path):
58+
"""Load a list of moderated words from a file."""
59+
try:
60+
with open(file_path, 'r') as file:
61+
return [line.strip() for line in file if line.strip()]
62+
except FileNotFoundError:
63+
logging.error(f"Moderated words file '{file_path}' not found.")
64+
return []
65+
66+
def replace_swear_words(text, moderated_words):
67+
"""Replace swear words in the text with asterisks."""
68+
for word in moderated_words:
69+
text = re.sub(r'\b' + re.escape(word) + r'\b', '*' * len(word), text, flags=re.IGNORECASE)
70+
return text
71+
5772
def create_rss_channel(config):
5873
"""Create the base RSS channel element with proper namespaces and configuration."""
5974
rss = Element('rss', version='2.0')
@@ -93,15 +108,19 @@ def create_rss_channel(config):
93108

94109
return rss, channel
95110

96-
def process_item(item, config):
111+
def process_item(item, config, moderated_words):
97112
"""Process individual JSON item to XML item element."""
98113
item_element = Element('item')
99114

115+
moderation_enabled = get_config_value(config, 'moderation', {}).get('enabled', False)
116+
100117
item_title = SubElement(item_element, 'title')
101-
item_title.text = escape_xml_chars(item.get('title', 'No Title'))
118+
title_text = item.get('title', 'No Title')
119+
item_title.text = escape_xml_chars(replace_swear_words(title_text, moderated_words) if moderation_enabled else title_text)
102120

103121
item_description = SubElement(item_element, 'description')
104-
content = escape_xml_chars(item.get('content', 'No Content'))
122+
content = item.get('content', 'No Content')
123+
content = escape_xml_chars(replace_swear_words(content, moderated_words) if moderation_enabled else content)
105124

106125
if 'links' in item:
107126
content += "<br/><br/><small><b>Sources</b></small><br/><ul>"
@@ -130,6 +149,10 @@ def process_item(item, config):
130149

131150
def create_rss_feed(json_data, output_path, config):
132151
"""Create or update an RSS feed based on provided JSON data."""
152+
moderation_enabled = get_config_value(config, 'moderation', {}).get('enabled', False)
153+
moderated_words_file = get_config_value(config, 'moderation', {}).get('words_file', 'moderated.txt')
154+
moderated_words = load_moderated_words(moderated_words_file) if moderation_enabled else []
155+
133156
if os.path.exists(output_path):
134157
try:
135158
tree = parse(output_path)
@@ -144,7 +167,7 @@ def create_rss_feed(json_data, output_path, config):
144167
new_items = []
145168
cutoff_date = datetime.now() - timedelta(days=int(get_config_value(config, 'max_age_days', 30)))
146169
for item in json_data:
147-
item_element = process_item(item, config)
170+
item_element = process_item(item, config, moderated_words)
148171
processed_at = datetime.strptime(item_element.find('pubDate').text, get_config_value(config, 'datetime_format', '%a, %d %b %Y %H:%M:%S GMT'))
149172

150173
if processed_at >= cutoff_date:
@@ -211,4 +234,4 @@ def main():
211234
logging.info('No JSON files found in the rewritten directory.')
212235

213236
if __name__ == '__main__':
214-
main()
237+
main()

moderation/EN.txt

Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
2g1c
2+
acrotomophilia
3+
anal
4+
anilingus
5+
anus
6+
apeshit
7+
arsehole
8+
ass
9+
asshole
10+
assmunch
11+
autoerotic
12+
babeland
13+
bangbros
14+
bangbus
15+
bareback
16+
barenaked
17+
bastard
18+
bastardo
19+
bastinado
20+
bbw
21+
bdsm
22+
beaner
23+
beaners
24+
beastiality
25+
bestiality
26+
bimbos
27+
birdlock
28+
bitch
29+
bitches
30+
blowjob
31+
blumpkin
32+
bollocks
33+
bondage
34+
boner
35+
boob
36+
boobs
37+
bukkake
38+
bulldyke
39+
bullshit
40+
bunghole
41+
busty
42+
butt
43+
buttcheeks
44+
butthole
45+
camgirl
46+
camslut
47+
camwhore
48+
carpetmuncher
49+
cialis
50+
circlejerk
51+
clit
52+
clitoris
53+
clusterfuck
54+
cock
55+
cocks
56+
coprolagnia
57+
coprophilia
58+
cornhole
59+
coon
60+
coons
61+
creampie
62+
cum
63+
cumming
64+
cumshot
65+
cumshots
66+
cunnilingus
67+
cunt
68+
darkie
69+
daterape
70+
deepthroat
71+
dendrophilia
72+
dick
73+
dildo
74+
dingleberry
75+
dingleberries
76+
doggiestyle
77+
doggystyle
78+
dolcett
79+
domination
80+
dominatrix
81+
dommes
82+
dvda
83+
ecchi
84+
ejaculation
85+
erotic
86+
erotism
87+
escort
88+
eunuch
89+
fag
90+
faggot
91+
fecal
92+
felch
93+
fellatio
94+
feltch
95+
femdom
96+
figging
97+
fingerbang
98+
fingering
99+
fisting
100+
footjob
101+
frotting
102+
fuck
103+
fuckin
104+
fucking
105+
fucktards
106+
fudgepacker
107+
futanari
108+
gangbang
109+
genitals
110+
goatcx
111+
goatse
112+
gokkun
113+
goodpoop
114+
goregasm
115+
grope
116+
g-spot
117+
guro
118+
handjob
119+
hardcore
120+
hentai
121+
homoerotic
122+
honkey
123+
hooker
124+
horny
125+
humping
126+
incest
127+
intercourse
128+
jailbait
129+
jigaboo
130+
jiggaboo
131+
jiggerboo
132+
jizz
133+
juggs
134+
kike
135+
kinbaku
136+
kinkster
137+
kinky
138+
knobbing
139+
livesex
140+
lolita
141+
lovemaking
142+
masturbate
143+
masturbating
144+
masturbation
145+
milf
146+
mong
147+
motherfucker
148+
muffdiving
149+
nambla
150+
nawashi
151+
negro
152+
neonazi
153+
nigga
154+
nigger
155+
nimphomania
156+
nipple
157+
nipples
158+
nsfw
159+
nude
160+
nudity
161+
nutten
162+
nympho
163+
nymphomania
164+
octopussy
165+
omorashi
166+
orgasm
167+
orgy
168+
paedophile
169+
paki
170+
panties
171+
panty
172+
pedobear
173+
pedophile
174+
pegging
175+
penis
176+
pikey
177+
pissing
178+
pisspig
179+
playboy
180+
ponyplay
181+
poof
182+
poon
183+
poontang
184+
punany
185+
poopchute
186+
porn
187+
porno
188+
pornography
189+
pthc
190+
pubes
191+
pussy
192+
queaf
193+
queef
194+
quim
195+
raghead
196+
rape
197+
raping
198+
rapist
199+
rectum
200+
rimjob
201+
rimming
202+
sadism
203+
santorum
204+
scat
205+
schlong
206+
scissoring
207+
semen
208+
sex
209+
sexcam
210+
sexo
211+
sexy
212+
sexual
213+
sexually
214+
sexuality
215+
shemale
216+
shibari
217+
shit
218+
shitblimp
219+
shitty
220+
shota
221+
shrimping
222+
skeet
223+
slanteye
224+
slut
225+
s&m
226+
smut
227+
snatch
228+
snowballing
229+
sodomize
230+
sodomy
231+
spastic
232+
spic
233+
splooge
234+
spooge
235+
spunk
236+
strapon
237+
strappado
238+
suck
239+
sucks
240+
swastika
241+
swinger
242+
threesome
243+
throating
244+
thumbzilla
245+
tit
246+
tits
247+
titties
248+
titty
249+
topless
250+
tosser
251+
towelhead
252+
tranny
253+
tribadism
254+
tubgirl
255+
tushy
256+
twat
257+
twink
258+
twinkie
259+
undressing
260+
upskirt
261+
urophilia
262+
vagina
263+
viagra
264+
vibrator
265+
vorarephilia
266+
voyeur
267+
voyeurweb
268+
voyuer
269+
vulva
270+
wank
271+
wetback
272+
whore
273+
worldsex
274+
xx
275+
xxx
276+
yaoi
277+
yiffy
278+
zoophilia

0 commit comments

Comments
 (0)