Skip to content

Commit

Permalink
Only try to publish tweets from one of my accounts
Browse files Browse the repository at this point in the history
I can favourite other user's posts using @mnfpublishing, that shouldn't
try to add them to my site as if it was my content.
  • Loading branch information
norm committed Jun 7, 2021
1 parent 8d25668 commit be2877c
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions script/mnfpublishing
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,26 @@ import toml

from lib.twitter import Twitter

MY_ACCOUNTS = ['cackhanded']


def main():
twitter = Twitter()

faves = twitter.get_favourites_for('mnfpublishing')
for fave in faves:
ids_toml = 'data/%s.toml' % fave.user.screen_name
with open(ids_toml, 'r') as handle:
ids = toml.load(handle)

tweet_id = '%s' % fave.id
if tweet_id not in ids:
twitter.create_source_from_tweet(tweet_id)
ids[tweet_id] = {}
with open(ids_toml, 'w') as write_handle:
toml.dump(ids, write_handle)
print('--', ids_toml)
if fave.user.screen_name in MY_ACCOUNTS:
ids_toml = 'data/%s.toml' % fave.user.screen_name
with open(ids_toml, 'r') as handle:
ids = toml.load(handle)

tweet_id = '%s' % fave.id
if tweet_id not in ids:
twitter.create_source_from_tweet(tweet_id)
ids[tweet_id] = {}
with open(ids_toml, 'w') as write_handle:
toml.dump(ids, write_handle)
print('--', ids_toml)


if __name__ == '__main__':
Expand Down

0 comments on commit be2877c

Please sign in to comment.