mirror of
https://github.com/mistergibson/radio.git
synced 2026-11-03 19:31:41 -08:00
fixed bugs
This commit is contained in:
parent
25bd70d0e9
commit
62a92a3740
1 changed files with 44 additions and 41 deletions
|
|
@ -158,13 +158,13 @@ def http_stream_to_file(url, dest_path, user = nil, pass = nil)
|
|||
end
|
||||
|
||||
def parse_feed(opts)
|
||||
result = nil
|
||||
file_path = opts[:file_path] || raise("parse_feed: :file_path is required")
|
||||
feed_url = opts[:feed_url] || ""
|
||||
|
||||
doc = Nokogiri::XML(File.read(file_path), nil)
|
||||
channel = doc.at_xpath("//channel")
|
||||
raise "No <channel> element found in feed" unless channel
|
||||
|
||||
if channel
|
||||
items = []
|
||||
channel.elements("item").each do |item|
|
||||
enc = item.at_xpath("./enclosure")
|
||||
|
|
@ -202,12 +202,15 @@ def parse_feed(opts)
|
|||
published_at: published_at
|
||||
}
|
||||
end
|
||||
|
||||
{
|
||||
result = {
|
||||
title: channel.at_xpath("./title")&.text || "Unknown Show",
|
||||
feed_url: feed_url,
|
||||
items: items
|
||||
}
|
||||
else
|
||||
# log - skipping - no channel data
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def register_show(show_title, feed_url, archive: false, opml_import: false)
|
||||
|
|
@ -389,7 +392,7 @@ def cmd_import_opml(path)
|
|||
next
|
||||
end
|
||||
|
||||
slug = gen_guid(url)[0..11]
|
||||
slug = generate_slug(title)
|
||||
guid = gen_guid(url)
|
||||
$db_s[:shows].insert(
|
||||
guid: guid,
|
||||
|
|
|
|||
Loading…
Reference in a new issue