-
Notifications
You must be signed in to change notification settings - Fork 333
Add support for Podcast RSS feed imports #413
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
Conversation
The importer will generate posts that use the podcast episode timestamp, the notes, as well as the audio file. For now, use open-embed to auto-magically turn the audio file into a playable resource via the html 5 audio tag..
Default overwrite remains true but it's now possible to toggle to false and maintain the edits in the _posts folder The audio file is now wrapped in an HTML audio tag so that browser can play it natively.
DirtyF
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this new importer, please remove the example post here.
|
Done |
ashmaroli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I mentioned in the comment #412 (comment), please subclass the existing importer to avoid repeating identical method definitions:
module JekyllImport
module Importers
class RSSPodcast < RSS
# new definitions only
end
end
end|
@ashmaroli I tried extending the RSS Importer (as per your instructions) and leaving just the As I mentioned in #412 I am not a Ruby dev. My attempts to import / reference the RSS.rb file have all failed, and when I checked all the other Importers, I noticed that none of them actually extend anything other than |
|
@nicktmro Perhaps the error you're seeing is because the # frozen_string_literal: true
require_relative "rss"
module JekyllImport
module Importers
class RSSPodcast < RSS
# new definitions
end
end
endIf the above works, do make the change. |
|
That did the trick :) |
|
The sole changes in this importer as compared to the RSS Importer is actually: @@ -30,10 +30,11 @@ module JekyllImport
# Returns nothing.
def self.process(options)
source = options.fetch("source")
frontmatter = options.fetch("frontmatter", [])
body = options.fetch("body", ["description"])
+ overwrite = options.fetch("overwrite", true)
content = ""
open(source) { |s| content = s.read }
rss = ::RSS::Parser.parse(content, false)
@@ -42,10 +43,15 @@ module JekyllImport
rss.items.each do |item|
formatted_date = item.date.strftime("%Y-%m-%d")
post_name = Jekyll::Utils.slugify(item.title, :mode => "latin")
name = "#{formatted_date}-#{post_name}"
+ # Skip this file if it already exists and overwrite is turned off
+ next if !overwrite && File.file?("_posts/#{name}.html")
+
+ audio = item.enclosure.url
+
header = {
"layout" => "post",
"title" => item.title,
}
@@ -67,10 +73,11 @@ module JekyllImport
FileUtils.mkdir_p("_posts")
File.open("_posts/#{name}.html", "w") do |f|
f.puts header.to_yaml
f.puts "---\n\n"
+ f.puts "<audio controls=\"\"><source src=\"#{audio}\" type=\"audio/mpeg\">Your browser does not support the audio element.</audio>"
f.puts output
end
end
end
endThe rest are identical.. Perhaps we should just "enhance the existing RSS importer" with some |
|
That sounds good to me, but I probably lack the skill to make that happen. Happy to help test it or justify the current “options”, though. |
|
@nicktmro I've merged your rss_podcast importer into the existing rss importer with a few changes. (Notably, I removed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with @ashmaroli implementation of the ability to render audio elements.
parkr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Could you please update the documentation for the RSS reader?
parkr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
|
@jekyllbot: merge +minor |
This is very similar to the existing RSS importer. Unlike the RSS importer, this importer will also extract the
enclosuretag and wrap the url into anaudioHTML 5 tag so that compliant browsers can just play the audio file.Standard "shownotes" can be extracted from a feed by specifying the
bodylaunch argument as per the included documentation.There is also support to not overwrite previous files using the
overwritelaunch argument with afalsevalue. The default is to overwrite any existing files.