jenslys / autovod

Automatically upload Twitch.tv / Kick.com streams in realtime to Youtube or a Rclone supported provider
MIT License
94 stars 10 forks source link

$($TIME_DATE) is never changing. $($TIME_CLOCK) totally wrong, #86

Closed warpz0ne88 closed 7 months ago

warpz0ne88 commented 8 months ago

date never changes, i guess its just using the date wehn the script was started ? date will never change on new uploads

jFY34ma

also the time_clock seems totally wrong, its grabbing the time from twitch ? i guess booth should use the local/host time/date

jenslys commented 8 months ago

The command substitution $($TIME_DATE) will execute the date command each time the loop iterates. so it should constantly update.

What do you mean its grabbing the time from twitch? its grabbing it from the system using this format: hour-min-second22_37_01

You also have to provide your config so i can try to debug this...

warpz0ne88 commented 8 months ago

so here is my default config.

#!/bin/bash
# shellcheck disable=SC2034
#! Do not edit this file directly, instead create a new file with the name of the streamer you want to record. (e.g: asmongold.config)
set -a

#* Source
STREAM_SOURCE="twitch" #* Options: twitch, kick, youtube

#* Upload provider
UPLOAD_SERVICE="youtube" #* Options: youtube, rclone, restream, local

#* Twitch metadata settings:
API_CALLS="true" #? Enable this to fetch additional metadata from the Twitch API. API_URL must be set to a valid API URL.
API_URL="https://tw-test.vercel.app/"        #? API for fetching stream metadata. (e.g: https://example.com/info/)

#? Variables that can be used in VIDEO_TITLE, YOUTUBE_VIDEO_DESCRIPTION, YOUTUBE_VIDEO_PLAYLIST, RCLONE_FILENAME and LOCAL_FILENAME.
STREAMER_TITLE="initial_title" #? The title of the stream. (This is only available if API_CALLS is set to true.) [! Do not change these values]
STREAMER_GAME="inital_game"    #? The current game the user is playing. (This is only available if API_CALLS is set to true.) [! Do not change these values]
#? $STREAMER_NAME - The name of the streamer.
#? $($TIME_DATE) - The current date (day/month/year).
#? $($TIME_CLOCK) - The current time (hour:minute:second).

#* Streamlink settings (Valid for all upload providers)
STREAMLINK_QUALITY="best"                                               #* Options: worst, 360p, 480p, 720p, 720p60, 1080p60, best
STREAMLINK_FLAGS=("--twitch-disable-reruns" "--twitch-disable-hosting" "--twitch-api-header=Authorization=OAuth censored") #? Options to pass to streamlink. (NB! Array not a string) (https://streamlink.github.io/cli.html#twitch)
STREAMLINK_LOGS="error"                                                 #* Options: none, error, warning, info, debug, trace, all

#* Universal Upload settings (Valid for all upload providers)
VIDEO_DURATION="12:00:00"       #? XX:XX:XX (Notice: YouTube has a upload limit of 12 hours per video).
SPLIT_INTO_PARTS="false"        #? If you want to split the video into parts, set this to true. (if this is enabled VIDEO_DURATION is ignored).
SPLIT_VIDEO_DURATION="06:00:00" #? Set the duration of each part. (XX:XX:XX)
SAVE_ON_FAIL="false"            #? If you want to save the video that failed to upload, set this to true.

#* YouTube upload settings (Only valid if UPLOAD_SERVICE is set to youtube)
VIDEO_TITLE="$STREAMER_NAME - $($TIME_DATE)"                          #? Title of the video.
VIDEO_DESCRIPTION="Uploaded using AutoVOD" #? YouTube video description.
VIDEO_VISIBILITY="unlisted"                                           #* Options: unlisted, private, public
VIDEO_PLAYLIST="$STREAMER_NAME VODs"                                  #? Playlist to upload to.

#* Rclone upload settings (Only valid if UPLOAD_SERVICE is set to rclone)
RCLONE_REMOTE="remote-name"                      #? Rclone remote to upload to.
RCLONE_DIR=""                                    #? Directory to upload to.
RCLONE_FILENAME="$STREAMER_NAME"_"$($TIME_DATE)" #? Filename of the video on the remote. (Dont use spaces in the filename, use dashes or undersores instead.)
RCLONE_FILEEXT="mkv"                             #? File extension of the video on the remote.

