class TivoHMO::Adapters::Plex::Application

Attributes

server[R]

Public Class Methods

new(identifier) click to toggle source
Calls superclass method TivoHMO::API::Application::new
# File lib/tivohmo/adapters/plex/application.rb, line 12
def initialize(identifier)
  host, port = identifier.to_s.split(':')
  host ||= 'localhost'
  port ||= 32400
  super("Plex[#{host}:#{port}]")

  self.metadata_class = TivoHMO::Adapters::Plex::Metadata
  self.transcoder_class = TivoHMO::Adapters::Plex::Transcoder
  self.title = self.identifier

  @server = ::Plex::Server.new(host, port)
end

Public Instance Methods

children() click to toggle source
Calls superclass method
# File lib/tivohmo/adapters/plex/application.rb, line 25
def children
  synchronize do
    if super.blank?
      sections = Array(server.library.sections)
      # Sort by title descending so that creation times are
      # correct for tivo sort of newest first (Time.now for
      # created_at in Section)
      sections = sections.sort_by(&:title).reverse
      sections.each do |section|
        add_child(Section.new(section))
      end
    end
  end

  super
end