Compare commits
No commits in common. "master" and "v0.2-Darwin-d0a8fdfb11d6372eece119f8f2a67e2184de97cd" have entirely different histories.
master
...
v0.2-Darwi
@ -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
|
|
@ -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.
|
|
@ -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
21
bitbucket-pipelines.yml
Normal 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
|
40
browser.go
40
browser.go
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
@ -13,17 +12,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type stationRecord struct {
|
type stationRecord struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Codec string `json:"codec"`
|
Codec string `json:"codec"`
|
||||||
Bitrate json.Number `json:"bitrate"`
|
Bitrate json.Number `json:"bitrate"`
|
||||||
Countrycode string `json:"countrycode"`
|
Countrycode string `json:"countrycode"`
|
||||||
Tags string `json:"tags"`
|
Tags string `json:"tags"`
|
||||||
Url string `json:"url"`
|
Url string `json:"url"`
|
||||||
Lastcheck int `json:"lastcheckok"`
|
Lastcheck int `json:"lastcheckok"`
|
||||||
}
|
}
|
||||||
|
|
||||||
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]
|
||||||
}
|
}
|
||||||
@ -45,18 +44,13 @@ func GetApiHost() string {
|
|||||||
return apiHost
|
return apiHost
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStations(qstring string) ([]stationRecord, error) {
|
func GetStations(qstring string) ([]stationRecord, error){
|
||||||
urlstr := fmt.Sprintf("https://%s/json/stations/search?%s&limit=%d", GetApiHost(), qstring, maxitems())
|
urlstr := fmt.Sprintf("https://%s/json/stations/search?%s&limit=%d",GetApiHost(),qstring,maxitems())
|
||||||
resp, err := http.Get(urlstr)
|
resp, err := http.Get(urlstr)
|
||||||
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)
|
||||||
@ -78,26 +72,28 @@ func pruneStations(stations []stationRecord) []stationRecord {
|
|||||||
|
|
||||||
func StationSearch(name string, country string, state string, tags string, notok bool) ([]stationRecord, error) {
|
func StationSearch(name string, country string, state string, tags string, notok bool) ([]stationRecord, error) {
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
if name != "" {
|
if name != ""{
|
||||||
params.Add("name", name)
|
params.Add("name", name)
|
||||||
}
|
}
|
||||||
if country != "" {
|
if country != "" {
|
||||||
params.Add("country", country)
|
params.Add("country", country)
|
||||||
}
|
}
|
||||||
if state != "" {
|
if state != ""{
|
||||||
params.Add("state", state)
|
params.Add("state", state)
|
||||||
}
|
}
|
||||||
if tags != "" {
|
if tags != ""{
|
||||||
params.Add("tag", tags)
|
params.Add("tag",tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
stations, err := GetStations(params.Encode())
|
stations, err := GetStations(params.Encode())
|
||||||
if err != nil {
|
if err != nil{
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if notok {
|
if notok{
|
||||||
return stations, err
|
return stations, err
|
||||||
} // otherwise prune the list
|
} // otherwise prune the list
|
||||||
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
21
build.ps1
@ -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
|
|
||||||
|
|
4
build.sh
4
build.sh
@ -18,6 +18,4 @@ 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
20
ci-build.sh
@ -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
|
|
||||||
|
|
13
commander.go
13
commander.go
@ -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
|
||||||
}
|
}
|
||||||
|
18
config.go
18
config.go
@ -4,13 +4,12 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/alyu/configparser"
|
"github.com/alyu/configparser"
|
||||||
)
|
)
|
||||||
|
|
||||||
// str2int
|
//str2int
|
||||||
func str2int(strnum string) int {
|
func str2int(strnum string) int {
|
||||||
i, err := strconv.Atoi(strnum)
|
i, err := strconv.Atoi(strnum)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -19,21 +18,12 @@ func str2int(strnum string) int {
|
|||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
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("HOME")+"/.config"
|
||||||
xdgConfigPath = os.Getenv("USERPROFILE") + "\\.config"
|
|
||||||
} else {
|
|
||||||
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.")
|
||||||
|
20
stations.go
20
stations.go
@ -8,27 +8,27 @@ import (
|
|||||||
|
|
||||||
var version string
|
var version string
|
||||||
|
|
||||||
func showVersion() {
|
func showVersion(){
|
||||||
fmt.Println(version)
|
fmt.Println(version)
|
||||||
}
|
}
|
||||||
|
|
||||||
func precheck() {
|
func precheck(){
|
||||||
if !isInstalled(player()) {
|
if !isInstalled(player()){
|
||||||
fmt.Printf("%s is either not installed, or not on your $PATH. Cannot continue.\n", player())
|
fmt.Printf("%s is either not installed, or not on your $PATH. Cannot continue.\n", player())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main(){
|
||||||
argCount := len(os.Args[1:])
|
argCount := len(os.Args[1:])
|
||||||
|
|
||||||
var (
|
var (
|
||||||
name string
|
name string
|
||||||
country string
|
country string
|
||||||
state string
|
state string
|
||||||
tags string
|
tags string
|
||||||
notok bool
|
notok bool
|
||||||
version bool
|
version bool
|
||||||
)
|
)
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
fmt.Printf("Usage: \n")
|
fmt.Printf("Usage: \n")
|
||||||
@ -42,7 +42,7 @@ func main() {
|
|||||||
flag.StringVar(&country, "c", "", "Home country.")
|
flag.StringVar(&country, "c", "", "Home country.")
|
||||||
flag.StringVar(&state, "s", "", "Home state (if in the United States).")
|
flag.StringVar(&state, "s", "", "Home state (if in the United States).")
|
||||||
flag.StringVar(&tags, "t", "", "Tag (or comma-separated tag list)")
|
flag.StringVar(&tags, "t", "", "Tag (or comma-separated tag list)")
|
||||||
flag.BoolVar(¬ok, "x", false, "If toggled, will show stations that are down")
|
flag.BoolVar(¬ok, "x", false,"If toggled, will show stations that are down")
|
||||||
flag.BoolVar(&version, "v", false, "Show version.")
|
flag.BoolVar(&version, "v", false, "Show version.")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@ -66,4 +66,4 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user