nhkpod

package module
v0.0.0-...-a9840d2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2022 License: MIT Imports: 22 Imported by: 0

README

nhkpod

A podcast server providing Radiru programs written in golang

All data processed by this program should be handled in accordance with the terms of use for Radiru https://www.nhk.or.jp/radio/info/kiyaku.html

Usage

  1. Visit Radiru ProgramList, copy site_id for the program you want to follow.

  2. Edit conf.yml and declare podcast. Specify the copied site_id as the id of the podcast. (Optional) If you specify corner_id, the corner will be served as an independent podcast. Otherwise, all the corners in the site_id are served as a single podcast.

podcasts:
  - id: 1633
  - id: F295
    corner_id: 29

This will make podcasts http://<host>:8080/audio/1633/feed.rss and http://<host>:8080/audio/f295_29/feed.rss

  1. Run cmd/nhkpod/main.go by make build && ./nhkpod or your preferred method to run the go program. Otherwise, you can docker-compose them. That way you just make .env then specify the podcast host.
NHKPOD_HOST=<your docker host>

Then docker-compose up. The directory for audio files and feed.rss will be mounted to ./audio as a docker volume.

  1. Initially, it will download all the available audio files associated with the site_id and corner_id you've specified.

  2. Register url http://<host>:8080/audio/<site_id>/feed.rss or http://<host>:8080/audio/<site_id>_<corner_id>/feed.rss on your podcast client.

Environment variables

Key Description Default
NHKPOD_SCHEDULE schedule for audio file download & podcast feed update (cron style) 35 * * * *
NHKPOD_LOG_FILE log file log.log
NHKPOD_AUDIO_DIR audio & podcast feed directory audio
NHKPOD_CONF_PATH configuration file path conf.yml
NHKPOD_PORT port for podcast server 8080
NHKPOD_HOST host for podcast server n/a

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Encoding = ".aac"
View Source
var Pubdate = time.Date(2011, 9, 1, 0, 0, 0, 0, time.UTC)
View Source
var TFormat = "200601021504"
View Source
var TFormatZone = TFormat + "-0700"

Functions

func ConvertFileTime

func ConvertFileTime(info04 string) (*time.Time, error)

func DownloadEpisode

func DownloadEpisode(s PodcastSettings, ep Episode) error

func DownloadEpisodes

func DownloadEpisodes(s PodcastSettings, p Program) error

func DownloadProgramEpisodes

func DownloadProgramEpisodes(s PodcastSettings, progs []Program) error

func FileNameToIDAndStarted

func FileNameToIDAndStarted(filePath string) (*string, *time.Time, error)

func GeneratePodcast

func GeneratePodcast(s PodcastSettings, program Program) (*podcast.Podcast, error)

func GetAudioFiles

func GetAudioFiles(audioDir string, program Program) ([]fs.FileInfo, error)

func GetAvailablePrograms

func GetAvailablePrograms() (*[]Program, error)

func GetM3U8URL

func GetM3U8URL(url string) (*string, error)

func GetenvOrDefault

func GetenvOrDefault(exists, key, defaultVal string) string

func HandleError

func HandleError(w http.ResponseWriter, err error)

func HandlePrograms

func HandlePrograms(w http.ResponseWriter, r *http.Request)

func NewEpisodesFrom

func NewEpisodesFrom(programURL string) (*[]Episode, error)

func PodcastTitle

func PodcastTitle(s PodcastSettings, program Program) string

func PreparePodcastRootDir

func PreparePodcastRootDir(e Env, programId, cornerId string) (string, error)

func SetupDir

func SetupDir(dirs []string) error

func SetupLogOutput

func SetupLogOutput(e Env) error

func StartScheduler

func StartScheduler(e Env) error

func StartServer

func StartServer(e Env) error

func UpdatePodcast

func UpdatePodcast(s PodcastSettings, programs *[]Program) error

func UpdatePodcasts

func UpdatePodcasts(e Env) error

func WritePodcastFile

func WritePodcastFile(s PodcastSettings, program Program) error

Types

type Conf

type Conf struct {
	Podcasts []struct {
		ID       string `yaml:"id"`
		CornerID string `yaml:"corner_id"`
	} `yaml:"podcasts"`
}

func GetConf

func GetConf(confPath string) (*Conf, error)

type Env

type Env struct {
	Schedule  string //cron format
	LogFile   string
	AssetsDir string
	AudioDir  string
	WorkDir   string
	ConfPath  string
	Port      string
	Host      string
	Https     bool
	BaseURL   string
}

func (*Env) Init

func (e *Env) Init() error

func (*Env) InitBaseURl

func (e *Env) InitBaseURl()

func (*Env) InitHost

func (e *Env) InitHost() error

func (*Env) ReadEnv

func (e *Env) ReadEnv()

type Episode

type Episode struct {
	ID          string
	M3u8Url     string
	Started     time.Time
	Program     string
	Title       string
	Description string
	FilePath    string
	Size        int64
}

func NewFromFile

func NewFromFile(filePath string, size int64) (*Episode, error)

func (*Episode) AudioFile

func (e *Episode) AudioFile(destDir string) string

func (*Episode) ConvertToAudioFile

func (e *Episode) ConvertToAudioFile(workDir, destDir string) (string, error)

func (*Episode) DeleteAudioFile

func (e *Episode) DeleteAudioFile(destDir string) error

func (*Episode) DeleteTSFile

func (e *Episode) DeleteTSFile(workDir string) error

func (*Episode) Download

func (e *Episode) Download(workDir, destDir string) error

func (*Episode) DownloadTS

func (e *Episode) DownloadTS(workDir string) error

func (*Episode) Exists

func (e *Episode) Exists(destDir string) bool

func (*Episode) GetTSRawFileDir

func (e *Episode) GetTSRawFileDir(workDir string) string

func (*Episode) GetTSRawFilePath

func (e *Episode) GetTSRawFilePath(workDir string) string

func (*Episode) RecoverTSPanic

func (e *Episode) RecoverTSPanic() error

func (*Episode) WriteTag

func (e *Episode) WriteTag(destDir string) error

type PodcastSettings

type PodcastSettings struct {
	ID       string
	CornerID string
	RootDir  string
	WorkDir  string
	BaseURL  string
}

type Program

type Program struct {
	ID       string
	CornerID string
	ImageUrl string
	URL      string
	Title    string
	Corner   string
}

func GetProgram

func GetProgram(id, cornerID string, programs *[]Program) ([]Program, error)

type ProgramDetailJson

type ProgramDetailJson struct {
	Main struct {
		SiteID       string `json:"site_id"`
		ProgramTitle string `json:"program_name"`
		CornerID     string `json:"corner_id"`
		CornerTitle  string `json:"corner_name"`
		DetailList   []struct {
			FileList []struct {
				FileID       string `json:"file_id"`
				FileTitle    string `json:"file_title"`
				FileTitleSub string `json:"file_title_sub"`
				FileName     string `json:"file_name"`
				AAVInfo1     string `json:"aa_vinfo1"`
				AAVInfo4     string `json:"aa_vinfo4"`
			} `json:"file_list"`
		} `json:"detail_list"`
	} `json:"main"`
}

type TimeTableJson

type TimeTableJson struct {
	DataList []struct {
		SiteID      string `json:"site_id"`
		ProgramName string `json:"program_name"`
		DetailJson  string `json:"detail_json"`
		CornerID    string `json:"corner_id"`
		CornerName  string `json:"corner_name"`
		ThumbnailP  string `json:"thumbnail_p"`
	} `json:"data_list"`
}

func GetTimeTable

func GetTimeTable() (*TimeTableJson, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL