Documentation ¶
Index ¶
- Constants
- Variables
- func Download(ctx context.Context, wg *sync.WaitGroup, prog *Prog) (err error)
- type Area
- type Asset
- func (a *Asset) AddExtraStations(es []string)
- func (a *Asset) GenerateGPSForAreaID(areaID string) string
- func (a *Asset) GetAreaIDByStationID(stationID string) string
- func (a *Asset) GetPartialKey(offset, length int64) (string, error)
- func (a *Asset) GetStationIDsByAreaID(areaID string) []string
- func (a *Asset) LoadAvailableStations(areaID string)
- func (a *Asset) NewDevice(areaID string) (*Device, error)
- func (a *Asset) RemoveIgnoreStations(is []string)
- func (a *Asset) UnmarshalJSON(b []byte) error
- type ContextKey
- type Coordinate
- type Coordinates
- type Device
- type Devices
- type Prog
- type ProgGenre
- type Progs
- type Regions
- type Rule
- func (r *Rule) HasDoW() bool
- func (r *Rule) HasKeyword() bool
- func (r *Rule) HasPfm() bool
- func (r *Rule) HasStationID() bool
- func (r *Rule) HasTitle() bool
- func (r *Rule) HasWindow() bool
- func (r *Rule) Match(stationID string, p *Prog) bool
- func (r *Rule) MatchDoW(ft string) bool
- func (r *Rule) MatchKeyword(p *Prog) bool
- func (r *Rule) MatchPfm(pfm string) bool
- func (r *Rule) MatchStationID(stationID string) bool
- func (r *Rule) MatchTitle(title string) bool
- func (r *Rule) MatchWindow(ft string) bool
- func (r *Rule) SetName(name string)
- type Rules
- type SDK
- type Schedules
- type Station
- type Stations
- type Versions
- type XMLProg
- type XMLProgItem
- type XMLProgs
- type XMLRegion
- type XMLRegionStation
- type XMLRegionStations
- type XMLWeekly
- type XMLWeeklyStation
Constants ¶
const ( // BufferMinutes for fetching the playlist.m3u8 chunks BufferMinutes = 5 // DatetimeLayout for time strings from radiko DatetimeLayout = "20060102150405" // DefaultArea for radiko are DefaultArea = "JP13" // RetryDelaySecond for initial delay DefaultInitialDelaySeconds = 60 // DefaultInterval to fetch the programs DefaultInterval = "168h" // DefaultMinimumOutputSize DefaultMinimumOutputSize = 1 // Environment Variable for RADICRON_HOME EnvRadicronHome = "RADICRON_HOME" // Language for ID3v2 tags ID3v2LangJPN = "jpn" // Kilobytes for the metric bytes Kilobytes = 1024 // DefaultMaxConcurrents MaxConcurrency = 64 // MaxRetryAttempts for BackOffDelay MaxRetryAttempts = 8 // OneDay is 24 hours OneDay = 24 // OutputDatetimeLayout for downloaded files OutputDatetimeLayout = "200601021504" // TZTokyo for time location TZTokyo = "Asia/Tokyo" // UserIDLength for user-id UserIDLength = 16 // API endpoints // region full APIRegionFull = "https://radiko.jp/v3/station/region/full.xml" APIPlaylistM3U8 = "https://radiko.jp/v2/api/ts/playlist.m3u8" APIWeeklyProgram = "https://radiko.jp/v3/program/station/weekly/%s.xml" // HTTP Headers // auth1 req UserAgentHeader = "User-Agent" RadikoAreaIDHeader = "X-Radiko-AreaId" RadikoAppHeader = "X-Radiko-App" RadikoAppVersionHeader = "X-Radiko-App-Version" RadikoDeviceHeader = "X-Radiko-Device" RadikoUserHeader = "X-Radiko-User" // auth1 res RadikoAuthTokenHeader = "X-Radiko-AuthToken" //nolint:gosec RadikoKeyLentghHeader = "X-Radiko-KeyLength" RadikoKeyOffsetHeader = "X-Radiko-KeyOffset" // auth2 req RadikoConnectionHeader = "X-Radiko-Connection" RadikoLocationHeader = "X-Radiko-Location" RadikoPartialKeyHeader = "X-Radiko-Partialkey" )
Variables ¶
var ( // Base64FullKey holds the /assets/flutter_assets/assets/key/android.jpg in the v8 APK //go:embed assets/base64-full.key Base64FullKey embed.FS // CoordinatesJSON is a JSON contains the base GPS locations //go:embed assets/coordinates.json CoordinatesJSON embed.FS // RegionsJSON is a JSON contains the region mapping //go:embed assets/regions.json RegionsJSON embed.FS // VersionsJSON is a JSON contains the valid SDK versions //go:embed assets/versions.json VersionsJSON embed.FS )
var ( CurrentTime time.Time Location *time.Location )
Functions ¶
Types ¶
type Asset ¶
type Asset struct { AvailableStations []string AreaDevices Devices Base64Key string Coordinates Coordinates DefaultClient *radiko.Client // MinimumOutputSize in bytes for the downloaded audio MinimumOutputSize int64 NextFetchTime *time.Time OutputFormat string Regions Regions Rules Rules Schedules Schedules Stations Stations Versions Versions }
func (*Asset) AddExtraStations ¶
AddExtraStations appends stations to AvailableStations
func (*Asset) GenerateGPSForAreaID ¶
GenerateGPS returns the RadikoLocationHeader GPS string e.g., "35.689492,139.691701,gps"
func (*Asset) GetAreaIDByStationID ¶
GetAreaIDByStationID returns the first AreaID for the station
func (*Asset) GetPartialKey ¶
GetPartialKey returns the partial key for auth2 API
func (*Asset) GetStationIDsByAreaID ¶
GetStationIDsByAreaID returns a slice of StationIDs
func (*Asset) LoadAvailableStations ¶
LoadAvailableStations loads up the avaialable stations
func (*Asset) RemoveIgnoreStations ¶ added in v0.2.11
RemoveIgnoreStations remove stations from AvailableStations
func (*Asset) UnmarshalJSON ¶
UnmarshalJSON loads up Coordinates with Regions
type ContextKey ¶
type ContextKey string
type Coordinate ¶
type Coordinates ¶
type Coordinates map[string]*Coordinate
type Device ¶
type Prog ¶
type Prog struct { ID string StationID string Ft string To string Title string Desc string Info string Pfm string Tags []string Genre ProgGenre M3U8 string }
Prog contains the solicited program metadata
type Progs ¶
type Progs []*Prog
Progs is a slice of Prog.
func FetchWeeklyPrograms ¶
FetchWeeklyPrograms returns the weekly programs.
func (*Progs) UnmarshalXML ¶
type Rule ¶
type Rule struct { Name string `mapstructure:"name"` // required Title string `mapstructure:"title"` // required if pfm and keyword are unset DoW []string `mapstructure:"dow"` // optional Keyword string `mapstructure:"keyword"` // optional Pfm string `mapstructure:"pfm"` // optional StationID string `mapstructure:"station-id"` // optional Window string `mapstructure:"window"` // optional }
func (*Rule) HasKeyword ¶
func (*Rule) HasStationID ¶
func (*Rule) Match ¶
Match returns true if the rule matches the program 1. check the Window filter 2. check the DoW filter 3. check the StationID 4. match the criteria
func (*Rule) MatchKeyword ¶ added in v0.2.9
func (*Rule) MatchStationID ¶ added in v0.2.9
func (*Rule) MatchTitle ¶ added in v0.2.9
func (*Rule) MatchWindow ¶ added in v0.2.10
type Rules ¶
type Rules []*Rule
func (Rules) HasRuleForStationID ¶
func (Rules) HasRuleWithoutStationID ¶
type XMLProg ¶
type XMLProg struct { ID string `xml:"id,attr"` Ft string `xml:"ft,attr"` To string `xml:"to,attr"` Title string `xml:"title"` Desc string `xml:"desc"` Info string `xml:"info"` Pfm string `xml:"pfm"` Tag struct { Item []XMLProgItem `xml:"item"` } `xml:"tag"` Genre struct { Personality XMLProgItem `xml:"personality"` Program XMLProgItem `xml:"program"` } `xml:"genre"` }
XMLProg contains the raw program metadata
type XMLProgItem ¶
type XMLRegion ¶
type XMLRegion struct {
Region []XMLRegionStations `xml:"stations"`
}
func FetchXMLRegion ¶
type XMLRegionStation ¶
type XMLRegionStations ¶
type XMLRegionStations struct { Stations []XMLRegionStation `xml:"station"` RegionID string `xml:"region_id,attr"` RegionName string `xml:"region_name,attr"` }
type XMLWeekly ¶
type XMLWeekly struct { XMLName xml.Name `xml:"radiko"` XMLStations struct { XMLName xml.Name `xml:"stations"` Station []XMLWeeklyStation `xml:"station"` } `xml:"stations"` }