mirror of
https://gitlab.com/jeancf/twoot.git
synced 2024-11-23 20:11:11 +00:00
Added debug messages
This commit is contained in:
parent
dff168baa4
commit
870a1ee745
18
twoot.py
18
twoot.py
|
@ -180,11 +180,6 @@ def update_profile(nitter_url, soup, sql, mast_password):
|
|||
"""
|
||||
# TODO Check if TOML option to update profile is set
|
||||
|
||||
# @noirextreme banner before https://nitter.net/pic/https%3A%2F%2Fpbs.twimg.com%2Fprofile_banners%2F57014511%2F1525787041%2F1500x500
|
||||
# after https://nitter.net/pic/https%3A%2F%2Fpbs.twimg.com%2Fprofile_banners%2F57014511%2F1686822924%2F1500x500
|
||||
# @noirextreme avatar before https://pbs.twimg.com/profile_images/1081778074/Twitter_400x400.png
|
||||
# after
|
||||
|
||||
db = sql.cursor()
|
||||
|
||||
# Extract avatar picture address
|
||||
|
@ -216,6 +211,7 @@ def update_profile(nitter_url, soup, sql, mast_password):
|
|||
db.execute("INSERT INTO profiles (mastodon_account, avatar_url, banner_url) VALUES (?, ?, ?)", (TOML['config']['mastodon_user'], "", ""))
|
||||
sql.commit()
|
||||
changed = True
|
||||
logging.debug("added new profile to database")
|
||||
|
||||
mastodon = None
|
||||
|
||||
|
@ -228,13 +224,13 @@ def update_profile(nitter_url, soup, sql, mast_password):
|
|||
new_avatar_img = new_avatar.content if new_avatar.status_code == 200 else None
|
||||
new_avatar_mime = new_avatar.headers['content-type'] if new_avatar.status_code == 200 else None
|
||||
if new_avatar.status_code !=200:
|
||||
logging.error("Could not download image from " + nitter_url + new_avatar_url)
|
||||
logging.error("Could not download avatar image from " + nitter_url + new_avatar_url)
|
||||
|
||||
new_banner = requests.get(nitter_url + new_banner_url, timeout=HTTPS_REQ_TIMEOUT) if new_banner_url is not None else None
|
||||
new_banner_img = new_banner.content if new_banner.status_code == 200 else None
|
||||
new_banner_mime = new_banner.headers['content-type'] if new_banner.status_code == 200 else None
|
||||
if new_banner.status_code !=200:
|
||||
logging.error("Could not download image from " + nitter_url + new_banner_url)
|
||||
logging.error("Could not download banner image from " + nitter_url + new_banner_url)
|
||||
|
||||
mastodon = login(mast_password)
|
||||
# Update profile on Mastodon
|
||||
|
@ -248,8 +244,8 @@ def update_profile(nitter_url, soup, sql, mast_password):
|
|||
# Add urls to database
|
||||
db.execute("UPDATE profiles SET avatar_url=?, banner_url=? WHERE mastodon_account=?", (new_avatar_url, new_banner_url, TOML['config']['mastodon_user']))
|
||||
sql.commit()
|
||||
logging.debug("updated profile on database")
|
||||
|
||||
exit(5)
|
||||
return mastodon
|
||||
|
||||
def deredir_url(url):
|
||||
|
@ -832,9 +828,9 @@ def main(argv):
|
|||
logging.debug('Nitter page downloaded successfully from ' + url)
|
||||
|
||||
# DEBUG: Save page to file
|
||||
of = open(TOML['config']['twitter_account'] + '.html', 'w')
|
||||
of.write(twit_account_page.text)
|
||||
of.close()
|
||||
# of = open(TOML['config']['twitter_account'] + '.html', 'w')
|
||||
# of.write(twit_account_page.text)
|
||||
# of.close()
|
||||
|
||||
# Make soup
|
||||
soup = BeautifulSoup(twit_account_page.text, 'html.parser')
|
||||
|
|
Loading…
Reference in New Issue
Block a user