Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Podcast RSS feed imports #413

Open
wants to merge 10 commits into
base: master
from
@@ -6,6 +6,7 @@ class RSS < Importer
def self.specify_options(c)
c.option "source", "--source NAME", "The RSS file or URL to import"
c.option "tag", "--tag NAME", "Add a tag to posts"
c.option "render_audio", "--render_audio", "Render <audio> element as necessary"
end

def self.validate(options)
@@ -32,6 +33,7 @@ def self.process(options)
source = options.fetch("source")
frontmatter = options.fetch("frontmatter", [])
body = options.fetch("body", ["description"])
render_audio = options.fetch("render_audio", false)

content = ""
open(source) { |s| content = s.read }
@@ -43,6 +45,7 @@ def self.process(options)
formatted_date = item.date.strftime("%Y-%m-%d")
post_name = Jekyll::Utils.slugify(item.title, :mode => "latin")
name = "#{formatted_date}-#{post_name}"
audio = render_audio && item.enclosure.url

header = {
"layout" => "post",
@@ -69,6 +72,16 @@ def self.process(options)
File.open("_posts/#{name}.html", "w") do |f|
f.puts header.to_yaml
f.puts "---\n\n"

if audio
f.puts <<~HTML
<audio controls="">
<source src="#{audio}" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
HTML
end

f.puts output
end
end
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.