diff --git a/catalog/sort.py b/catalog/sort.py new file mode 100755 index 0000000..3e83873 --- /dev/null +++ b/catalog/sort.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import re +import json + +catalog = {} +for catalogPage in json.loads(open('raw.json').read()): + for pageInfo in catalogPage: + pageId = re.search(r'^/novel/57104/read_(\d+)\.html$', pageInfo['url'])[1] + catalog[pageInfo['name']] = pageId + +catalog = sorted(catalog.items(), key = lambda d: int(re.search(r'^第(\d+)章', d[0])[1])) +catalog = {x[0]: x[1] for x in catalog} + +print(json.dumps(catalog))