mirror of
https://gitlab.com/jeancf/twoot.git
synced 2025-02-25 01:18:41 +00:00
Compare commits
No commits in common. "b09ee35f5c5f4fd895e3f9282ae082c173477898" and "e512838a0e8e8d29374536023c55be0d1d4b090c" have entirely different histories.
b09ee35f5c
...
e512838a0e
@ -1,11 +1,5 @@
|
||||
# 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
|
||||
|
@ -3,12 +3,11 @@
|
||||
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.
|
||||
|
||||
**22 JUL 2023** VERSION 4.3.1
|
||||
**17 JUL 2023** VERSION 4.3
|
||||
|
||||
Minor improvements of robustness (avoid interruption of processing):
|
||||
|
||||
* Ignore timeline-item without tweet-link tag
|
||||
* Improve detection of missing video
|
||||
* 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").
|
||||
|
||||
> Previous updates can be found in CHANGELOG.
|
||||
|
||||
|
49
twoot.py
49
twoot.py
@ -674,31 +674,25 @@ def process_attachments(nitter_url, attachments_container, status_id, author_acc
|
||||
logging.debug("downloading video from twitter")
|
||||
import youtube_dl
|
||||
|
||||
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,
|
||||
}
|
||||
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,
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
return pics, vid_in_tweet
|
||||
@ -975,12 +969,7 @@ def main(argv):
|
||||
in_db_cnt = 0
|
||||
for replied_to_tweet, status in timeline:
|
||||
# Extract tweet ID and status ID
|
||||
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')
|
||||
tweet_id = status.find('a', class_='tweet-link').get('href').strip('#m')
|
||||
status_id = tweet_id.split('/')[3]
|
||||
|
||||
logging.debug('processing tweet %s', tweet_id)
|
||||
@ -1068,7 +1057,7 @@ def main(argv):
|
||||
status_id, author_account)
|
||||
photos.extend(pics)
|
||||
if vid_in_tweet:
|
||||
tweet_text += '\n\n[Video is unavailable]'
|
||||
tweet_text += '\n\n[Video embedded in original tweet]'
|
||||
|
||||
# Add custom footer from config file
|
||||
if TOML['options']['footer'] != '':
|
||||
|
Loading…
x
Reference in New Issue
Block a user