Categorygithub.com/mattn/go-radiko
modulepackage
0.7.0
Repository: https://github.com/mattn/go-radiko.git
Documentation: pkg.go.dev

# README

Go Radiko

godoc build codecov go report

The unofficial radiko.jp APIs Client Library for Go

Installation

  • Go 1.7 or newer
$ go get github.com/yyoshiki41/go-radiko

Usage

■ Default

// authentication token is not necessary.
client, err := radiko.New("")
if err != nil {
	panic(err)
}
// Get programs data
stations, err := client.GetNowPrograms(context.Background())
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%v", stations)

■ Get & Set authentication token

// 1. Create a new Client.
client, err := radiko.New("")
if err != nil {
	panic(err)
}

// 2. Enables and sets the auth_token.
// After client.AuthorizeToken() has succeeded,
// the client has the enabled auth_token internally.
authToken, err := client.AuthorizeToken(context.Background(), authKeyPath)
if err != nil {
	log.Fatal(err)
}

Premium member (Enable to use the area free.)

// 1. Create a new Client.
client, err := radiko.New("")
if err != nil {
	panic(err)
}

// 2. Login as the premium member
// After client.Login() has succeeded,
// the client has the valid cookie internally.
ctx := context.Background()
login, err := client.Login(ctx, "[email protected]", "example_password")
if err != nil {
	log.Fatal(err)
}
if login.StatusCode() != 200 {
	log.Fatalf("Failed to login premium member.\nInvalid status code: %d",
		login.StatusCode())
}

// 3. Enables and sets the auth_token.
// After client.AuthorizeToken() has succeeded,
// the client has the enabled auth_token internally.
authToken, err := client.AuthorizeToken(context.Background(), authKeyPath)
if err != nil {
	log.Fatal(err)
}

■ Use your authentication token

// If the auth_token is cached, set your token in HTTP Header like below.
client, err = radiko.New("auth_token")
if err != nil {
	panic(err)
}

Examples

It is possible to try examples.

# Get programs data
$ go run ./examples/main.go
# Get & Set auth_token
$ go run ./examples/auth/main.go

Projects using go-radiko

License


Licensed under the GPLv3 license for all open source applications.

Please do not use this project for commercial use.

Author

Yoshiki Nakagawa

# Packages

No description provided by the author

# Functions

AreaID returns areaID.
DownloadPlayer downloads a swf player file.
GetChunklistFromM3U8 returns a slice of url.
GetLiveURL returns a live url for web browser.
GetStreamMultiURL returns a slice of the stream url.
GetTimeshiftURL returns a timeshift url for web browser.
New returns a new Client struct.
SetHTTPClient overrides the default HTTP client.
SetUserAgent overrides the default User-Agent header.

# Variables

ErrProgramNotFound is returned when a program not found.

# Structs

Client represents a single connection to radiko API endpoint.
LoginNG represents login failed.
LoginOK represents login is successful.
LoginStatus is a base struct that has a Status field.
Params is the list of options to pass to the request.
Prog is a struct.
Progs is a slice of Prog.
Scd is a struct.
Station is a struct.
URLItem represents a stream url.

# Interfaces

Statuser is the interface that wraps StatusCode method.

# Type aliases

Stations is a slice of Station.