Compare commits

..

No commits in common. "master" and "v0.2-Darwin-d0a8fdfb11d6372eece119f8f2a67e2184de97cd" have entirely different histories.

11 changed files with 55 additions and 167 deletions

View File

@ -1,26 +0,0 @@
name: gobuild
on: [push]
env:
BUILD_TYPE: Release
jobs:
build:
runs-on: golang-latest
steps:
- name: Lets See What We Have
run:
uname -a
&& echo $PATH
&& echo $GOPATH
&& which go
&& go version
- name: Clone Repo
run:
git clone https://repos.gmgauthier.com/gmgauthier/gostations.git .
&& ls -la
- name: Linux Build
run:
./ci-build.sh

View File

@ -1,35 +0,0 @@
# FOR WINDOWS USERS
## MPV
MPV insists on opening a GUI (or "pseudo-gui" as they call it) window, whether you like it or not.
So, here is the best mpv.conf I could come up with, under those
circumstances:
```ini
[default]
terminal=yes
audio-display=no
video=no
force-window=no
window-minimized=yes
idle=yes
```
The window will still be created, but at least, it will be minimized to the taskbar.
You should put this file in: `%USERPROFILE%\AppData\Roaming\mpv.net\mpv.conf`
## RADIOSTATIONS.INI
Make sure your `gostations.exe` is somewhere in your searchable %PATH%. Then, you should
only need to change the player.command option:
```ini
[DEFAULT]
radio_browser.api=all.api.radio-browser.info
player.command=mpvnet.exe
player.options=--no-video
menu_items.max=9999
```
# FOR EVERYONE ELSE
Continue as you are. The sane people don't need to do anything different.

View File

@ -140,7 +140,3 @@ To exit the program entirely, choose the __*Quit__ option, or just hit `[ENTER]`
* Change the precheck, to do ini file validation once, rather than every time a config value is called for. * Change the precheck, to do ini file validation once, rather than every time a config value is called for.
* Add a way to capture favorite selections. Perhaps a preloaded search or something. * Add a way to capture favorite selections. Perhaps a preloaded search or something.
* Add color or a dashboard to the menu and player. * Add color or a dashboard to the menu and player.
.

21
bitbucket-pipelines.yml Normal file
View File

@ -0,0 +1,21 @@
image: golang:1.15
pipelines:
default:
- parallel:
- step:
name: Test and Build
script:
- go mod vendor
- go mod tidy
- go test -v
- mkdir build
- ./build.sh
- export BUILDPATH="build/$(uname)/gostations"
- curl -X POST --user "${BITBUCKET_USERNAME}:${BITBUCKET_APP_PASSWORD}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"${BUILDPATH}"
- step:
name: Lint code
image: golangci/golangci-lint:v1.31.0
script:
- golangci-lint run -v

View File

@ -3,7 +3,6 @@ package main
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io"
"log" "log"
"math/rand" "math/rand"
"net" "net"
@ -23,7 +22,7 @@ type stationRecord struct {
} }
func RandomIP(iplist []net.IP) net.IP { func RandomIP(iplist []net.IP) net.IP {
rand.NewSource(time.Now().Unix()) rand.Seed(time.Now().Unix())
randomIndex := rand.Intn(len(iplist)) randomIndex := rand.Intn(len(iplist))
return iplist[randomIndex] return iplist[randomIndex]
} }
@ -51,12 +50,7 @@ func GetStations(qstring string) ([]stationRecord, error) {
if err != nil { if err != nil {
log.Print(err.Error()) log.Print(err.Error())
} }
defer func(Body io.ReadCloser) { defer resp.Body.Close()
err := Body.Close()
if err != nil {
log.Print(err.Error())
}
}(resp.Body)
var data []stationRecord var data []stationRecord
err = json.NewDecoder(resp.Body).Decode(&data) err = json.NewDecoder(resp.Body).Decode(&data)
@ -101,3 +95,5 @@ func StationSearch(name string, country string, state string, tags string, notok
prunedStations := pruneStations(stations) // eliminate stations that are reporting down. prunedStations := pruneStations(stations) // eliminate stations that are reporting down.
return prunedStations, err return prunedStations, err
} }

