if [%~1] == [--debug] goto skip
@echo off
:skip
SETLOCAL EnableDelayedExpansion
REM for the Kill Me Baby Screens Bot twitter account

for /F "delims=" %%a in ('randfile.exe') do set "episode=%%a"
for /F "tokens=1 delims=." %%a in ('ffprobe -v quiet -of csv^=p^=0 -show_entries format^=duration "E:\Movies\Anime\Kill Me Baby\%episode%"') do set "length=%%a"

echo %episode%
echo %length%

SET /A test=%RANDOM% * !length! / 32768 + 1

echo %test%

ffmpeg.exe -hide_banner -loglevel warning -i "E:\Movies\Anime\Kill Me Baby\%episode%" -y -frames:v 1 -ss %test% screencap.jpg

for /F "usebackq tokens=1 delims=" %%a in (`twurl -H "upload.twitter.com" -X POST "/1.1/media/upload.json" --file "screencap.jpg" --file-field "media" ^| jq -r .media_id_string `) do set "media_id=%%a"
twurl "/1.1/statuses/update.json" -d "media_ids=%media_id%"
