class Episode
Attributes
podcast[RW]
Public Class Methods
extract_episode_data_from_auphonic(podcast, production)
click to toggle source
# File lib/gst-kitchen/episode.rb, line 38 def extract_episode_data_from_auphonic(podcast, production) data = production.meta metadata = { auphonic_uuid: data["data"]["uuid"], number: extract_episode_number(podcast.handle, data["data"]["metadata"]["title"]), length: data["data"]["length"], name: extract_name(podcast.handle, data["data"]["metadata"]["title"]), subtitle: data["data"]["metadata"]["subtitle"].strip, summary: data["data"]["metadata"]["summary"].strip, } metadata[:media] = data["data"]["output_files"].each_with_object({}) do |item, obj| obj[item["format"]] = { "size" => item["size"], "file_ext" => item["ending"] } end metadata[:chapters] = if data["data"]["chapters"] metadata[:chapters] = data["data"]["chapters"].map do |chapter| Chapter.new(chapter["start"], chapter["title"]) end.sort end metadata end
extract_episode_number(handle, title)
click to toggle source
# File lib/gst-kitchen/episode.rb, line 30 def extract_episode_number(handle, title) title.match(/#{handle}(\d{3})/) { |match| match[1].to_i } end
extract_name(handle, title)
click to toggle source
# File lib/gst-kitchen/episode.rb, line 34 def extract_name(handle, title) title.match(/#{handle}\d{3} ?- ?(.*)$/) { |match| match[1] } end
from_auphonic(podcast, production)
click to toggle source
# File lib/gst-kitchen/episode.rb, line 7 def from_auphonic(podcast, production) metadata = extract_episode_data_from_auphonic(podcast, production) episode = self.new podcast episode.number = metadata[:number] episode.name = metadata[:name] episode.subtitle = metadata[:subtitle] episode.length = metadata[:length].round episode.auphonic_uuid = metadata[:auphonic_uuid] episode.published_at = Time.now episode.summary = metadata[:summary] episode.media = metadata[:media] episode.chapters = metadata[:chapters] episode end
from_yaml(podcast, yaml_file)
click to toggle source
# File lib/gst-kitchen/episode.rb, line 24 def from_yaml(podcast, yaml_file) episode = YAML.load_file(yaml_file) episode.podcast = podcast episode end
new(podcast=nil, *args)
click to toggle source
Calls superclass method
# File lib/gst-kitchen/episode.rb, line 68 def initialize(podcast=nil, *args) @podcast = podcast super(*args) end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/gst-kitchen/episode.rb, line 73 def <=>(other) self.number <=> other.number end
duration()
click to toggle source
# File lib/gst-kitchen/episode.rb, line 89 def duration hours = length / (60 * 60) minutes = (length - hours * 60 * 60) / 60 seconds = length % 60 "#{"%02i" % hours}:#{"%02i" % minutes}:#{"%02i" % seconds}" end
handle()
click to toggle source
# File lib/gst-kitchen/episode.rb, line 81 def handle "#{podcast.handle}#{"%03i" % self.number}" end
rfc_2822_date()
click to toggle source
# File lib/gst-kitchen/episode.rb, line 85 def rfc_2822_date self.published_at.rfc2822 end
title()
click to toggle source
# File lib/gst-kitchen/episode.rb, line 77 def title "#{handle} - #{name}" end
to_s()
click to toggle source
# File lib/gst-kitchen/episode.rb, line 97 def to_s "#{title} (#{duration}) https://auphonic.com/engine/status/#{auphonic_uuid}" end
to_yaml_properties()
click to toggle source
Calls superclass method
# File lib/gst-kitchen/episode.rb, line 101 def to_yaml_properties super - [:@podcast] end