Explorar el Código

Add word filtering to cut down on possible crap

main
fluffy hace 5 meses
padre
commit
3f44f700f5
Se han modificado 3 ficheros con 18 adiciones y 7 borrados
  1. +1
    -1
      beatbot.py
  2. +8
    -5
      checkwords.py
  3. +9
    -1
      youtube.py

+ 1
- 1
beatbot.py Ver fichero

@@ -2,9 +2,9 @@

import logging
import logging.handlers
import os
import pickle
import random
import os

import mastodon



+ 8
- 5
checkwords.py Ver fichero

@@ -4,8 +4,11 @@ import sys

import wordfilter

for fname in sys.argv[1:]:
with open(fname, 'r') as afile:
for line in afile:
if wordfilter.blacklisted(line):
print(fname, line.strip())
if __name__ == '__main__':
wfilter = wordfilter.Wordfilter()

for fname in sys.argv[1:]:
with open(fname, 'r') as afile:
for line in afile:
if wfilter.blacklisted(line):
print(fname, line.strip())

+ 9
- 1
youtube.py Ver fichero

@@ -1,9 +1,13 @@
""" Wrapper to the YouTube API """

import logging

import googleapiclient.discovery
import wordfilter

import config

LOGGER = logging.getLogger(__name__)

def get_videos(query):
""" Given a search query, return a list of video IDs """
@@ -22,10 +26,14 @@ def get_videos(query):
LOGGER.warning("No items found")
return []

wfilter = wordfilter.Wordfilter()
return [item["id"]["videoId"]
for item in response['items']
if 'id' in item
and 'videoId' in item['id']]
and 'videoId' in item['id']
and not wfilter.blacklisted(
item['snippet'].get('title', '')
+ item['snippet'].get('description', ''))]


if __name__ == "__main__":


Cargando…
Cancelar
Guardar