View File

@ -1,21 +0,0 @@
$current_directory = "$(pwd.exe)"
Set-Variable -Name GOPATH -Value "$HOME/go:$current_directory"
# NOTE: The following commands assumes you have Git For Windows
# installed, which comes with a bunch of GNU tools packaged for windows:
Set-Variable -Name GIT_COMMIT -Value "$(git rev-list -1 HEAD)"
Set-Variable -Name CANONICAL_VERSION -Value "$(cat.exe ./VERSION)-$(uname)"
Set-Variable -Name VERSION_STRING -Value "$CANONICAL_VERSION-$GIT_COMMIT"
Set-Variable -Name buildpath -Value "build/$(uname)/gostations.exe"
go mod vendor
go mod tidy
go build -o "$buildpath" -ldflags "-X main.version=$VERSION_STRING"
& $buildpath -v
Copy-Item $buildpath $HOME/.local/bin -Force

View File

@ -19,5 +19,3 @@ go mod tidy
go build -o "$buildpath" -ldflags "-X main.version=$VERSION_STRING" go build -o "$buildpath" -ldflags "-X main.version=$VERSION_STRING"
"$buildpath" -v "$buildpath" -v
cp "$buildpath" ~/.local/bin

View File

@ -1,20 +0,0 @@
#!/usr/bin/env sh
mkdir build
GIT_COMMIT=$(git rev-list -1 HEAD)
export GIT_COMMIT
CANONICAL_VERSION=$(cat ./VERSION)-$(uname)
export CANONICAL_VERSION
VERSION_STRING="$CANONICAL_VERSION-$GIT_COMMIT"
export VERSION_STRING
buildpath="build/$(uname)/gostations"
/usr/local/go/bin/go mod vendor
/usr/local/go/bin/go mod tidy
/usr/local/go/bin/go build -o "$buildpath" -ldflags "-X main.version=$VERSION_STRING"
"$buildpath" -v

View File

@ -4,21 +4,10 @@ import (
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
"runtime"
) )
func isInstalled(name string) bool { func isInstalled(name string) bool {
var cmd *exec.Cmd cmd := exec.Command("/bin/sh", "-c", "command -v " + name)
// check for the operating system
if runtime.GOOS == "windows" {
// 'where' command is used on Windows to locate executables
cmd = exec.Command("where.exe", name)
} else {
// 'command' is used on Unix systems
cmd = exec.Command("/bin/sh", "-c", "command -v "+name)
}
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
return false return false
} }

View File

@ -4,7 +4,6 @@ import (
"errors" "errors"
"log" "log"
"os" "os"
"runtime"
"strconv" "strconv"
"github.com/alyu/configparser" "github.com/alyu/configparser"
@ -22,18 +21,9 @@ func str2int(strnum string) int {
func configStat(configFile string) string{ func configStat(configFile string) string{
xdgConfigPath := os.Getenv("XDG_CONFIG_HOME") xdgConfigPath := os.Getenv("XDG_CONFIG_HOME")
if xdgConfigPath == "" { if xdgConfigPath == "" {
if runtime.GOOS == "windows" {
xdgConfigPath = os.Getenv("USERPROFILE") + "\\.config"
} else {
xdgConfigPath = os.Getenv("HOME")+"/.config" xdgConfigPath = os.Getenv("HOME")+"/.config"
} }
}
if runtime.GOOS == "windows" {
configFile = xdgConfigPath + "\\gostations\\" + configFile
} else {
configFile = xdgConfigPath + "/gostations/" + configFile configFile = xdgConfigPath + "/gostations/" + configFile
}
if _, err := os.Stat(configFile); errors.Is(err, os.ErrNotExist) { if _, err := os.Stat(configFile); errors.Is(err, os.ErrNotExist) {
log.Printf("Your stations config file seems to be missing. A default will be generated.") log.Printf("Your stations config file seems to be missing. A default will be generated.")