-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for stream titles/custom date format in filename #6
base: master
Are you sure you want to change the base?
Changes from 2 commits
0c413d2
3084830
c152c94
1d0b3cf
a0acd58
cac8ed4
f554b61
bc71d40
caffad9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,13 +7,19 @@ WEBSOCKET_URL="wss://pubsub-edge.twitch.tv/v1" | |||||
CLIENT_ID="jzkbprff40iqj646a697cyrvl0zt2m6" | ||||||
|
||||||
PRINT_FILENAME=0 | ||||||
FILENAME_TITLE=0 | ||||||
FILENAME_DATE=0 | ||||||
|
||||||
errf(){ >&2 printf "$@"; } | ||||||
|
||||||
get_id () { | ||||||
curl --silent --fail -H "Client-ID: $CLIENT_ID" "$API_URL$1" | jq -r ._id | ||||||
} | ||||||
|
||||||
get_stream_title () { | ||||||
curl --silent --fail -H "Client-ID: $CLIENT_ID" "$API_URL$1" | jq -r .status | ||||||
} | ||||||
|
||||||
print_usage() { | ||||||
errf "Usage: record [OPTIONS...] <USERNAMES...>\n" | ||||||
errf "\n" | ||||||
|
@@ -41,7 +47,7 @@ invalid_input() { | |||||
|
||||||
check_deps | ||||||
|
||||||
while getopts ":ph" opt | ||||||
while getopts "d:pht" opt | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This should be ":phtd:", ":" at the start of a getopt argument prevents it from displaying debug errors. |
||||||
do | ||||||
case "$opt" in | ||||||
p ) | ||||||
|
@@ -51,6 +57,14 @@ do | |||||
print_usage | ||||||
exit 0 | ||||||
;; | ||||||
t ) | ||||||
FILENAME_TITLE=1 | ||||||
;; | ||||||
d ) | ||||||
FILENAME_DATE=1 | ||||||
DFORMAT="+""$OPTARG" | ||||||
#OPTIND=`echo $OPTIND + 1 | bc` | ||||||
;; | ||||||
\? ) | ||||||
invalid_input "$(printf $'unknown option \'-%s\'' "$OPTARG")" | ||||||
;; | ||||||
|
@@ -113,11 +127,27 @@ done | |||||
then | ||||||
( | ||||||
username=${id_username[$id]} | ||||||
|
||||||
errf '[%s] stream started\a\n' "$username" | ||||||
while : | ||||||
do | ||||||
mkdir -p "$username" | ||||||
filename=$(printf "%s/%s.ts" $username "$(date -u '+%Y_%m_%d_%H_%M_%S_(%Z)')") | ||||||
|
||||||
filename="$username/" | ||||||
|
||||||
if [ "$FILENAME_TITLE" == "1" ]; | ||||||
then | ||||||
title=$(get_stream_title $username) | ||||||
filename+="${title}_" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to sanitize the filename somehow, as it is, if a streamer has their title set to |
||||||
fi | ||||||
if [ "$FILENAME_DATE" == "1" ]; | ||||||
then | ||||||
filename+=$(date $DFORMAT) | ||||||
else | ||||||
filename+=$(date -u '+%Y-%m-%d-%H-%M-%S-(%Z)') | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I would also prefer the date format stay the same as it was before, |
||||||
fi | ||||||
filename+=".ts" | ||||||
|
||||||
errf '[%s] recording to %s\n' "$username" "$filename" | ||||||
(twitchpipe --archive "$username" >> "$filename") 2>&1 | ( | ||||||
while read -r line; | ||||||
|
@@ -148,4 +178,4 @@ done | |||||
;; | ||||||
esac | ||||||
done | ||||||
) | ||||||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new switches should be added to the usage text.