mirror of
https://gitlab.com/jeancf/twoot.git
synced 2025-02-25 09:28:43 +00:00
Add comments
This commit is contained in:
parent
b10a8392c8
commit
cdc1fb03f7
14
twoot.py
14
twoot.py
@ -295,9 +295,9 @@ def get_timeline(nitter_url):
|
|||||||
timeline = []
|
timeline = []
|
||||||
for item in list:
|
for item in list:
|
||||||
classes = item['class']
|
classes = item['class']
|
||||||
if 'timeline-item' in classes:
|
if 'timeline-item' in classes: # Individual tweet
|
||||||
timeline.append(item)
|
timeline.append(item)
|
||||||
elif 'thread-line' in classes:
|
elif 'thread-line' in classes: # First tweet of a thread
|
||||||
# Get the first item of thread
|
# Get the first item of thread
|
||||||
first_item = item.find('div', class_='timeline-item')
|
first_item = item.find('div', class_='timeline-item')
|
||||||
timeline.append(first_item)
|
timeline.append(first_item)
|
||||||
@ -956,21 +956,17 @@ def main(argv):
|
|||||||
# Select random nitter instance to fetch updates from
|
# Select random nitter instance to fetch updates from
|
||||||
nitter_url = 'https://' + NITTER_URLS[random.randint(0, len(NITTER_URLS) - 1)]
|
nitter_url = 'https://' + NITTER_URLS[random.randint(0, len(NITTER_URLS) - 1)]
|
||||||
|
|
||||||
# **********************************************************
|
|
||||||
# Load twitter page of user. Process all tweets and generate
|
|
||||||
# list of dictionaries ready to be posted on Mastodon
|
|
||||||
# **********************************************************
|
|
||||||
# To store content of all tweets from this user
|
|
||||||
tweets = []
|
|
||||||
|
|
||||||
|
# Load twitter page of user
|
||||||
soup, timeline = get_timeline(nitter_url)
|
soup, timeline = get_timeline(nitter_url)
|
||||||
|
|
||||||
logging.info('Processing ' + str(len(timeline)) + ' tweets found in timeline')
|
logging.info('Processing ' + str(len(timeline)) + ' tweets found in timeline')
|
||||||
|
|
||||||
# **********************************************************
|
# **********************************************************
|
||||||
# Process each tweets and generate dictionary
|
# Process each tweets and generate an array of dictionaries
|
||||||
# with data ready to be posted on Mastodon
|
# with data ready to be posted on Mastodon
|
||||||
# **********************************************************
|
# **********************************************************
|
||||||
|
tweets = []
|
||||||
out_date_cnt = 0
|
out_date_cnt = 0
|
||||||
in_db_cnt = 0
|
in_db_cnt = 0
|
||||||
for status in timeline:
|
for status in timeline:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user