plugfiles

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 220cdcf9b402ecea5d78a1922d6133ea695fa3ce
parent 56a580234946e7ad4b2bd45a0991ac34a40a2a28
Author: NicholasFarrow <nicholas.w.farrow@gmail.com>
Date:   Fri,  7 Jun 2019 02:13:59 +1000

updated downloading and storing

Diffstat:
Mstarshell.sh | 43+++++++++++++++----------------------------
1 file changed, 15 insertions(+), 28 deletions(-)

diff --git a/starshell.sh b/starshell.sh @@ -1,43 +1,30 @@ #!/bin/bash +# Nicholas Farrow 2019 CFGLOC=~/.config SCENEDIR=$CFGLOC/starshell +STARTSCENE=115 + # Make folder if doesn't exist [ -d $SCENEDIR ] || mkdir $SCENEDIR -# Save starwars to file -if [ ! -f $SCENEDIR/main ]; then - telnet towel.blinkenlights.nl | sed -e 's/\[H/Z/g' | tee $SCENEDIR/main +# If $STARTSCENE scene file does not exist, save starwars to file +if [ ! -f $SCENEDIR/s_$STARTSCENE ]; then + #telnet towel.blinkenlights.nl | sed -e 's/.\[H/Z/g' | tee $SCENEDIR/main SCENEDATA=$(<"$SCENEDIR/main") - + # Load scenes - IFS=$'Z' read -d '' -ra SCENES <<< "$SCENEDATA" - - # Save "good" scenes to files + IFS=$'Z' read -d '' -ra SCENES <<< "$SCENEDATA" + + echo ${#SCENES[@]} + + # Save "good" scenes to invividual files for SCENENUM in $(seq 115 ${#SCENES[@]}); do - echo "${SCENES[$SCENENUM]}" >> $SCENEDIR/s_$SCENENUM + echo "${SCENES[$SCENENUM]}" >> $SCENEDIR/s_$SCENENUM + echo $SCENENUM done fi +# Print random scene echo "$(<$(ls "$SCENEDIR/s_"* | shuf -n 1))" - - -# Approx first 115 scenes are garbage -#SCENENUM=$(shuf -i 100-${#SCENES[@]} -n 1) -#echo "${SCENES[$SCENENUM]}" - -#mkdir $CFGLOC/.starshell - - - -#for i in $(seq 115 ${#SCENES[@]}); do -#for SCENE in "${SCENES[@]}"; do -# echo "$SCENE" >> -#done -# -# -#echo ${#SCENES[@]} - - -