Giter VIP home page Giter VIP logo

go-radiko's Introduction

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

go-radiko's People

Contributors

cabbagekobe avatar juntaki avatar kangaechu avatar mattn avatar yyoshiki41 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

go-radiko's Issues

User-Agentを指定できるようにするべき(?)

[議論]
タイトル通りで、UAを指定できるようにするべきではないでしょうか?

例えば、yyoshiki41/radigoでは"radigo"と指定することでradiko運営への認知が行えます

現在radikoがAPIを公式に公開しているわけではないので、利用するにあたってUAをきちんと設定することには意義があると思いますがいかかでしょうか?

よろしくお願いします

Remove outsideJP flag

	// FIXME:
	// affects the outside packages
	flag.BoolVar(&outsideJP, "outjp", false, "Skip tests if outside Japan.")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.