Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
Recurive file finding (#42)
Browse files Browse the repository at this point in the history
* Added support for nested directories in radioFiles

* Also noted recursive file finding in README

* Finished up README updates

* Updated another README

* Base folders to help understand
  • Loading branch information
torch2424 authored Sep 21, 2018
1 parent e4d0a6c commit f33c1a1
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 4 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Scripts for piStreamRadio, a 24/7 live streaming raspberry pi. This will allows
* [Getting Started (Installation)](#getting-started-installation)
* [Updating](#updating)
* [Adding Content to the Stream](#adding-content-to-the-stream)
* [Music](#music)
* [Gifs](#gifs)
* [Interludes](#interludes)
* [Fonts](#fonts)
* [Additional Notes On Stream Content](#additional-notes-on-stream-content)
* [Helper Scripts](#helper-scripts)
* [Tips](#tips)
* [Additional Info](#additional-info)
Expand Down Expand Up @@ -89,15 +94,26 @@ Updating your stream to the latest master can sometimes have breaking changes. I

# Adding Content to the Stream

Specific directories in [radioFiles](./radioFiles) control what is shown on your stream. Please see below for the directories and what each one does. Also, please also note **files in these directories can be nested and organized in sub folders, as they are found/randomized recursively**.

### Music

Music files can be found under [radioFiles/music](./radioFiles/music). `.mp3` files may be added / removed here, and will be randomly played on your stream.

### Gifs

Gif files can be found under [radioFiles/gifs](./radioFiles/gifs). `.gif` files may be added / removed here, and will be randomly played on your stream.

### Interludes

Interlude files can be found under [radioFiles/interludes](./radioFiles/interludes). `.mp3` files may be added / removed here, and will be randomly played on your stream. Interludes should be used for little radio breaks, or maybe you giving a shout out to the radio station. This is simply for fun, and can give a more "radio" feel

### Fonts

Font files can be found under [radioFiles/fonts](./radioFiles/fonts). `.ttf` files may be added / removed here, and will be used as the onscreen text of your stream.

**Additional Notes On Stream Content:**
### Additional Notes On Stream Content

* Content on the stream will only be updated after a new song is loaded and played.

# Helper Scripts
Expand Down
5 changes: 3 additions & 2 deletions getFileFromDir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

# Function to get random file from a directory
if [ "$#" -ne 1 ]; then
echo "getFileFromDir.sh: Bash Script to return a random file from a directory"
echo "getFileFromDir.sh: Bash Script to return a random file from a directory."
echo "This works recursively, and will not list directories, only files"
echo " "
echo "USAGE: ./getFileFromDir.sh [Directory path]"
else
# Use find instead of ls to better handle non-alphanumeric filenames.
ranfile=$( find "$1" -mindepth 1 | sort --random-sort | tail -1 )
ranfile=$( find "$1" -mindepth 1 -type f | sort --random-sort | tail -1 )
echo "$ranfile"
fi
2 changes: 1 addition & 1 deletion radioFiles/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Folders for the files for the radio

Don't place folders within these folders, and ensure the files are of the correct format for each folder
You may place folders within these base folders, as content is found/randomized recursively. However, ensure that the files are of the correct format for each respective base folder.

`music` is where ".mp3" is stored to be played as songs on the station
`gifs` is where ".gif" files are stored to be encoded
Expand Down
Binary file not shown.
12 changes: 12 additions & 0 deletions startStream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ while true ; do
# Create our video text from the random song
rm $STREAM_TEXT_PATH
echo "$INTERLUDE_TEXT" >> "$STREAM_TEXT_PATH"

echo " "
echo "Playing Interlude:"
echo "Path: $RANDOM_SONG"
echo " "
else
# Get our random song
RANDOM_SONG=$(./getFileFromDir.sh "$MUSIC_DIRECTORY")
Expand All @@ -72,6 +77,13 @@ while true ; do
echo "Artist: $ARTIST" >> "$STREAM_TEXT_PATH"
echo " " >> /tmp/stream.txt
echo "Song: $SONG_NAME" >> "$STREAM_TEXT_PATH"

echo " "
echo "Playing Song:"
echo "Path: $RANDOM_SONG"
echo "Artist: $ARTIST"
echo "Song: $SONG_NAME"
echo " "
fi

# Create our two threads of audio playing, and the stream
Expand Down

0 comments on commit f33c1a1

Please sign in to comment.