import requests
import pytz
from jinja2 import Template
from datetime import datetime
from urllib.parse import unquote
domain = 'https://api.asmr-200.com/api/search'
tpl = '''
发布者:{{ work['name'] }}
评分:{{ work['rate_average_2dp'] }} | 评论数:{{ work.review_count }} | 总时长:{{ work['duration'] }} | 音频来源:{{ work['source_type'] }}
价格:{{ work.price }} JPY | 销量:{{ work['dl_count'] }}
分类:{{ work['category'] }}
声优:{{ work['cv'] }}
''' template = Template(tpl) def parse(post): url = f'https://asmr-200.com/work/{post["source_id"]}' post['category'] = ', '.join(map(lambda tag: tag['name'], post['tags'])) post['cv'] = ', '.join(map(lambda cv: cv['name'], post['vas'])) return { 'title': post['title'], 'image': post['mainCoverUrl'], 'author': post['name'], 'link': url, 'pubDate': pytz.timezone('Asia/Shanghai').localize(datetime.strptime(post['release'], '%Y-%m-%d')), 'category': post['category'], 'description': template.render({'work': post, 'link': url}) } def ctx(search='', order='create_date', subtitle=0, sort='desc'): top_url = f'{domain}/{search}?order={order}&subtitle={subtitle}&sort={sort}' res = requests.get(top_url).json() return { 'title': f'ASMR{"-" + unquote(search) if search != "" else ""}', 'link': top_url, 'description': 'ASMR Search Subscription', 'author': 'Bamboo_King', 'items': list(map(parse, res['works'])) }