<commit_before>// Package main is to play radio with VLC(mac).
//
/*
Install:

	go install github.com/toomore/gohinetradio/gohinetradio

Usage:

	gohinetradio

*/
package main

import (
	"bufio"
	"fmt"
	"os"
	"os/exec"
	"runtime"
	"strings"

	"github.com/toomore/gohinetradio"
)

func main() {
	//PrintChannel()
	gohinetradio.GenList()

	//fmt.Println(GetRadioList(LISTPAGE))

	fmt.Println("輸入廣播頻道編號：")
	in := bufio.NewReader(os.Stdin)
	stdString, _ := in.ReadString('\n')
	radioNo := strings.Split(stdString, "\n")[0]
	if len(radioNo) > 0 {
		radioData, err := gohinetradio.GetURL(radioNo)
		if err != nil {
			fmt.Println(err)
		} else {
			fmt.Printf("%s %s\n%s\n",
				radioData.ChannelTitle, radioData.ProgramName, radioData.PlayRadio)
			if runtime.GOOS == "darwin" {
				exec.Command("/Applications/VLC.app/Contents/MacOS/VLC", radioData.PlayRadio).Start()
			}
		}
	}
}<commit_msg>Rewrite for direct open radio.<commit_after>// Package main is to play radio with VLC(mac).
//
/*
Install:

	go install github.com/toomore/gohinetradio/gohinetradio

Usage:

	gohinetradio [RadioNo]

*/
package main

import (
	"bufio"
	"flag"
	"fmt"
	"log"
	"os"
	"os/exec"
	"runtime"
	"strings"

	"github.com/toomore/gohinetradio"
)

func play(radioNo string) {
	if radioData, err := gohinetradio.GetURL(radioNo); err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("%s %s\n%s\n",
			radioData.ChannelTitle, radioData.ProgramName, radioData.PlayRadio)
		if runtime.GOOS == "darwin" {
			if err := exec.Command("/Applications/VLC.app/Contents/MacOS/VLC", radioData.PlayRadio).Start(); err != nil {
				log.Fatal(err)
			}
		}
	}
}

func main() {
	flag.Parse()
	var args = flag.Args()

	if len(args) == 1 {
		play(args[0])
	} else {
		//PrintChannel()
		gohinetradio.GenList()
		//fmt.Println(GetRadioList(LISTPAGE))
		fmt.Println("輸入廣播頻道編號：")
		in := bufio.NewReader(os.Stdin)
		stdString, _ := in.ReadString('\n')
		radioNo := strings.Split(stdString, "\n")[0]
		if len(radioNo) > 0 {
			play(radioNo)
		}
	}
}
{'fraction_non_alphanumeric': 0.17032967032967034, 'fraction_numerical': 0.002997002997002997, 'mean_word_length': 3.735224586288416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1637691', 'n_tokens_mistral': 885, 'n_tokens_neox': 825, 'n_words': 143}