Browse Source

Better filtering logic.

master
Trey Del Bonis 2 years ago
parent
commit
a4a7e47cb9
2 changed files with 8 additions and 7 deletions
  1. 1
    0
      config.json
  2. 7
    7
      main.py

+ 1
- 0
config.json View File

"hostname": "alpines.club", "hostname": "alpines.club",
"subreddit": "snowboarding", "subreddit": "snowboarding",
"top_posts": 5, "top_posts": 5,
"min_score": 100,
"skip_titles": ["daily discussion"] "skip_titles": ["daily discussion"]
} }

+ 7
- 7
main.py View File

return posts return posts


def filter_posts(config, posts, filt): def filter_posts(config, posts, filt):
tp = config['top_posts']
ok = [] ok = []
filt = set(filt) filt = set(filt)
newfilt = set() newfilt = set()


for p in posts: for p in posts:
if p['rid'] not in filt:
ok.append(p)
newfilt.add(p['rid'])
if len(ok) > config['top_posts']:
ok = ok[:config['top_posts']]
if len(ok) <= tp and p['score'] >= config['min_score']:
if p['rid'] not in filt:
ok.append(p)
newfilt.add(p['rid'])
elif p['rid'] in filt:
newfilt.add(p['rid'])


return ok, list(newfilt) return ok, list(newfilt)


print('posting', p['rid'], '-', p['title']) print('posting', p['rid'], '-', p['title'])
make_post(masto, p) make_post(masto, p)


print(newrecents)
save_recents(newrecents) save_recents(newrecents)


if __name__ == '__main__': if __name__ == '__main__':

Loading…
Cancel
Save