lib/junkie/reactor.rb in junkie-0.0.2 vs lib/junkie/reactor.rb in junkie-0.0.3
- old
+ new
@@ -24,12 +24,10 @@
def initialize
@config = Config.get_config(self)
- @sindex = Sindex::SeriesIndex.new(index_file: @config[:series_index_file])
- @sjunkieex = Sjunkieex::Interface.new(@sindex, @config)
@pyload_observer = Junkie::Pyload::Observer.new()
@episode_queue = EM::Queue.new
@found_episodes = Hash.new
build_procs # has to be called here
@@ -39,12 +37,18 @@
# Proc that looks for new episodes on Seriesjunkies.org and adds them to
# the episode_queue if they are new
@look_for_new_episodes = Proc.new {
in_fiber {
- log.info "Looking for new episodes"
- @sjunkieex.get_links_for_downloads.each do |episode|
+ log.debug "Reload Sindex from file"
+ # TODO refactor this so that we can detect if we have to reload the
+ # index (by MD5sum)
+ sindex = Sindex::SeriesIndex.new(index_file: @config[:series_index_file])
+ sjunkieex = Sjunkieex::Interface.new(sindex, @config)
+
+ log.info "Looking for new episodes"
+ sjunkieex.get_links_for_downloads.each do |episode|
identifier = "%s@%s" % [episode.id, episode.series]
if not @found_episodes.has_key? identifier
log.info("Found new episode '#{episode}'")
@episode_queue.push(episode)