Advertisement
Guest User

Untitled

a guest
Apr 15th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.05 KB | None | 0 0
  1. Podcast.destroy_all
  2. Episode.destroy_all
  3.  
  4. responsed = HTTParty.get('http://joeroganexp.joerogan.libsynpro.com/rss')
  5. response = Crack::XML.parse(responsed)
  6. joerogan = Podcast.create(title: response["rss"]["channel"]["title"], copyright: response["rss"]["channel"]["copyright"], description: response["rss"]["channel"]["description"], docs: response["rss"]["channel"]["link"], feed_url: response["rss"]["channel"]["itunes:new_feed_url"], image_url: response["rss"]["channel"]["image"]["url"], language: response["rss"]["channel"]["language"], author: response["rss"]["channel"]["itunes:author"], explicit: response["rss"]["channel"]["itunes:explicit"])
  7. response["rss"]["channel"]["item"].each do |item|
  8.   Episode.create(title: item["title"], content: item["description"], enclosure_length: item["enclosure"]["length"].to_i, enclosure_type: item["enclosure"]["type"], enclosure_url: item["enclosure"]["url"], pubdate: item["pubDate"].to_datetime, guid: item["guid"], duration: item["itunes:duration"].to_i, explicit: item["itunes:explicit"], podcast_id: joerogan.id)
  9. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement