Compare commits
15 Commits
v0.2-Darwi
...
master
Author | SHA1 | Date | |
---|---|---|---|
505e25189e | |||
2b1c44a619 | |||
be1a214a13 | |||
c34bdf66f2 | |||
1f27512017 | |||
3ae9f2afa2 | |||
767b1e8a7c | |||
cda405a9e2 | |||
5fa2bc67fd | |||
d92771b7ec | |||
a2c48e95b7 | |||
8c0e3a896d | |||
|
ea29c29531 | ||
|
fd70f428ae | ||
c2508127b4 |
26
.gitea/workflows/build.yml
Normal file
26
.gitea/workflows/build.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
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
|
35
README-CONFIGS.md
Normal file
35
README-CONFIGS.md
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# 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.
|
@ -140,3 +140,7 @@ 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.
|
||||||
|
|
||||||
|
|
||||||
|
.
|
||||||
|
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
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
|
|
12
browser.go
12
browser.go
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
@ -22,7 +23,7 @@ type stationRecord struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RandomIP(iplist []net.IP) net.IP {
|
func RandomIP(iplist []net.IP) net.IP {
|
||||||
rand.Seed(time.Now().Unix())
|
rand.NewSource(time.Now().Unix())
|
||||||
randomIndex := rand.Intn(len(iplist))
|
randomIndex := rand.Intn(len(iplist))
|
||||||
return iplist[randomIndex]
|
return iplist[randomIndex]
|
||||||
}
|
}
|
||||||
@ -50,7 +51,12 @@ func GetStations(qstring string) ([]stationRecord, error){
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err.Error())
|
log.Print(err.Error())
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func(Body io.ReadCloser) {
|
||||||
|
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)
|
||||||
@ -95,5 +101,3 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
21
build.ps1
Normal file
21
build.ps1
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
$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
|
||||||
|
|
2
build.sh
2
build.sh
@ -19,3 +19,5 @@ 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
|
||||||
|
20
ci-build.sh
Executable file
20
ci-build.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/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
|
||||||
|
|
13
commander.go
13
commander.go
@ -4,10 +4,21 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func isInstalled(name string) bool {
|
func isInstalled(name string) bool {
|
||||||
cmd := exec.Command("/bin/sh", "-c", "command -v " + name)
|
var cmd *exec.Cmd
|
||||||
|
|
||||||
|
// 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
|
||||||
}
|
}
|
||||||
|
10
config.go
10
config.go
@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/alyu/configparser"
|
"github.com/alyu/configparser"
|
||||||
@ -21,9 +22,18 @@ 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.")
|
||||||
|
Loading…
Reference in New Issue
Block a user