first commit
This commit is contained in:
commit
a00a1b9ca3
1 changed files with 63 additions and 0 deletions
63
zeroToots.py
Normal file
63
zeroToots.py
Normal file
|
@ -0,0 +1,63 @@
|
|||
import json
|
||||
import datetime
|
||||
import time
|
||||
from json import JSONEncoder
|
||||
from credentials import user, password
|
||||
|
||||
# subclass JSONEncoder
|
||||
class DateTimeEncoder(JSONEncoder):
|
||||
#Override the default method
|
||||
def default(self, obj):
|
||||
if isinstance(obj, (datetime.date, datetime.datetime)):
|
||||
return obj.isoformat()
|
||||
|
||||
|
||||
#employeeJSONData = json.dumps(employee, indent=4, cls=DateTimeEncoder)
|
||||
|
||||
from mastodon import *
|
||||
|
||||
Mastodon.create_app(
|
||||
'0toots',
|
||||
api_base_url = 'https://mastodon.bida.im',
|
||||
to_file = 'clientcred.secret'
|
||||
)
|
||||
|
||||
mastodon = Mastodon(
|
||||
client_id = 'clientcred.secret',
|
||||
api_base_url = 'https://mastodon.bida.im'
|
||||
)
|
||||
mastodon.log_in(
|
||||
user,
|
||||
password,
|
||||
to_file = 'clientcred.secret'
|
||||
)
|
||||
|
||||
def zeroToots():
|
||||
for i in range(237265, 1, -1):
|
||||
try:
|
||||
account=mastodon.account(i)
|
||||
if account['id'] != None and not "@" in account['acct']:
|
||||
if account['statuses_count'] == 0:
|
||||
userJson = {
|
||||
'id' : account['id'],
|
||||
'acct' : account['acct'],
|
||||
'username' : account['username'],
|
||||
'created_at' : account['created_at'],
|
||||
'followers_count' : account['followers_count'],
|
||||
'following_count' : account['following_count'],
|
||||
}
|
||||
with open("user.0toot.txt", "a") as userFile:
|
||||
userFile.write((str(userJson)+ ", \n"))
|
||||
print(account['id'])
|
||||
time.sleep(2)
|
||||
except NameError as e:
|
||||
print("Oops!", e.__class__, "occurred.")
|
||||
pass
|
||||
except MastodonNotFoundError as e:
|
||||
print("Oops!", e.__class__, "occurred.")
|
||||
pass
|
||||
except MastodonAPIError as e:
|
||||
print("Oops!", e.__class__, "occurred.")
|
||||
pass
|
||||
|
||||
zeroToots()
|
Loading…
Reference in a new issue