Created
March 22, 2023 20:59
-
-
Save jmarhee/213cc6999a0afc12dea81b67b6cf3e9d to your computer and use it in GitHub Desktop.
Dump directory of video files to screenshots, script to randomly select a screenshot and post to Twitter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
import os, random | |
def main(): | |
twitter_auth_keys = { | |
"consumer_key" : os.environ['CONSUMER_KEY'], | |
"consumer_secret" : os.environ['CONSUMER_SECRET'], | |
"access_token" : os.environ['ACCESS_TOKEN'], | |
"access_token_secret" : os.environ['ACCESS_TOKEN_SECRET'] | |
} | |
auth = tweepy.OAuthHandler( | |
twitter_auth_keys['consumer_key'], | |
twitter_auth_keys['consumer_secret'] | |
) | |
auth.set_access_token( | |
twitter_auth_keys['access_token'], | |
twitter_auth_keys['access_token_secret'] | |
) | |
api = tweepy.API(auth) | |
# Upload image | |
path = os.environ['LNVC_PREV_PATH'] + random.choice(os.listdir(os.environ['LNVC_PREV_PATH'])) | |
media = api.media_upload(path) | |
# Post tweet with image | |
tweet = "#bot" | |
post_result = api.update_status(status=tweet, media_ids=[media.media_id]) | |
if __name__ == "__main__": | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# LNVC_DATA_PATH=${YOUR_VIDEO_FILE_SOURCE_DIR} | |
# LNVC_PREV_PATH=${YOUR_SCREENSHOT_TARGET_DIR} | |
REFRESH_SCREENS=1 # Any Value will Enable Clearing LNVC_PREV_PATH before running | |
if [ -z "${LNVC_DATA_PATH}" ]; then | |
echo "No source path found." ; exit 1 | |
fi | |
if [ -z "${LNVC_PREV_PATH}" ]; then | |
echo "No target path found." ; exit 1 | |
fi | |
if [ -n "${REFRESH_SCREENS}" ]; then | |
rm -rf $LNVC_PREV_PATH/*.jpg ; \ | |
fi | |
for v in `ls $LNVC_DATA_PATH`; do \ | |
ffmpeg -i $LNVC_DATA_PATH/$v -vf fps=1/90 $LNVC_PREV_PATH/$v-`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo ''`%03d.jpg | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment