Put it in a function

This commit is contained in:
jeancf 2023-06-13 17:28:05 +02:00
parent 17bbcb7372
commit 3583186d3f
2 changed files with 17 additions and 12 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
.idea/
.vscode/
venv/
__pycache__/
*.secret
*.sh
*.log

View File

@ -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')