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

@@ -3,5 +3,6 @@
"hostname": "alpines.club",
"subreddit": "snowboarding",
"top_posts": 5,
"min_score": 100,
"skip_titles": ["daily discussion"]
}

+ 7
- 7
main.py View File

@@ -154,17 +154,18 @@ def query_tops(config):
return posts

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

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)

@@ -185,7 +186,6 @@ def main():
print('posting', p['rid'], '-', p['title'])
make_post(masto, p)

print(newrecents)
save_recents(newrecents)

if __name__ == '__main__':

Loading…
Cancel
Save