Kaynağa Gözat

Fix breaking/sticky logic

Only break on the first thread with no new posts if that thread is not
sticky. Also, ignore sticky threads unless this is the first page.
master
Dylan Baker 5 yıl önce
ebeveyn
işleme
210c1c5667
1 değiştirilmiş dosya ile 4 ekleme ve 2 silme
  1. 4
    2
      db/scrape.rb

+ 4
- 2
db/scrape.rb Dosyayı Görüntüle

78
   cookie = login(ENV['VLV_USERNAME'], ENV['VLV_PASSWORD'])
78
   cookie = login(ENV['VLV_USERNAME'], ENV['VLV_PASSWORD'])
79
   db = connect
79
   db = connect
80
 
80
 
81
-  (first..last).each do |page_number|
81
+  (first..last).each_with_index do |page_number, index|
82
     page = fetch_page(page_number, cookie)
82
     page = fetch_page(page_number, cookie)
83
     threads = parse_threads(page)
83
     threads = parse_threads(page)
84
     threads.each do |t|
84
     threads.each do |t|
85
-      puts t[:title]
86
       sleep(1)
85
       sleep(1)
86
+      is_sticky = t[:title].match(/^Sticky:/)
87
+      next if index > 0 && is_sticky
87
       page = fetch_thread(t, cookie)
88
       page = fetch_thread(t, cookie)
88
       first_post = page.at_css('.postinfo:first-child')
89
       first_post = page.at_css('.postinfo:first-child')
89
 
90
 
112
 
113
 
113
       last_post = posts.last
114
       last_post = posts.last
114
       unless db.from(:posts).first(remote_id: last_post[:remote_id]).nil?
115
       unless db.from(:posts).first(remote_id: last_post[:remote_id]).nil?
116
+        next if is_sticky
115
         break
117
         break
116
       end
118
       end
117
 
119
 

Loading…
İptal
Kaydet