Top Level Namespace

Defined Under Namespace

Modules: Doubapi Classes: Struct

Instance Method Summary collapse

Instance Method Details

#test1Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/test.rb', line 7

def test1
  key = "许巍" 
  Doubapi.search_events_of(:key=>key).each do |event|
    event.what.should be_include(key)
    puts event.title
    puts event.when
    puts event.where
    puts event.link
  end	

end

#test2Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/test.rb', line 20

def test2
  #author = "李志"
  #author = "窦唯"

	#authors = File.read("artists.txt").split("\n")

	authors = ['汪峰']
	authors.each do |author|
	
	total, albums = Doubapi.search_albums_of(:singer=>author,:since=>"1900-05",:max_result => 20) 
  
  #release date decending
  albums.sort {|a , b| b.release_date <=> a.release_date }.each do |album|
    puts "-------------------------------"
    puts album.author	
    puts album.release_date	
    puts album.title	
    puts album.cover_thumbnail
    puts album.publisher
    puts album.link	
    puts album.mobile_site
    puts album.rating

		album.tracks.each do |track|
			puts track.title
		end

		#puts album.json
  end
 
	end# each author
  #rating decending
 
=begin
  #release date decending
   albums.sort {|a , b| b.rating <=> a.rating }.each do |album|
     puts "-------------------------------"
     puts album.author	
     puts album.release_date	
     puts album.title	
     puts album.cover_thumbnail
     puts album.publisher
     puts album.link	
     puts album.mobile_site
     puts album.rating
   end
  puts "total #{total}"
=end
end

#test4Object



116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/test.rb', line 116

def test4
  
  totalResults = Doubapi.search_events_of(:key => "all", :location => "shanghai", :start_index => 1,:max_result => 1) do |event|
    puts "#{event.when} #{event.title}"
    puts event.where
    puts event.link
    puts event.poster_mobile
    puts event.bar_icon
  end
  
  puts "totalResults #{totalResults}"
  
end

#test5Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/test.rb', line 130

def test5
  
  totalResults ,events = Doubapi.search_events_of(:key => "all", :location => "shanghai", :start_index => 1,:max_result => 5)
  
  events.each do |event|
    puts "#{event.when} #{event.title}"
    puts event.where
    puts event.link
    puts event.poster_mobile
    puts event.bar_icon
  end
  
  puts "totalResults #{totalResults}"
  
end

#test_get_all_eventsObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/test.rb', line 72

def test_get_all_events
  
  
  puts "trying to get 30 first"
  
  batch_size = 30;
  totalResults1 = Doubapi.search_events_of(:key => "all", :location => "shanghai", :start_index => 1,:max_result => batch_size) do |event|
   # puts "#{event.when} #{event.title}"
  end
  
  puts "total results #{totalResults1} ,will fetch others"
  
  return if(totalResults1 <= batch_size)
  
  (2..totalResults1/batch_size).each do |i|
    start_index = (i-1)*batch_size+1;
    max_result = batch_size;
    puts "start_index :#{start_index}"
    Doubapi.search_events_of(:key => "all", :location => "shanghai", :start_index => start_index, :max_result => max_result) do |event|
     # puts "#{event.when} #{event.title}"
    end
    
  end
  
  return if((totalResults1%batch_size)==0)
  
  last_fetch_size = totalResults1 - (totalResults1/batch_size)*batch_size;
  
  start_index = (totalResults1/batch_size)*batch_size+1;
  max_result = last_fetch_size;
  puts "start_index :#{start_index}"
  Doubapi.search_events_of(:key => "all", :location => "shanghai", :start_index => start_index, :max_result => max_result) do |event|
   # puts "#{event.when} #{event.title}"
  end
  
  
  
  
    

  
end