LoginSignup
1
0

More than 5 years have passed since last update.

PelicanでPodcast配信をしてみた作業メモ

Last updated at Posted at 2017-03-17

概要

  • PelicanでPodcastの配信ページを作成してみました。
  • feedの作成には pelican-podcast-feed プラグインを使わせてもらってます。
  • Pelicanの詳細な使い方は別の記事を参考にしてください……。

注) ここは単なるメモ書きです。有用な情報はないかもしれないですょ。

準備

友人とPodcastでの配信を目指して駄弁った内容を配信するために、Pythonで書かれた静的サイトジェネレータPelicanでやってみようということで挑戦しました。
まずは、Pelicanのインストールですが、pyvenvをつかって、以下のようにインストールしました。

% mkdir asterisk
% cd asterisk
% pyvenv pelican
% source pelican/bin/activate
% pip3 install pelican

コンテンツの記述には、流行にしたがってMarkdownをつかいました。ということでMarkdownもインストールします。

% pip3 install Markdown

ひとまず、ここまでをgitにでもコミットしておきます。.gitignoreを以下のようにしてinitial commitです。

.gitignore
/pelican
/output

*.pid
__pycache__

Pelicanの初期設定をする

次に、Pelicanの初期設定をします。pelican-quickstartを実行します。実行すると色々と質問が出てくるので、適当に回答します。

% pelican-quickstart
Welcome to pelican-quickstart v3.7.1.

This script will help you create a new Pelican-based website.

Please answer the following questions so this script can generate the files
needed by Pelican.


> Where do you want to create your new web site? [.]
> What will be the title of this web site? Podcast test
> Who will be the author of this web site? A, B, rarewin
> What will be the default language of this web site? [ja]
> Do you want to specify a URL prefix? e.g., http://example.com   (Y/n)
> What is your URL prefix? (see above example; no trailing slash) http://hogehoge
> Do you want to enable article pagination? (Y/n)
> How many articles per page do you want? [10]
> What is your time zone? [Europe/Paris] Asia/Tokyo
> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n)
> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n)
> Do you want to upload your website using FTP? (y/N)
> Do you want to upload your website using SSH? (y/N) y
> What is the hostname of your SSH server? [localhost] hogehoge
> What is the port of your SSH server? [22]
> What is your username on that server? [root] rarewin
> Where do you want to put your web site on that server? [/var/www]
> Do you want to upload your website using Dropbox? (y/N)
> Do you want to upload your website using S3? (y/N)
> Do you want to upload your website using Rackspace Cloud Files? (y/N)
> Do you want to upload your website using GitHub Pages? (y/N)
Done. Your new project is available at /tmp/asterisk

この状態で

% ./develop_server.sh start 18889 

とすると、 http://localhost:18889/ からブラウザで内容を確認できます。ここまでも一旦gitにコミットしておくとよいかもしれない。

pelican-podcast-feed をつかってみる

ということで、本題の pelican-podcast-feed です。適当にぐぐったら出てきたので、こちら以外にもプラグインはあるかもしれません。
が、二年前にコミットしたREADMEが

Alert: Still in early development stage.

を含む3行という漢らしさに惹かれて(?)、これをつかってみたいと思います。

とにもかくにも、インストールしてあげましょう。今回は、pluginsというフォルダを作った上で、submoduleとして取得しました。
使用したコマンドラインそのままなので、GitHubのアカウントがない人はhttpsに変更しましょう(ここをコピペする人はいないような気もしてますが)。

% mkdir plugins
% cd plugins
% git submodule add git@github.com:magnunleno/pelican-podcast-feed.git

さて、今度はプラグインを使用するためにpelicanconf.pyを編集します。
ここでは、追加・変更した行だけ載せておきますね。

pelicanconf.part.py
# Podcast
PODCAST_FEED_PATH = 'feeds/podcasts.atom.xml'
PODCAST_FEED_AUTHOR = AUTHOR
PODCAST_FEED_COPYRIGHT = AUTHOR

# Blogroll
LINKS = (('Podcast', './feeds/podcasts.atom.xml'),)

# Plugin
PLUGIN_PATHS = ['plugins',]
PLUGINS = ['pelican-podcast-feed',]

本当はRSSやAtomと同じくSotial widgetとして追加したかったんですが、まだうまく動かせてないのでLINKSにつっこんでます。
動かせたら、また追記します。たぶん。

とはいえ、これだけではまだ何も生成されません。実施に配信するエピソードについてはcontentにMarkdownやらを置いていきます。
今回は、以下のようなファイルを用意してみました。

content/test.md
Title: episode title
Date: 2017-03-16
Podcast: http://hogehoge/mp3/20170316.mp3

test podcast

<audio controls><source src="http://hoehoge/mp3/20170316.mp3" type="audio/mpeg"></audio>

## Speakers

* Aさん
* Bさん
* rarewin

一番のポイントは、Podcastというメタデータです。まだプラグインのソースコードを読み切れていないのですが、コンテントがpublishedになっていること(これは設定をデフォルトから換えていなければdraftと宣言しなければOK)と、Podcastというメタデータが入っているとプラグインが動くようです。
上記のファイルからは、以下のようなatomが生成されます。

feed.atom.xml
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"><channel><title>Podcast test</title><link>/</link><description></description><lastBuildDate>Fri, 17 Mar 2017 22:49:53 -0000</lastBuildDate><copyright>A, B, rarewin</copyright><itunes:author>A, B, rarewin</itunes:author><item><enclosure type="audio/mpeg" url="http://hogehoge/mp3/20170316.mp3"></enclosure><description><![CDATA[<p>test podcast</p>
<p><audio controls><source src="http://hoehoge/mp3/20170316.mp3" type="audio/mpeg"></audio></p>
<h2>Speakers</h2>
<ul>
<li>Aさん</li>
<li>Bさん</li>
<li>rarewin</li>
</ul>]]></description><pubDate>Thu, 16 Mar 2017 00:00:00 +0900</pubDate><link>/episode-title.html</link><itunes:summary>test podcast Speakers Aさん Bさん rarewin</itunes:summary><itunes:author>A, B, rarewin</itunes:author><title>episode title</title><guid>/episode-title.html</guid></item></channel></rss>

上記はhogeな値を入れてますが、実際には真面目な値を入れており、そちらで生成されたatomをfeedとしてpodcastのクライアントに読ませると、ちゃんとエピソードとして認識されました!なお、動作確認はAndroidのPodcastAddictを使用しております。

追記: 2017-04-03

iTunes Storeに登録の申請をするには、pelican.confに以下の内容を追記する必要がありました。

pelican.conf.py
PODCAST_FEED_LANGUAGE = 'ja'          # 日本語
PODCAST_FEED_CATEGORY = 'Technology'  # テクノロジ!! きっと…….
PODCAST_FEED_EXPLICIT = 'No'          # ぁゃιくないよ……?
PODCAST_FEED_SUMMARY = "ほげほげ"
PODCAST_FEED_IMAGE = "http://hogehoge/hoge.png"

審査通ると良いなぁ……。
(とおりました)

追記: 2017-04-13

ファイルサイズと再生時間については、各ページに

episode.md
Duration: 59:09
Length: 56805629

のように入れておくとフィードに反映されるようです。

今後の課題

  • Social widgetとして表示させたい。
  • 他にもいくつか設定があるようなので確認したい。
  • 継続してPodcast配信をする。

参考にさせていただいたもの

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0