mirror of
https://gitlab.com/jeancf/twoot.git
synced 2025-01-31 05:33:45 +00:00
Calling twitterdl.py as subprocess
This commit is contained in:
parent
2090d214b6
commit
6fa2019618
1
twitterdl.py
Normal file → Executable file
1
twitterdl.py
Normal file → Executable file
|
@ -1,3 +1,4 @@
|
||||||
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import requests
|
import requests
|
||||||
|
|
14
twoot.py
14
twoot.py
|
@ -29,7 +29,7 @@ import datetime, time
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from mastodon import Mastodon, MastodonError, MastodonAPIError, MastodonIllegalArgumentError
|
from mastodon import Mastodon, MastodonError, MastodonAPIError, MastodonIllegalArgumentError
|
||||||
import twitterdl
|
import subprocess
|
||||||
import json.decoder
|
import json.decoder
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
@ -128,12 +128,14 @@ def cleanup_tweet_text(tt_iter, tweet_uri, get_vids):
|
||||||
if get_vids:
|
if get_vids:
|
||||||
# Download video from twitter and store in filesystem
|
# Download video from twitter and store in filesystem
|
||||||
# TODO set output location to ./output/twit_account
|
# TODO set output location to ./output/twit_account
|
||||||
twitter_dl = twitterdl.TwitterDownloader(tweet_uri, target_width=500)
|
|
||||||
try:
|
try:
|
||||||
twitter_dl.download()
|
dl_feedback = subprocess.run(["./twitterdl.py", tweet_uri, "-w 500"], capture_output=True)
|
||||||
except json.JSONDecodeError:
|
if dl_feedback.returncode != 0:
|
||||||
print("ERROR: Could not get playlist")
|
# TODO Log dl_feedback.stderr
|
||||||
tweet_text += '\n\n[Video embedded in original tweet]'
|
tweet_text += '\n\n[Video embedded in original tweet]'
|
||||||
|
except OSError:
|
||||||
|
print("Could not execute twitterdl.py (is it there? Is it set as executable?)")
|
||||||
|
sys.exit(-1)
|
||||||
else:
|
else:
|
||||||
tweet_text += '\n\n[Video embedded in original tweet]'
|
tweet_text += '\n\n[Video embedded in original tweet]'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user