Reformat some code

This commit is contained in:
jeancf 2023-09-14 11:30:55 +02:00
parent 22a8df8983
commit 9b29471140

View File

@ -29,7 +29,7 @@ import sqlite3
import sys import sys
import time import time
from pathlib import Path from pathlib import Path
from urllib.parse import urlparse, parse_qsl, urlencode, urlunparse, urljoin, unquote from urllib.parse import urlparse, parse_qsl, urlencode, urlunparse, urljoin
import requests import requests
from bs4 import BeautifulSoup, element from bs4 import BeautifulSoup, element
@ -172,6 +172,7 @@ def build_config(args):
exit(-1) exit(-1)
def _get_rest_of_thread(session, headers, nitter_url, thread_url, first_item):
""" """
Dowload page with full thread of tweets and extract all replied to tweet reference by url. Dowload page with full thread of tweets and extract all replied to tweet reference by url.
Only used by `get_timeline()`. Only used by `get_timeline()`.
@ -181,7 +182,6 @@ Only used by `get_timeline()`.
:param thread_url: url of the first tweet in thread :param thread_url: url of the first tweet in thread
:return: list of tuples with url of tweet replied-to (or None) and content of tweet :return: list of tuples with url of tweet replied-to (or None) and content of tweet
""" """
def _get_rest_of_thread(session, headers, nitter_url, thread_url, first_item):
# Add first item to timeline # Add first item to timeline
timeline = [(None, first_item)] timeline = [(None, first_item)]
@ -235,12 +235,12 @@ def _get_rest_of_thread(session, headers, nitter_url, thread_url, first_item):
return timeline return timeline
def get_timeline(nitter_url):
""" """
Download timeline of twitter account Download timeline of twitter account
:param url: url of the account page to download :param url: url of the account page to download
:return: list of tuples with url of tweet replied-to (or None) and content of tweet :return: list of tuples with url of tweet replied-to (or None) and content of tweet
""" """
def get_timeline(nitter_url):
# Define url to use # Define url to use
url = nitter_url + '/' + TOML['config']['twitter_account'] url = nitter_url + '/' + TOML['config']['twitter_account']
@ -419,6 +419,7 @@ def update_profile(nitter_url, soup, sql, mast_password):
return mastodon return mastodon
def deredir_url(url): def deredir_url(url):
""" """
Given a URL, return the URL that the page really downloads from Given a URL, return the URL that the page really downloads from