mirror of
https://gitlab.com/jeancf/twoot.git
synced 2024-11-23 20:11:11 +00:00
Put it in a function
This commit is contained in:
parent
17bbcb7372
commit
3583186d3f
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,6 +1,7 @@
|
|||
.idea/
|
||||
.vscode/
|
||||
venv/
|
||||
__pycache__/
|
||||
*.secret
|
||||
*.sh
|
||||
*.log
|
||||
|
|
28
twoot.py
28
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')
|
||||
|
|
Loading…
Reference in New Issue
Block a user