@@ -10,9 +10,17 @@ pub fn problem(problems: &mut Vec<Problem>, v: Value) -> Option<()> {
10
10
let total_acs = stat. get ( "total_acs" ) ?. as_f64 ( ) ? as f32 ;
11
11
let total_submitted = stat. get ( "total_submitted" ) ?. as_f64 ( ) ? as f32 ;
12
12
13
+ let fid_obj = stat. get ( "frontend_question_id" ) ?;
14
+ let fid = match fid_obj. as_i64 ( ) {
15
+ // Handle on leetcode-com
16
+ Some ( s) => s as i32 ,
17
+ // Handle on leetcode-cn
18
+ None => fid_obj. as_str ( ) ?. split ( " " ) . last ( ) ?. parse :: < i32 > ( ) . ok ( ) ?,
19
+ } ;
20
+
13
21
problems. push ( Problem {
14
22
category : v. get ( "category_slug" ) ?. as_str ( ) ?. to_string ( ) ,
15
- fid : stat . get ( "frontend_question_id" ) ? . as_i64 ( ) ? as i32 ,
23
+ fid : fid ,
16
24
id : stat. get ( "question_id" ) ?. as_i64 ( ) ? as i32 ,
17
25
level : p. get ( "difficulty" ) ?. as_object ( ) ?. get ( "level" ) ?. as_i64 ( ) ? as i32 ,
18
26
locked : p. get ( "paid_only" ) ?. as_bool ( ) ?,
@@ -89,17 +97,20 @@ pub fn tags(v: Value) -> Option<Vec<String>> {
89
97
/// daily parser
90
98
pub fn daily ( v : Value ) -> Option < i32 > {
91
99
trace ! ( "Parse daily..." ) ;
92
- v. as_object ( ) ?
93
- . get ( "data" ) ?
94
- . as_object ( ) ?
95
- . get ( "activeDailyCodingChallengeQuestion" ) ?
96
- . as_object ( ) ?
97
- . get ( "question" ) ?
98
- . as_object ( ) ?
99
- . get ( "questionFrontendId" ) ?
100
- . as_str ( ) ?
101
- . parse ( )
102
- . ok ( )
100
+ let v_obj = v. as_object ( ) ?. get ( "data" ) ?. as_object ( ) ?;
101
+ match v_obj. get ( "dailyQuestionRecord" ) {
102
+ // Handle on leetcode-com
103
+ Some ( v) => v,
104
+ // Handle on leetcode-cn
105
+ None => v_obj. get ( "todayRecord" ) ?. as_array ( ) ?. get ( 0 ) ?,
106
+ }
107
+ . as_object ( ) ?
108
+ . get ( "question" ) ?
109
+ . as_object ( ) ?
110
+ . get ( "questionFrontendId" ) ?
111
+ . as_str ( ) ?
112
+ . parse ( )
113
+ . ok ( )
103
114
}
104
115
105
116
/// user parser
0 commit comments