@@ -10,9 +10,17 @@ pub fn problem(problems: &mut Vec<Problem>, v: Value) -> Option<()> {
1010 let total_acs = stat. get ( "total_acs" ) ?. as_f64 ( ) ? as f32 ;
1111 let total_submitted = stat. get ( "total_submitted" ) ?. as_f64 ( ) ? as f32 ;
1212
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+
1321 problems. push ( Problem {
1422 category : v. get ( "category_slug" ) ?. as_str ( ) ?. to_string ( ) ,
15- fid : stat . get ( "frontend_question_id" ) ? . as_i64 ( ) ? as i32 ,
23+ fid : fid ,
1624 id : stat. get ( "question_id" ) ?. as_i64 ( ) ? as i32 ,
1725 level : p. get ( "difficulty" ) ?. as_object ( ) ?. get ( "level" ) ?. as_i64 ( ) ? as i32 ,
1826 locked : p. get ( "paid_only" ) ?. as_bool ( ) ?,
@@ -89,17 +97,20 @@ pub fn tags(v: Value) -> Option<Vec<String>> {
8997/// daily parser
9098pub fn daily ( v : Value ) -> Option < i32 > {
9199 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 ( )
103114}
104115
105116/// user parser
0 commit comments