Class: SabnzbdPlusApi::UnannouncedActive

Inherits:
Object
  • Object
show all
Defined in:
lib/sabnzbd_plus/api/unannounced_active.rb

Overview

Get the items in the current queue that haven't been announced yet that have a status of Downloading

Re-announces if the status changes from downloaded and then back again.

Instance Method Summary (collapse)

Constructor Details

- (UnannouncedActive) initialize(mapper = SabnzbdPlusModel::Mapper.new)

Load the mapper

Parameters:

  • mapper (SabnzbdPlusModel::Mapper) (defaults to: SabnzbdPlusModel::Mapper.new)

    defaults to new SabnzbdPlusModel::Mapper



13
14
15
16
# File 'lib/sabnzbd_plus/api/unannounced_active.rb', line 13

def initialize(mapper = SabnzbdPlusModel::Mapper.new)
  @mapper = mapper
  @announced_nzos = []
end

Instance Method Details

- (Array<Slot>) process

Get the items in the current queue that haven't been announced yet that have a status of Downloading

Re-announces if the status changes from downloaded and then back again.

Returns:

  • (Array<Slot>)

See Also:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/sabnzbd_plus/api/unannounced_active.rb', line 25

def process
  return_array = []

  @mapper.current_queue.slots.each { |slot|
    unless @announced_nzos.include? slot.nzo_id
      if slot.status == "Downloading"
        return_array = return_array << slot
        @announced_nzos << slot.nzo_id
      else
        @announced_nzos.delete slot.nzo_id
      end
    end
  }

  return return_array
end