Skip to content

Instantly share code, notes, and snippets.

@Answeror
Last active July 14, 2017 11:51
Show Gist options
  • Save Answeror/34fd6a535090ca85a2fc to your computer and use it in GitHub Desktop.
Save Answeror/34fd6a535090ca85a2fc to your computer and use it in GitHub Desktop.
Bangumi私信订阅

Bangumi私信订阅

这个gist由torabot自动抓取并生成Atom feed.

使用方法

注意: 公开你的cookie是一件危险的事情. 别人可能利用它来滥用你的Bangumi账户! Torabot的作者保证不会使用你的cookie做这个gist功能以外的事情. 如果你不信任torabot, 请忽略这个gist.

例子: http://torabot.com/api/source/34fd6a535090ca85a2fc.atom?chii_auth=<chii_auth_in_your_cookie>

其中"chii_auth_in_your_cookie"是你的cookie里的对应值. 如果你使用Chrome, 可以按下CTRL+SHIFT+J, 然后在Resources选项卡中找到Cookies项, 用其中的"chii_auth"对应的值替换"chii_auth_in_your_cookie"即可. 注意: 如果你的chii_auth里包含%, 必须将其全部替换成%25.

然后将上述地址填入torabot的feed订阅. Bangumi收到私信后一般10分钟内即可收到torabot发来的通知邮件.

如果你不想使用torabot, 也可以直接用你喜欢的rss阅读器订阅该地址.

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet
version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:re='http://exslt.org/regular-expressions'
extension-element-prefixes='re'
>
<xsl:output method='xml' encoding='UTF-8'/>
<xsl:template match='/'>
<feed xml:lang='zh-CN' xmlns='http://www.w3.org/2005/Atom'>
<id>bgm.tv/pm</id>
<link rel='alternate' type='text/html' href='http://bgm.tv/pm'/>
<title>bgm.tv/pm</title>
<xsl:apply-templates select='//table[@class="topic_list"]'/>
</feed>
</xsl:template>
<xsl:template match='table'>
<xsl:for-each select='.//tr[td[contains(@class, "pm_")]]'>
<xsl:variable name='date' select='.//small[@class="grey"]'/>
<xsl:variable name='year' select='re:replace($date, "(\d+)-(\d+)-(\d+)", "", "\1")'/>
<xsl:variable name='month' select='re:replace($date, "(\d+)-(\d+)-(\d+)", "", "\2")'/>
<xsl:variable name='day' select='re:replace($date, "(\d+)-(\d+)-(\d+)", "", "\3")'/>
<xsl:variable name='time' select='concat($year, "-", format-number($month, "00"), "-", format-number($day, "00"), "T00:00:00Z")'/>
<xsl:variable name='content' select='.//span[@class="tip"]'/>
<entry>
<id><xsl:value-of select='.//input[@type="checkbox"]/@value'/></id>
<published><xsl:value-of select='$time'/></published>
<updated><xsl:value-of select='$time'/></updated>
<link rel='alternate' type='text/html'>
<xsl:attribute name='href'>
<xsl:value-of select='.//a[1]/@href'/>
</xsl:attribute>
</link>
<title><xsl:value-of select='normalize-space(.//a[1])'/></title>
<summary><xsl:value-of select='$content'/></summary>
<content type='text'><xsl:value-of select='$content'/></content>
<author>
<name><xsl:value-of select='.//a[2]'/></name>
<url><xsl:value-of select='.//a[2]/@href'/></url>
</author>
</entry>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
{
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Encoding": "gzip,deflate,sdch",
"Accept-Language": "en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,zh-TW;q=0.2,ja;q=0.2",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"Cookie": "chii_auth={{ chii_auth }}; chii_cookietime=2592000",
"Host": "bgm.tv",
"Referer": "http://bgm.tv/",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:32.0) Gecko/20100101 Firefox/32.0"
}
{
"@all": [
{
"@json_decode[headers]": {
"@jinja2": {
"template": { "text<": "headers.json" },
"kargs": { "chii_auth": "{{ chii_auth }}" }
}
}
},
{
"@request[login]": {
"context": "bangumi",
"uri": "http://bgm.tv",
"headers": { "&": "headers" }
}
},
{
"@xslt": {
"html_encoded": {
"[body]": {
"@request/login": {
"context": "bangumi",
"uri": "http://bgm.tv/pm",
"headers": { "&": "headers" }
}
}
},
"xslt": { "text<": "bgm_pm.xslt" }
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment