Compare commits

...

3 Commits

Author SHA1 Message Date
jeancf
b09ee35f5c Updated documentation 2023-07-22 11:00:16 +02:00
jeancf
2327294af3 Ignore timeline-item without tweet-link tag 2023-07-22 10:48:54 +02:00
jeancf
b69ac01b3c Improve detection of missing video 2023-07-22 09:56:54 +02:00
3 changed files with 41 additions and 23 deletions

View File

@ -1,5 +1,11 @@
# Changelog
**17 JUL 2023** VERSION 4.3
* Twitter threads are replicated on Mastodon: each follow-up message in a thread is posted
as a reply to its predecessor.
* An issue with downloading videos has been fixed ("ERROR: Sorry, you are not authorized to see this status").
**14 JUL 2023** VERSION 4.2
Twoot can now handle threads. All tweets can again be uploaded on Mastodon. Tweets in a threads are

View File

@ -3,11 +3,12 @@
Twoot is a python script that mirrors tweets from a twitter account to a Mastodon account.
It is simple to set-up on a local machine, configurable and feature-rich.
**17 JUL 2023** VERSION 4.3
**22 JUL 2023** VERSION 4.3.1
* Twitter threads are replicated on Mastodon: each follow-up message in a thread is posted
as a reply to its predecessor.
* An issue with downloading videos has been fixed ("ERROR: Sorry, you are not authorized to see this status").
Minor improvements of robustness (avoid interruption of processing):
* Ignore timeline-item without tweet-link tag
* Improve detection of missing video
> Previous updates can be found in CHANGELOG.

View File

@ -674,25 +674,31 @@ def process_attachments(nitter_url, attachments_container, status_id, author_acc
logging.debug("downloading video from twitter")
import youtube_dl
video_path = vid_container.source['src']
if video_path is not None:
video_file = urljoin(nitter_url, video_path)
ydl_opts = {
'outtmpl': "output/" + TOML['config']['twitter_account'] + "/" + status_id + "/%(id)s.%(ext)s",
# 'format': "best[width<=500]",
'socket_timeout': 60,
'quiet': True,
}
video_path_source = vid_container.source
if video_path_source is not None:
video_path = video_path_source['src']
if video_path is not None:
video_file = urljoin(nitter_url, video_path)
ydl_opts = {
'outtmpl': "output/" + TOML['config']['twitter_account'] + "/" + status_id + "/%(id)s.%(ext)s",
# 'format': "best[width<=500]",
'socket_timeout': 60,
'quiet': True,
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
try:
ydl.download([video_file])
except Exception as e:
logging.warning('Error downloading twitter video: ' + str(e))
vid_in_tweet = True
else:
logging.debug('downloaded twitter video from attachments')
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
try:
ydl.download([video_file])
except Exception as e:
logging.warning('Error downloading twitter video: ' + str(e))
vid_in_tweet = True
else:
logging.debug('downloaded twitter video from attachments')
else:
logging.debug("Media is unavailable")
vid_in_tweet = True
else:
logging.debug("Media is unavailable")
vid_in_tweet = True
return pics, vid_in_tweet
@ -969,7 +975,12 @@ def main(argv):
in_db_cnt = 0
for replied_to_tweet, status in timeline:
# Extract tweet ID and status ID
tweet_id = status.find('a', class_='tweet-link').get('href').strip('#m')
tweet_link_tag = status.find('a', class_='tweet-link')
if tweet_link_tag is None:
logging.debug("Malformed timeline item (no tweet link), skipping")
continue
tweet_id = tweet_link_tag.get('href').strip('#m')
status_id = tweet_id.split('/')[3]
logging.debug('processing tweet %s', tweet_id)
@ -1057,7 +1068,7 @@ def main(argv):
status_id, author_account)
photos.extend(pics)
if vid_in_tweet:
tweet_text += '\n\n[Video embedded in original tweet]'
tweet_text += '\n\n[Video is unavailable]'
# Add custom footer from config file
if TOML['options']['footer'] != '':