mirror of
https://github.com/cquest/tootbot.git
synced 2024-10-05 23:49:28 +00:00
do not retrieve video longer than 600s (10mn)
This commit is contained in:
parent
f54ab85f18
commit
735c495b41
13
tootbot.py
13
tootbot.py
|
@ -286,11 +286,15 @@ else:
|
|||
if m is None:
|
||||
c = c.replace(l, redir)
|
||||
else:
|
||||
print('lien:',l)
|
||||
c = c.replace(l, '')
|
||||
video = redir
|
||||
print('video:', video)
|
||||
subprocess.run('rm -f out.mp4; yt-dlp -N 8 -o out.mp4 --recode-video mp4 --no-playlist %s --max-filesize 100M' %
|
||||
video_json = subprocess.run('yt-dlp -s -j %s' %
|
||||
(video,), shell=True, capture_output=True)
|
||||
video_info = json.loads(video_json.stdout)
|
||||
if video_info['duration'] < 600:
|
||||
print('lien:', l)
|
||||
c = c.replace(l, '')
|
||||
subprocess.run('rm -f out.*; yt-dlp -N 8 -o out.mp4 --recode-video mp4 --no-playlist --max-filesize 100M %s' %
|
||||
(video,), shell=True, capture_output=False)
|
||||
print("received")
|
||||
try:
|
||||
|
@ -301,8 +305,11 @@ else:
|
|||
c = c.replace(video, '')
|
||||
print("posted")
|
||||
toot_media.append(media_posted['id'])
|
||||
os.remove("out.mp4")
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
print("video duration > 600s : ", video_info['duration'])
|
||||
|
||||
# remove pic.twitter.com links
|
||||
m = re.search(r"pic.twitter.com[^ \xa0]*", c)
|
||||
|
|
Loading…
Reference in New Issue
Block a user