diff --git a/.gitignore b/.gitignore index 0b5f6e7..640c16f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea/ .vscode/ venv/ +__pycache__/ *.secret *.sh *.log diff --git a/twoot.py b/twoot.py index c43f3ff..4991e28 100755 --- a/twoot.py +++ b/twoot.py @@ -169,6 +169,16 @@ def build_config(args): print('CRITICAL: Missing Mastodon user') terminate(-1) +def update_profile(TOML, soup, db, mast_password): + # Extract avatar picture address + avatar_url = 'https://' + unquote(soup.find('div', class_='profile-card-info').findChild('a').findChild('img').get('src').removeprefix('/pic/')) + + # Extract banner picture address + banner_url = unquote(soup.find('div', class_='profile-banner').findChild('a').findChild('img').get('src').removeprefix('/pic/')) + + mastodon_account = TOML['config']['mastodon_user'] + + exit() def deredir_url(url): """ @@ -750,22 +760,16 @@ 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') - # Extract avatar picture address - avatar = 'https://' + unquote(soup.find('div', class_='profile-card-info').findChild('a').findChild('img').get('src').removeprefix('/pic/')) - - # Extract banner picture address - banner = unquote(soup.find('div', class_='profile-banner').findChild('a').findChild('img').get('src').removeprefix('/pic/')) - - print(avatar) - print(banner) - exit(0) + # Update profile if it has changed + # TODO Make conditional to TOML option + update_profile(TOML, soup, db, mast_password) # Extract twitter timeline timeline = soup.find_all('div', class_='timeline-item')