Skip to content

Commit eb00c31

Browse files
committed
add #387 PodcastsConnect のRSSタグ追加
追加のタグは必須ではないのですが、Apple Podcastsでおすすめとして紹介されやすくなるようなので追加しました。 cf. https://help.apple.com/itc/podcasts_connect/#/itcb54353390
1 parent 620ccac commit eb00c31

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

app/controllers/podcasts_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ def show
1616
end
1717

1818
def feed
19-
@episodes = Podcast.all.sort_by{|episode| episode.filename.rjust(3, '0')}
19+
@episodes = Podcast.all.sort_by{|episode| episode.published_at}
2020
@domainname = request.base_url
21+
@author = "一般社団法人 CoderDojo Japan"
2122
respond_to do |format|
2223
format.rss { render :layout => false }
2324
end

app/models/podcast.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def description
3636
@desc ||= exists? ? self.content.lines.reject{|l| l =~ /^(\n|<)/ }.second.delete('<br>').strip : ''
3737
end
3838

39+
def published_at
40+
@pubDate ||= exists? ? Time.parse(self.content.lines.second.gsub(/<.+?>/, '').delete('収録日: ')) : ''
41+
end
42+
3943
def content
4044
@content ||= exists? ? File.read(path) : ''
4145
end

app/views/podcasts/feed.rss.builder

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
xml.instruct! :xml, :version => "1.0"
2-
xml.rss :version => "2.0" do
2+
xml.rss :version => "2.0", "xmlns:itunes" => "http://www.itunes.com/dtds/Podcast-1.0.dtd" do
33
xml.channel do
44
xml.title full_title ""
55
xml.description full_description ""
66
xml.link root_url
7+
xml.author @author
8+
xml.copyright "Copyright © 2012-2018 一般社団法人 CoderDojo Japan"
9+
xml.language "ja"
10+
xml.itunes :category, :text => "Technology" do
11+
xml.itunes :category, :text => "Software How-To"
12+
xml.itunes :category, :text => "Podcasting"
13+
end
14+
xml.itunes :type, "serial"
15+
xml.itunes :explicit, "clean"
716

817
@episodes.each do |episode|
918
xml.item do
1019
xml.title episode.title
20+
xml.author @author
1121
xml.description episode.description
12-
xml.link @domainname + episode.url + ".mp3"
22+
xml.link @domainname + episode.url
1323
xml.guid({:isPermaLink => "false"}, @domainname + episode.url)
24+
xml.itunes :explicit, "clean"
25+
xml.pubDate episode.published_at.rfc2822
26+
xml.enclosure({:url => @domainname + episode.url + ".mp3", :type => "audio/mpeg"})
1427
end
1528
end
1629
end
17-
end
30+
end

0 commit comments

Comments
 (0)