mirror of
https://gitlab.com/jeancf/twoot.git
synced 2024-11-24 04:21:13 +00:00
placed nitter url in const
This commit is contained in:
parent
3b752ffca1
commit
8e4f13c26a
9
twoot.py
9
twoot.py
|
@ -34,6 +34,7 @@ from mastodon import Mastodon, MastodonError, MastodonAPIError, MastodonIllegalA
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
NITTER_URL = 'https://nitter.42l.fr'
|
||||||
|
|
||||||
# Update from https://www.whatismybrowser.com/guides/the-latest-user-agent/
|
# Update from https://www.whatismybrowser.com/guides/the-latest-user-agent/
|
||||||
USER_AGENTS = [
|
USER_AGENTS = [
|
||||||
|
@ -86,7 +87,7 @@ def process_card(card_container):
|
||||||
|
|
||||||
img = card_container.div.div.img
|
img = card_container.div.div.img
|
||||||
if img is not None:
|
if img is not None:
|
||||||
image_url = 'https://nitter.net' + img.get('src')
|
image_url = NITTER_URL + img.get('src')
|
||||||
list.append(image_url)
|
list.append(image_url)
|
||||||
logging.debug('Extracted image from card')
|
logging.debug('Extracted image from card')
|
||||||
|
|
||||||
|
@ -107,14 +108,14 @@ def process_attachments(attachments_container, get_vids, twit_account, status_id
|
||||||
pics = []
|
pics = []
|
||||||
images = attachments_container.find_all('a', class_='still-image')
|
images = attachments_container.find_all('a', class_='still-image')
|
||||||
for image in images:
|
for image in images:
|
||||||
pics.append('https://nitter.net' + image.get('href'))
|
pics.append(NITTER_URL + image.get('href'))
|
||||||
|
|
||||||
logging.debug('collected ' + str(len(pics)) + ' images from attachments')
|
logging.debug('collected ' + str(len(pics)) + ' images from attachments')
|
||||||
|
|
||||||
# Download nitter video (converted animated GIF)
|
# Download nitter video (converted animated GIF)
|
||||||
gif_class = attachments_container.find('video', class_='gif')
|
gif_class = attachments_container.find('video', class_='gif')
|
||||||
if gif_class is not None:
|
if gif_class is not None:
|
||||||
gif_video_file = 'https://nitter.net' + gif_class.source.get('src')
|
gif_video_file = NITTER_URL + gif_class.source.get('src')
|
||||||
|
|
||||||
video_path = os.path.join('output', twit_account, status_id, author_account, status_id)
|
video_path = os.path.join('output', twit_account, status_id, author_account, status_id)
|
||||||
os.makedirs(video_path, exist_ok=True)
|
os.makedirs(video_path, exist_ok=True)
|
||||||
|
@ -260,7 +261,7 @@ def main(argv):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
url = 'https://nitter.net/' + twit_account
|
url = NITTER_URL + '/' + twit_account
|
||||||
# Use different page if we need to handle replies
|
# Use different page if we need to handle replies
|
||||||
if tweets_and_replies:
|
if tweets_and_replies:
|
||||||
url += '/with_replies'
|
url += '/with_replies'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user