This commit is contained in:
26
handlers/pixiv/comb.py
Normal file
26
handlers/pixiv/comb.py
Normal file
@ -0,0 +1,26 @@
|
||||
import re
|
||||
|
||||
# 整理数据
|
||||
def extract_pixiv_info(entries):
|
||||
# 整理为JSON数组
|
||||
pixiv_list = []
|
||||
for entry in entries:
|
||||
links = []
|
||||
for i in entry['content']:
|
||||
pattern = re.compile(
|
||||
r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+')
|
||||
links = (re.findall(pattern, i['value']))
|
||||
|
||||
tag_pattern = re.compile(r'tags/(.*)/')
|
||||
item = {'id': entry['id'], 'title': entry['title'], 'link': links, 'author': entry['author'], 'tag': re.findall(tag_pattern, entry['source']['id'])}
|
||||
|
||||
pixiv_list.append(item)
|
||||
return pixiv_list
|
||||
|
||||
def get_prefix_name_on_entry(entry):
|
||||
tag = ','.join(entry['tag'])
|
||||
title = entry['title']
|
||||
author = entry['author']
|
||||
prefix_name = f'#{tag}# @{author}@ {title}'
|
||||
|
||||
return prefix_name
|
Reference in New Issue
Block a user