Skip to content
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

Created the audiofilelibrary package #37

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions audiofilelibrary.go → audiofilelibrary/audiofilelibrary.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package main
package audiofilelibrary

import (
"errors"
Expand Down Expand Up @@ -54,7 +54,7 @@ func extractIDFromFileName(fileName string) (int, error) {
}

// OpenLibrary reads the audio directory. And constructs a map of file IDs to file names.
func OpenLibrary(soundsDirectory string) (*AudioFileLibrary, error) {
func OpenLibrary(soundsDirectory string, scheduleFilename string) (*AudioFileLibrary, error) {

library := &AudioFileLibrary{
soundsDirectory: soundsDirectory,
Expand Down
3 changes: 2 additions & 1 deletion downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"path/filepath"
"time"

"github.com/TheCacophonyProject/audiobait/audiofilelibrary"
"github.com/TheCacophonyProject/audiobait/playlist"
"github.com/TheCacophonyProject/go-api"
"github.com/TheCacophonyProject/modemd/connrequester"
Expand Down Expand Up @@ -268,7 +269,7 @@ func (dl *Downloader) getFileDetails(apiObj *api.CacophonyAPI, fileID int) (*api

// Try and download a single audio file from the API server.
func (dl *Downloader) downloadAudioFile(api *api.CacophonyAPI, fileID int, fileResp *api.FileResponse) error {
filename := MakeFileName(fileResp.File.Details.OriginalName, fileResp.File.Details.Name, fileID)
filename := audiofilelibrary.MakeFileName(fileResp.File.Details.OriginalName, fileResp.File.Details.Name, fileID)

return retry(
fmt.Sprintf("download and validate file %d", fileID),
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

arg "github.com/alexflint/go-arg"

"github.com/TheCacophonyProject/audiobait/audiofilelibrary"
"github.com/TheCacophonyProject/audiobait/playlist"
goconfig "github.com/TheCacophonyProject/go-config"
)
Expand Down Expand Up @@ -140,7 +141,7 @@ func createPlayer(soundCard SoundCardPlayer, audioDirectory string) (*playlist.S
func getScheduleFiles(audioDirectory string, schedule *playlist.Schedule) (map[int]string, error) {
referencedFiles := schedule.GetReferencedSounds()

audioLibrary, err := OpenLibrary(audioDirectory)
audioLibrary, err := audiofilelibrary.OpenLibrary(audioDirectory, scheduleFilename)
if err != nil {
return nil, fmt.Errorf("error creating audio library: %v", err)
}
Expand Down