lib/junkie/pyload/observer.rb in junkie-0.0.11 vs lib/junkie/pyload/observer.rb in junkie-0.0.12
- old
+ new
@@ -9,10 +9,11 @@
attr_accessor :api
DEFAULT_CONFIG = {
watchdog_refresh: 10, # interval the watchdog_timer is fired
+ dont_add_episodes_to_queue: false,
}
def initialize(channels)
@config = Config.get_config(self)
@@ -25,17 +26,17 @@
@active_episode = nil
@ready_for_new_links = true
@watchdog_enabled = false
@skipped_timer_at_first_complete_detection = false
+ @should_stat_queued_episodes = false
@channels[:episodes].subscribe do |episode|
next unless episode.status == :found
log.info("Got episode from Channel: #{episode}")
@found_episodes.push(episode)
- stat_queued_episodes
end
end
# is a method that is called once from inside the reactor and allows us
@@ -49,11 +50,18 @@
}
EM.add_periodic_timer(@config[:watchdog_refresh]) do
monitor_progress if @watchdog_enabled
- in_fiber { add_next_episode_to_pyload }
+ if @should_stat_queued_episodes
+ stat_queued_episodes
+ @should_stat_queued_episodes = false
+ end
+
+ if not @config[:dont_add_episodes_to_queue]
+ in_fiber { add_next_episode_to_pyload }
+ end
end
end
private
@@ -89,10 +97,11 @@
# sends the current number of queued episodes out on the info channel
def stat_queued_episodes
@channels[:info].push({
key: "Pending episodes",
desc: "Number of episodes queued for download",
- value: @found_episodes.size
+ value: @found_episodes.size,
+ additional: @found_episodes.map { |e| e.to_s }
})
end
# send the info about the current active download out on the