grab_epg 0.2.9 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWFkOTJjM2E1ZDAxNjViODIxYWE2OTJiODRiZThhMTBmMzRmNDU3MA==
4
+ MGJjOWQ0MTYxNDVjNjBiNTRkYzZlMTE5ZWU1MzNiZjRiZTIwMmY5Zg==
5
5
  data.tar.gz: !binary |-
6
- N2Y1ZGJkM2Q5NmIzMDViMmFlMDc1NTQxY2NkY2JlZjAxODQxZTZiMA==
6
+ YjVlYWZlNDgwOWQzNGMzNDk4YmIwOWMyNmU5NWMzZTY3NTM4ZTgwZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YTBkZDFjOWUzN2UwYzEwYWQwNDdiZjYxOTA1MjAzYTEzNDA4M2VjODdjMTgw
10
- OGJkNDMxMzFjNzdiNWYwOWY0NWYyODI4OWIzZGUzMThlZTQ2ZjVmNmZjY2U2
11
- ZmQyODI0MWM4ZjQ5MjQzYTgxMmEzZTdiMzdmN2I4ZmMxNmE5Njc=
9
+ YzdhNjczNDA2ZDc3MmQwMzEyZjI1OWJhYzI3MTQwYmJjNzJiOGY0NDRhZWMw
10
+ NGUzZDg2OWM0ODhlYTI5ODc3MjhmN2Y4MWQwMzc4YmQ0OTQzYzVlMjc5ZTkw
11
+ ZWM5ZmJhM2ViNjZlNzRlYzYyNGExOTc1OTI0MjBkNGQzNDA4ZjU=
12
12
  data.tar.gz: !binary |-
13
- YWY4ZjA1YWRiZmNjOWNlY2RkYTQ2NzE1Mjk5N2U0OGMxYzU1MzBkMjg3MDdj
14
- ZDVhY2ViYzY0OGFkYzhkOGEyZjA0MTM0YTk2MzRhN2RjMTUyZWM0NGY2Yzk1
15
- ZDBhYWQ2ZjE5YjUzNGEwOTVhOTE0ZWIzMTNjNTk4MDI3MGEzMGI=
13
+ YzkzODFkOTlkYjllYjU4NjMwYWY4NDNlMTJjYTBjZjg1NDZjYmEzNGU4NWRj
14
+ NGIxMDg2OThlNTRhNzhjODFhZWExZjAyYzFjZTA1YTFkOThjMjdlMmUzNDdk
15
+ OWU2MWUxZWVmNDAxNzU0NTkwM2RiZDU0NDkzNmU3YTdmNWQ1MDc=
data/.grabepg.gemspec CHANGED
@@ -10,6 +10,6 @@ Gem::Specification.new do |gem|
10
10
  gem.files = `git ls-files`.split($\)
11
11
  gem.name = "grab_epg"
12
12
  gem.require_paths = ["lib"]
13
- gem.version = "0.2.9"
13
+ gem.version = "0.3.2"
14
14
  gem.homepage = "https://github.com/hahazql/grab_epg"
15
15
  end
data/lib/debug.rb CHANGED
@@ -12,5 +12,5 @@ class Debug
12
12
 
13
13
  # p TestGrabTvsou.new.get_channel_logo
14
14
  # p TestGrabTvmao.new.test_get_show_type_by_batch
15
- p TestGrabBase.new.test_proxy_list
15
+ p TestGrabTvmao.new.test_get_doc_channel_date
16
16
  end
data/lib/grab_tvmao.rb CHANGED
@@ -28,6 +28,7 @@ module Grabepg
28
28
 
29
29
  def initialize
30
30
  @grabbase = GrabBase.new
31
+ @@proxyindex = 0
31
32
  end
32
33
 
33
34
 
@@ -46,11 +47,12 @@ module Grabepg
46
47
  end
47
48
  url = get_show_type_url(url,date)
48
49
  schedules = get_schedulelist_atday(channel,url,proxylist)
49
- type = nil
50
+ type = []
50
51
  schedules.each do |schedule|
52
+ begin
51
53
  schedule_time_num = schedule["schedule_start"].gsub(":","").to_i
52
54
  if _schedule.has_key?(schedule_time_num)
53
- _schedule[schedule_time_num]["type"]=_schedule[schedule_time_num]["type"]|schedule["type"]
55
+ _schedule[schedule_time_num]["type"]=_schedule[schedule_time_num]["type"]|schedule["type"] if schedule["type"]
54
56
  p "*****************************************************************************************"
55
57
  p "Schedule: #{_schedule[schedule_time_num]}"
56
58
  p "schedule_logo_1: #{_schedule[schedule_time_num]["schedule_logo"]}"
@@ -61,6 +63,9 @@ module Grabepg
61
63
  end
62
64
  end
63
65
  end
66
+ rescue
67
+ next
68
+ end
64
69
  end
65
70
  ret = []
66
71
  _schedule.each do |key,value|
@@ -150,7 +155,9 @@ module Grabepg
150
155
  when 6
151
156
  ret += "六"
152
157
  when 7
153
- ret += ""
158
+ ret += ""
159
+ when 0
160
+ ret += "日"
154
161
  end
155
162
  ret
156
163
  end
