Files
rss-server/handlers/pixiv/comb.py
mol 5157f4f8d2
All checks were successful
continuous-integration/drone/push Build is passing
feat
2023-09-05 18:06:07 +08:00

26 lines
835 B
Python

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