#* Re-Stream settings (Only valid if UPLOAD_SERVICE is set to restream)
RTMPS_URL="rtmp://a.rtmp.youtube.com/live2/"
RTMPS_STREAM_KEY=""
AUDIO_BITRATE="44100"
AUDIO_CODEC="aac"
FILE_FORMAT="flv"

#* Local settings (Only valid if UPLOAD_SERVICE is set to local)
LOCAL_FILENAME="$STREAMER_NAME"_"$($TIME_DATE)" #? Filename/filepath of the local recording. (Dont use spaces in the filename, use dashes or undersores instead.)
LOCAL_EXTENSION="mkv"                           #? File extension of the local recording.

#* Re-Encoding settings (Currently only works if UPLOAD_SERVICE is set to rclone or local)
#? Re-encodes the stream to a desired codec and quality using ffmpeg. This can be useful if you want to save space on your remote. (Only recommended if you have a high-end server.)
RE_ENCODE="false"         #? Set this to true if you want to re-encode the video.
RE_ENCODE_CODEC="libx265" #* Options: libx265, libvpx-vp9, libaom-av1 (https://ffmpeg.org/ffmpeg-codecs.html)
RE_ENCODE_CRF="25"        #* Options: 0-51 (lower is better quality, but larger file size) (https://slhck.info/video/2017/02/24/crf-guide.html)
RE_ECODE_PRESET="medium"  #* Options: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow (https://trac.ffmpeg.org/wiki/Encode/H.265)
RE_ENCODE_LOG="error"     #* Options: none, error, warning, info, debug, trace, all

set +a
hui1601 commented 7 months ago

The config file is actually a bash script file. So, it runs when loaded from AutoVod.sh. https://github.com/jenslys/autovod/blob/f96c30ac54845bbec8b50899eab9f98cb0943ecc/AutoVOD.sh#L49-L55

At this time, the $TIME_DATE command is executed by $($TIME_DATE) at the time the LOCAL_FILENAME value is loaded. https://github.com/jenslys/autovod/blob/f96c30ac54845bbec8b50899eab9f98cb0943ecc/default.config#L53-L55 https://github.com/jenslys/autovod/blob/f96c30ac54845bbec8b50899eab9f98cb0943ecc/AutoVOD.sh#L3-L5 Therefore, date +%d-%m-%y is executed and the name of the file to be saved is determined by the load time of the config script.

There are several solutions.

  1. Load the config script on every download attempt → It's simple, but it's a trick.
  2. Instead of using $($TIME_DATE) in the config script, use TIME_DATE, replacing the TIME_DATE string with $($TIME_DATE) whenever necessary → probably the most user-friendly. You need to do the same for TIME_CLOCK

There may be a better way, but these are the only ones I can think of.

jenslys commented 7 months ago

The config file is actually a bash script file. So, it runs when loaded from AutoVod.sh.

https://github.com/jenslys/autovod/blob/f96c30ac54845bbec8b50899eab9f98cb0943ecc/AutoVOD.sh#L49-L55

At this time, the $TIME_DATE command is executed by $($TIME_DATE) at the time the LOCAL_FILENAME value is loaded.

https://github.com/jenslys/autovod/blob/f96c30ac54845bbec8b50899eab9f98cb0943ecc/default.config#L53-L55

https://github.com/jenslys/autovod/blob/f96c30ac54845bbec8b50899eab9f98cb0943ecc/AutoVOD.sh#L3-L5

Therefore, date +%d-%m-%y is executed and the name of the file to be saved is determined by the load time of the config script. There are several solutions.

  1. Load the config script on every download attempt → It's simple, but it's a trick.
  2. Instead of using $($TIME_DATE) in the config script, use TIME_DATE, replacing the TIME_DATE string with $($TIME_DATE) whenever necessary → probably the most user-friendly. You need to do the same for TIME_CLOCK

There may be a better way, but these are the only ones I can think of.

Yeah, i think the best would be to replace $($TIME_DATE) in the config, do you mind opening a PR for this? i dont have time to work on this for a couple of weeks. @hui1601

hui1601 commented 7 months ago

I already fixed this bug anyway. However, constantly changing file name values ​​can result in numerous empty files being created in many cases, such as when the channel is not live. So, I haven't committed any changes yet 😕 Due to my personal schedule and need to test various cases, I will clean up the code and open a pull request next week :)