(self)
| 165 | self.dict["leetcode_update_db_time"] = util.now() |
| 166 | |
| 167 | def update_db(self): |
| 168 | t = self.get_update_db_time() |
| 169 | if util.now()-t < 24*3600*1000: |
| 170 | return |
| 171 | |
| 172 | url = withUrl("api/problems/all/") |
| 173 | f = urllib.request.urlopen(url) |
| 174 | content = f.read().decode('utf-8') |
| 175 | qlist = json.loads(content) |
| 176 | |
| 177 | try: |
| 178 | for q in qlist['stat_status_pairs']: |
| 179 | id = q['stat']['question_id'] |
| 180 | front_id = q['stat']['frontend_question_id'] |
| 181 | if is_int(front_id): |
| 182 | id = int(front_id) |
| 183 | level = q['difficulty']['level'] |
| 184 | slug = q['stat']['question__title_slug'] |
| 185 | paid_only = q['paid_only'] |
| 186 | title = self.get_title_with_slug(id, slug, paid_only) |
| 187 | print("id:", id, level, title) |
| 188 | |
| 189 | self.save_update_db_time() |
| 190 | except Exception as e: |
| 191 | print("leetcode update db error:", e) |
| 192 | pass |
no test coverage detected