@@ -320,7 +327,6 @@ module Grabepg
320
327
  def getchannels(img_dir_path)
321
328
  @channel = []
322
329
  @site=DEFAULT_SITE
323
- @proxyindex = 0
324
330
  @img_down_dir_path = img_dir_path
325
331
  @img_down_file = File.new(File.join(img_dir_path,"channel_img_down_path"),'w+')
326
332
 
@@ -364,7 +370,7 @@ module Grabepg
364
370
 
365
371
  def err_doc_proxy(proxy,proxylist,url="",err="")
366
372
  if proxy.empty?||proxy.nil?
367
- proxylist.delete_at[@proxyindex]
373
+ proxylist.delete_at[@@proxyindex]
368
374
  end
369
375
 
370
376
 
@@ -375,10 +381,10 @@ module Grabepg
375
381
  @no_firest += 1
376
382
  p "*************************Proxy:#{proxy}, url:#{url} Error:#{err}"
377
383
  #proxylist.delete(proxy) #删除出错的代理 但如果是此网页错误则会引起BUG待修复
378
- @proxyindex += 1
379
- @proxyindex=@proxyindex%@size
380
- doc=get_doc_with_proxy(proxylist,url) if @no_firest<4
381
- unless @no_firest<4
384
+ @@proxyindex += 1
385
+ @@proxyindex=@@proxyindex%@size
386
+ doc=get_doc_with_proxy(proxylist,url) if @no_firest<10
387
+ unless @no_firest<10
382
388
  @no_firest=0
383
389
  raise RuntimeError,"Error: #{err}"
384
390
  end
@@ -389,15 +395,17 @@ module Grabepg
389
395
  #使用代理获取url的html的doc值
390
396
  def get_doc_with_proxy(proxylist,url)
391
397
  unless proxylist.nil?||proxylist.empty?
392
- unless @proxyindex
393
- @proxyindex = 0
398
+ unless @@proxyindex
399
+ @@proxyindex = 0
394
400
  end
395
401
  @size = proxylist.size
396
- @proxyindex=@proxyindex%proxylist.size
397
- if(proxylist[@proxyindex])
398
- proxy = proxylist[@proxyindex]
402
+ @@proxyindex=@@proxyindex+1
403
+ @@proxyindex=@@proxyindex%@size
404
+ if(proxylist[@@proxyindex])
405
+ proxy = proxylist[@@proxyindex]
399
406
  else
400
- proxy = proxylist[@proxyindex+1]
407
+ @@proxyindex=@@proxyindex+1
408
+ proxy = proxylist[@@proxyindex]
401
409
  end
402
410
  begin
403
411
  doc = Nokogiri::HTML(open(url,:proxy=>"#{proxy}").read) unless proxy.nil?||proxy.empty?
@@ -412,12 +420,10 @@ module Grabepg
412
420
  doc=err_doc_proxy(proxy,proxylist,url,err.to_s)
413
421
  @no_firest=0
414
422
  p "Get DOC"
415
- @proxyindex += 1
416
- @proxyindex=@proxyindex%@size
423
+ @@proxyindex=@@proxyindex+1
424
+ @@proxyindex=@@proxyindex%@size
417
425
  return doc
418
426
  end
419
- @proxyindex += 1
420
- @proxyindex=@proxyindex%@size
421
427
  else
422
428
  begin
423
429
  doc = Nokogiri::HTML(open(url).read) if proxy.nil?||proxy.empty?
@@ -600,7 +606,6 @@ module Grabepg
600
606
  #获取节目详细信息
601
607
  def get_show_infomation(proxy_list,schedule_herf)
602
608
  begin
603
- @proxyindex = 0
604
609
  unless @site
605
610
  @site = "http://www.tvmao.com"
606
611
  end
@@ -633,10 +638,10 @@ module Grabepg
633
638
  unless @show_schedule
634
639
  @show_schedule={}
635
640
  end
636
- @show_schedule.merge!(name=>get_show_schedule(proxy_list,schedule_herf)) unless @show_schedule.has_key?(name)
641
+ #@show_schedule.merge!(name=>get_show_schedule(proxy_list,schedule_herf)) unless @show_schedule.has_key?(name)
637
642
  {"type"=>type,"name"=>name,"img"=>schedule_img_down_path}
638
- #rescue => e
639
- # p "Error In get_show_infomation msg : #{e.to_s}"
643
+ rescue => e
644
+ p "Error In get_show_infomation msg : #{e.to_s}"
640
645
  end
641
646
  end
642
647
 
@@ -140,8 +140,8 @@ module Grabepg
140
140
  #proxylist.delete(proxy) #删除出错的代理 但如果是此网页错误则会引起BUG待修复
141
141
  @proxyindex += 1
142
142
  @proxyindex=@proxyindex%@size
143
- doc=get_doc_with_proxy(proxylist,url) if @no_firest<4
144
- unless @no_firest<4
143
+ doc=get_doc_with_proxy(proxylist,url) if @no_firest<10
144
+ unless @no_firest<10
145
145
  @no_firest=0
146
146
  raise RuntimeError,"Error: #{err}"
147
147
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grab_epg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - hahazql
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-09 00:00:00.000000000 Z
11
+ date: 2013-06-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ! '"用于抓取EPG信息"'
14
14
  email: