diff --git a/rsshub/spiders/asmr/works.py b/rsshub/spiders/asmr/works.py new file mode 100644 index 0000000..cf9f3b9 --- /dev/null +++ b/rsshub/spiders/asmr/works.py @@ -0,0 +1,46 @@ +import requests +import pytz +from jinja2 import Template +from datetime import datetime + +domain = 'https://api.asmr-200.com/api/search' + +tpl = ''' +{{ work['title'] }} +

{{ work['title'] }} {{ work['source_id'] }}

+

发布者:{{ 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 - {search}', + 'link': top_url, + 'description': f'ASMR - {search}', + 'description': 'ASMR - 200 Search Subscription', + 'author': 'Bamboo_King', + 'items': list(map(parse, res['works'])) + } +