miniocast

package module
v0.0.0-...-502824f Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 19 Imported by: 0

README

miniocast

Amazon S3 互換のクラウドストレージ、MinIO のバケットを Podcast サーバーにしてしまおうという寸法です。

機能

  • バケット内のフォルダを1つの Podcast サイトとし、そこに存在する音声ファイルをもとに、同一フォルダ内に自動的に feed.rss と index.html を生成あるいは更新します。同時に複数の Podcast サイトを更新することも可能です。
  • ファイルの名前をエピソードタイトルとして使います。
  • ファイル名に含まれている最初の半角スペースを区切りとして認識し、区切りの前をタイトル、後を ISubtitle として登録します。
  • 区切り以降に「第<半角数字>回」(第023回、第5回など)という文字列が存在する場合は、それを ISubtitle ではなく、エピソード番号として認識します。数字は全角ダメ、絶対。
  • タイトルにエピソード番号を自動で追加するよう設定することができます(書式:「第~回」)。

miniocastコマンドの使い方

  1. 下準備1:MinIO のバケットと Podcast ごとのフォルダを作成し、バケットには Read Only ポリシーを適用しておく。
  2. 下準備2:Podcast にしたいフォルダ直下に、配信したい mp3 もしくは m4a ファイルを置く。
  3. 下準備3:Podcast にしたいフォルダ直下に、image.jpg という名前でタイトル画像を設置する。
  4. cmd/miniocast フォルダで go get、go build すると、フォルダに miniocast コマンドができる。
  5. config.yml.example を config.yml にリネームまたはコピーし、バケットとフォルダなどの設定に応じて書き換えるあるいは追記する。
  6. ./miniocast で起動し、index.html と feed.rss を生成する。以後 Podcast のフォルダ内容を変更するたびに起動し、index.html と feed.rss を更新する。

作成したPodcastの利用方法

  1. 作成した Podcast は iTunes ストア等で検索しても表示されないので、お使いのアプリに RSS フィードの URL:
    {minioバケットのurl}/{フォルダ名}/feed.rss を直接登録してください。
  2. {minioバケットのurl}/{フォルダ名}/index.html にアクセスすると、シンプルな Web インターフェイスを表示することができます。各エピソードのタイトルをクリックすると、プレイヤーが表示されたり隠れたりします。注意:MinIO はウェブサーバではないので、index.html というファイルまで指定しないとサイトが表示されません。
  3. index.html は、config.yml で SavePlayState を true にすることにより、ブラウザを閉じたり再読み込みしても各エピソードの再生位置と再生速度を保存することができます。再生状態が保存されているエピソードはタイトルが緑色で表示されます。一時停止中にシークバーで再生位置をゼロに戻せば、保存状態をリセットできます。

Amazon S3 では

……試しておりません。

謝辞

Webインターフェイスのデザインは、Turing Complete FMRui Ueyamaさんが気前よく公開してくださっている JavaScript と CSS を使わせていただきました。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInfos

type FileInfos []minio.ObjectInfo

FileInfos は、クラウドストレージオブジェクトの情報のスライス

func (FileInfos) Len

func (fInfo FileInfos) Len() int

Len は、FileInfosの長さを返す

func (FileInfos) Less

func (fInfo FileInfos) Less(i, j int) bool

Less は、FileInfosの小さい方を判定する

func (FileInfos) Swap

func (fInfo FileInfos) Swap(i, j int)

Swap は、FileInfosの要素を入れ替える

type Index

type Index struct {
	FileLink string
	Updated  string
}

Index は、差分比較のためのキー

type Indexes

type Indexes []Index

Indexes は、Indexのスライス

func (Indexes) Len

func (idxs Indexes) Len() int

Len は、Indexesの長さを返す

func (Indexes) Less

func (idxs Indexes) Less(i, j int) bool

Less は、Indexesの小さい方を判定する

func (Indexes) Swap

func (idxs Indexes) Swap(i, j int)

Swap は、Indexesの要素を入れ替える

type PodcastPref

type PodcastPref struct {
	Title         string
	Subtitle      string
	Author        string
	Email         string
	Description   string
	Link          string
	Bucket        string
	Folder        string
	Serial        int
	Active        bool
	SavePlayState bool
}

PodcastPref は、設定ファイルから読み込んだ各Podcastの情報を格納する

func Initialize

func Initialize() (casts []*PodcastPref, ct *minio.Client, err error)

Initialize は、設定ファイルを読み込んで初期化する

func (*PodcastPref) UpdatePodcast

func (pref *PodcastPref) UpdatePodcast(ct *minio.Client) (err error)

UpdatePodcast はフォルダに入っている音声ファイルに応じてポッドキャストを更新する

func (*PodcastPref) UpdateRSS

func (pref *PodcastPref) UpdateRSS(infos FileInfos, ct *minio.Client)

UpdateRSS は、フィードを作成あるいは更新する

func (*PodcastPref) UpdateWeb

func (pref *PodcastPref) UpdateWeb(infos FileInfos, ct *minio.Client)

UpdateWeb は、index.htmlを作成あるいは更新する

func (*PodcastPref) UpdatedInfos

func (pref *PodcastPref) UpdatedInfos(ct *minio.Client) (updatedInfos FileInfos, err error)

UpdatedInfos は、更新が必要なアイテムを返す

type RSS

type RSS struct {
	XMLName xml.Name        `xml:"rss"`
	Channel podcast.Podcast `xml:"channel"`
}

RSS はfeed.rss のデータ全体。

type Web

type Web struct {
	Title         string
	Subtitle      string
	Author        string
	Description   string
	Link          string
	Items         []*WebItem
	SavePlayState bool
}

Web は、index.htmlに含めるデータを格納する

type WebItem

type WebItem struct {
	FileURL          string
	PubDateFormatted string
	Title            string
	Subtitle         string
	Description      string
}

WebItem は、index.htmlに含める各エピソードのデータを格納する

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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