mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-06-09 15:10:40 +00:00
Merge pull request #29 from Bamboo-King/master
Add asmr-200.com (asmr.one) Support
This commit is contained in:
1
Pipfile
1
Pipfile
@@ -24,6 +24,7 @@ pyjsparser = "*"
|
||||
charset-normalizer = "*"
|
||||
pyppeteer = "*"
|
||||
flask-caching = "*"
|
||||
pytz = "*"
|
||||
|
||||
[dev-packages]
|
||||
coverage = "*"
|
||||
|
||||
1243
Pipfile.lock
generated
1243
Pipfile.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,16 @@ from rsshub.extensions import cache
|
||||
|
||||
bp = Blueprint('main', __name__)
|
||||
|
||||
@bp.route('/asmr/works/<string:search>/<string:order>/<int:subtitle>/<string:sort>')
|
||||
@bp.route('/asmr/works/<string:search>/<string:order>/<int:subtitle>')
|
||||
@bp.route('/asmr/works/<string:search>/<string:order>')
|
||||
@bp.route('/asmr/works/<string:search>')
|
||||
@bp.route('/asmr/works')
|
||||
def works(search='', order='create_date', subtitle=0, sort='desc'):
|
||||
from rsshub.spiders.asmr.works import ctx
|
||||
return render_template('main/atom.xml', **filter_content(ctx(search, order, subtitle, sort)))
|
||||
|
||||
|
||||
@bp.route('/word/<string:category>')
|
||||
@bp.route('/')
|
||||
@cache.cached(timeout=3600)
|
||||
|
||||
46
rsshub/spiders/asmr/works.py
Normal file
46
rsshub/spiders/asmr/works.py
Normal file
@@ -0,0 +1,46 @@
|
||||
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 = '''
|
||||
<a href="{{ link }}" title="点击进入官网查看"><img src="{{ work['mainCoverUrl'] }}" alt="{{ work['title'] }}" /></a>
|
||||
<h1>{{ work['title'] }} <span style="font-size: 0.6em; color: darkred;">{{ work['source_id'] }}</span></h1>
|
||||
<p><b>发布者:</b>{{ work['name'] }}</p>
|
||||
<p><b>评分:</b>{{ work['rate_average_2dp'] }} | <b>评论数:</b>{{ work.review_count }} | <b>总时长:</b>{{ work['duration'] }} | <b>音频来源:</b>{{ work['source_type'] }}</p>
|
||||
<p><b>价格:</b><span style="color: #f44336">{{ work.price }} JPY</span> | <b>销量:</b>{{ work['dl_count'] }}</p>
|
||||
<p><b>分类:</b>{{ work['category'] }}</p>
|
||||
<p><b>声优:</b>{{ work['cv'] }}</p>
|
||||
'''
|
||||
|
||||
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']))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
{% extends "layout.html" %} {% block title %}All Feeds{% endblock title %} {% block content %}
|
||||
|
||||
<div class="card text-left">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">ASMR Online</h4>
|
||||
<h6 class="text-muted">ASMR <a href="https://github.com/bamboo-king" target="_blank" class="badge badge-secondary">by Bamboo_King</a></h6>
|
||||
<p class="card-text">举例:<a href="https://pyrsshub.vercel.app/asmr/works" target="_blank">https://pyrsshub.vercel.app/asmr/works</a></p>
|
||||
<p class="card-text">路由:<code>/asmr/works/:search/:order/:subtitle/:sort</code></p>
|
||||
<p class="card-text">参数:<code>search</code> Optional 搜索字符串,不同的搜索用空格隔开,可以使用类似 $tag:*$ 格式搜索标签(或社团、声优、年龄限制等),具体使用方法可以类比官网</p>
|
||||
<p class="card-text">参数:<code>order</code> Optional 排序字段,默认按照资源的收录日期来排序,详见下表a</p>
|
||||
<p class="card-text">参数:<code>subtitle</code> Optional 筛选带字幕音频,可选 0 和 1 ,默认关闭</p>
|
||||
<p class="card-text">参数:<code>sort</code> Optional 排序方式,可选 asc 和 desc ,默认倒序</p>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<!--item info end-->
|
||||
|
||||
<!--item info start-->
|
||||
<div class="card text-left">
|
||||
<div class="card-body">
|
||||
@@ -685,4 +700,4 @@
|
||||
<br>
|
||||
<!--item info end-->
|
||||
|
||||
{% endblock content %}
|
||||
{% endblock content %}
|
||||
|
||||
Reference in New Issue
Block a user