arb-xmu-course 1.2.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/arb-xmu-course +37 -29
- data/bin/check_code.jpeg +0 -0
- data/lib/arb/xmu/course/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e85f64acb48eb553e908353453ac7e976cad47d6
|
4
|
+
data.tar.gz: 74bcb5fbc624ad94e17a454676fbfe722f11a9d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9451ef7d6f5710ecf9eb25544a690a65a4b6c972bee897eac0de1feea3b5ec0a1ecf974dc3ca40fcd6bc38550f029d034f09b22c75ad30a1ae79de14e68ea25c
|
7
|
+
data.tar.gz: 3d59a5b48c0221a22976b296fd51bdacb36626dd0af1b56d7138d6d6bf3c7ab04116b87edd0c5a32581dc8e6ed3f4623d65a4c6de809dcf3f5f632215ead7a5d
|
data/bin/arb-xmu-course
CHANGED
@@ -22,7 +22,7 @@ def filter_text(raw)
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
black_list =([] << "\r" << "\n" << "\t" << "'")
|
25
|
+
black_list =([] << "\r" << "\n" << "\t" << "'" << '<br>')
|
26
26
|
black_list.each do |tmp|
|
27
27
|
raw.gsub! tmp, ''
|
28
28
|
end
|
@@ -122,10 +122,10 @@ def create_attempt_thread(max_interval, client, course, xxlx, lcid, &block)
|
|
122
122
|
sleep interval
|
123
123
|
res = request_select_course(client, course, xxlx, lcid)
|
124
124
|
if res['success']
|
125
|
-
$stdout.puts "课程:《#{course.name}》已经成功选课!"
|
125
|
+
$stdout.puts '', "课程:《#{course.name}》已经成功选课!", ''
|
126
126
|
break
|
127
127
|
else
|
128
|
-
$stdout.puts "课程:《#{course.name}》第#{count}次尝试选课失败,#{interval}秒后将重试。(错误信息:#{res['message']})"
|
128
|
+
$stdout.puts '', "课程:《#{course.name}》第#{count}次尝试选课失败,#{interval}秒后将重试。(错误信息:#{filter_text(res['message'])})", ''
|
129
129
|
end
|
130
130
|
exit if block.binding.local_variable_get(:opened_thread_count)-1==0
|
131
131
|
end
|
@@ -133,24 +133,29 @@ def create_attempt_thread(max_interval, client, course, xxlx, lcid, &block)
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def prepare_select_course(client)
|
136
|
-
|
136
|
+
ensure_local_account
|
137
137
|
username, password = get_account_info
|
138
138
|
authorize_session(client, username, password)
|
139
139
|
end
|
140
140
|
|
141
|
-
def
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
141
|
+
def process_ids(str_ids)
|
142
|
+
#return int_ids
|
143
|
+
int_ids = str_ids.map do |item|
|
144
|
+
next item.to_i unless item=~/[^0-9]/
|
145
|
+
next (Range.new *(item.split('-').map(&:to_i))).to_a if item.include? '-'
|
146
|
+
end
|
147
|
+
int_ids.flatten.uniq
|
148
|
+
end
|
148
149
|
|
150
|
+
def try_to_select_courses(client, courses, xxlx, lcid)
|
151
|
+
$stdout.puts '', '输入要选的课程ID(重复无效,支持语法糖:x-y,会尝试选择ID从x到y的所有课程), 以空格分割:'
|
152
|
+
ids = process_ids($stdin.gets.chomp.split(' '))
|
153
|
+
$stdout.puts '输入最大重试间隔时间,要求不得低于3秒:'
|
149
154
|
max_interval = $stdin.gets.chomp.to_i
|
150
|
-
max_interval =
|
155
|
+
max_interval = 3 if max_interval<3
|
151
156
|
opened_thread_count = ids.size
|
152
157
|
ids.each do |id|
|
153
|
-
create_attempt_thread(max_interval, client, courses.find { |course| course.index==id
|
158
|
+
create_attempt_thread(max_interval, client, courses.find { |course| course.index==id }, xxlx, lcid) {}
|
154
159
|
end
|
155
160
|
end
|
156
161
|
|
@@ -160,34 +165,37 @@ def get_account_info
|
|
160
165
|
stu_id, passwd=SimpleDes.decrypt(file.read.split(TOKEN_SEPARATOR))
|
161
166
|
end
|
162
167
|
[stu_id, passwd]
|
168
|
+
rescue
|
169
|
+
puts '账号信息受损,请重新设置:'
|
170
|
+
set_up_account && exit
|
163
171
|
end
|
164
172
|
|
165
|
-
|
166
|
-
def select_school_elective(client)
|
167
|
-
|
173
|
+
def select_course_common(client, url, xxlx)
|
168
174
|
prepare_select_course(client)
|
169
|
-
|
170
|
-
show_courses_in_table
|
171
|
-
try_to_select_courses(client,
|
172
|
-
|
175
|
+
courses = parse_courses((client.get url).body)
|
176
|
+
show_courses_in_table courses
|
177
|
+
try_to_select_courses(client, courses, xxlx, get_main_select_round(client))
|
173
178
|
loop do
|
174
179
|
sleep 3
|
175
180
|
end
|
176
181
|
end
|
177
182
|
|
178
|
-
def
|
179
|
-
|
183
|
+
def select_school_elective(client)
|
184
|
+
select_course_common client, 'http://bkxk.xmu.edu.cn/xsxk/yxxx.html?pagination=5000', 4
|
180
185
|
end
|
181
186
|
|
182
|
-
def
|
187
|
+
def select_general_elective(client)
|
188
|
+
select_course_common client, 'http://bkxk.xmu.edu.cn/xsxk/qxxxx.html?pagination=5000', 3
|
189
|
+
end
|
183
190
|
|
191
|
+
def select_public(client)
|
192
|
+
select_course_common client, 'http://bkxk.xmu.edu.cn/xsxk/ggk.html?pagination=5000', 5
|
184
193
|
end
|
185
194
|
|
186
|
-
def
|
195
|
+
def ensure_local_account
|
187
196
|
unless (File.exists? TOKEN_FILE_NAME)
|
188
|
-
puts '
|
189
|
-
set_up_account
|
190
|
-
exit
|
197
|
+
puts '请先设置账号信息(账号信息会先加密然后保存在本地,用于授权选课系统)'
|
198
|
+
set_up_account && exit
|
191
199
|
end
|
192
200
|
end
|
193
201
|
|
@@ -218,9 +226,9 @@ case true
|
|
218
226
|
when opts.school?
|
219
227
|
select_school_elective(CLIENT)
|
220
228
|
when opts.general?
|
221
|
-
|
229
|
+
select_general_elective(CLIENT)
|
222
230
|
when opts.public?
|
223
|
-
|
231
|
+
select_public(CLIENT)
|
224
232
|
else
|
225
233
|
puts(opts) && exit
|
226
234
|
end
|
data/bin/check_code.jpeg
CHANGED
Binary file
|