Sfoglia il codice sorgente

Add word filtering to cut down on possible crap

main
fluffy 5 mesi fa
parent
commit
3f44f700f5
3 ha cambiato i file con 18 aggiunte e 7 eliminazioni
  1. +1
    -1
      beatbot.py
  2. +8
    -5
      checkwords.py
  3. +9
    -1
      youtube.py

+ 1
- 1
beatbot.py Vedi File

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

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

import mastodon



+ 8
- 5
checkwords.py Vedi File

@@ -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 Vedi File

@@ -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__":


Caricamento…
Annulla
Salva