-
Notifications
You must be signed in to change notification settings - Fork 1
/
recommendations_to_follow
executable file
·54 lines (36 loc) · 1.46 KB
/
recommendations_to_follow
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
from argparse import ArgumentParser
from mastodon_recommender import display_table, get_own_account_name
from mastodon_recommender.database import Suggestion
from mastodon_recommender.following import FollowingCollection
from mastodon_recommender.recommender import Recommender
def main():
parser = ArgumentParser()
parser.add_argument("--update_own_followers", action="store_true", default=False)
parser.add_argument("--test_run", action="store_true", default=False)
parser.add_argument(
"--no_update", dest="update", action="store_false", default=True
)
args = parser.parse_args()
account = get_own_account_name()
following_collection = FollowingCollection(account, update_following=args.update)
following_collection.fetch_for_own_account(force=args.update_own_followers)
following_collection.fetch_for_accounts_being_followed()
recommender = Recommender(following_collection)
recommender.build_lists()
suggestion_list = recommender.get_suggestions()
suggestions_left = 5
to_display = []
for count, user in suggestion_list:
if args.test_run:
created = True
else:
_, created = Suggestion.get_or_create(account=user["acct"])
if created:
to_display.append((count, user))
suggestions_left -= 1
if suggestions_left == 0:
break
display_table(to_display)
if __name__ == "__main__":
main()