Giter Site home page Giter Site logo

douban-backup's Introduction

sync-rss

详细教程 -> https://zhuzi.dev/posts/2021-06-05-douban-backup-sync-notion/

油猴脚本 -> https://greasyfork.org/en/scripts/420999

.
├── archive     # 不再使用的实验时的爬虫脚本
├── cols.json   # 可修改自定义的 Notion 表格列名
├── .env        # 如果需要在本地 debug,可以添加这个文件
├── scripts     # 长期不需要使用的脚本,但未来有可能需要使用
├── src         # 会保持更新正在使用的脚本👩🏻‍💻👈
└── userscript  # 导出时可使用的油猴脚本

从豆瓣 RSS 数据同步到 Notion 数据库

使用油猴脚本 export.user.js导出的 CSV 数据样例(one row)
{
  '标题': '无间双龙:这份爱,才是正义 / ウロボロス~この愛こそ正  義。',
  '个人评分': '5',
  '打分日期': '2015/03/21',
  '我的短评': '5星打的绝对不是剧情!为建国,为toma,为一众cast就  是如此任性ˊ_>ˋ(1 有用)',
  '上映日期': '2015/01/16',
  '制片国家': '日本',
  '条目链接': 'https://movie.douban.com/subject/25953663/'
}
  
Notion 数据库 properties 样例数据
{
  '条目链接': {
    id: '=jBf',
      type: 'url',
        url: 'https://movie.douban.com/subject/26277363/'
  },
  'IMDb 链接': {
    id: '@ME}',
      type: 'url',
        url: 'https://www.imdb.com/title/tt5419278'
  },
  '主演': { id: 'X{lL', type: 'rich_text', rich_text: [[Object]] },
  '个人评分': {
    id: 'Z^ph',
    type: 'multi_select',
    multi_select: [ { id: 'FRXk', name: '5', color: 'pink' } ]
    // multi_select: [], // empty array if no value for rating
  },
  '打分日期': {
    id: 'e\\{[',
      type: 'date',
        date: { start: '2021-01-19', end: null }
  },
  '类型': {
    id: 'pzY>',
      type: 'multi_select',
        multi_select: [[Object], [Object]]
  },
  '海报': {
    id: 't@Fv',
    type: 'files',
    files: [
    {
      name: 'https://img3.doubanio.com/view/photo/s_ratio_poster/public/p2524998570.jpg'
    }
  ]
  },
  '我的短评': { id: 'wG?R', type: 'rich_text', rich_text: [[Object]] },
  '上映年份': { id: 'xghA', type: 'number', number: 2016 },
  '导演': { id: 'y]UL', type: 'rich_text', rich_text: [[Object]] },
  '标题': { id: 'title', type: 'title', title: [[Object]] }
}
  
豆瓣RSS 数据解析之后的例子
#竹子哟竹子#✨ 的收藏
{
  creator: '#竹子哟竹子#✨',
  title: '想看白蛇传·情',
  link: 'http://movie.douban.com/subject/34825976/',
  pubDate: 'Mon, 31 May 2021 15:14:58 GMT',
  'dc:creator': '#竹子哟竹子#✨',
  content:
    `
白蛇传·情

推荐: 很差/较差/还行/推荐/力荐

`, contentSnippet: '', guid: 'https://www.douban.com/people/MoNoMilky/interests/2898270366', isoDate: '2021-05-31T15:14:58.000Z' } { creator: '#竹子哟竹子#✨', title: '想看大宋提刑官', link: 'http://movie.douban.com/subject/2239292/', pubDate: 'Mon, 31 May 2021 15:12:13 GMT', 'dc:creator': '#竹子哟竹子#✨', content: '\n' + '\n' + ' \n' + ' \n' + '
\n' + ' 大宋提刑官\n' + '

推荐: 还行

备注: 测试 短评第 2 行

' '
\n', contentSnippet: '推荐: 还行\n备注: 测试\n短评第 2 行', guid: 'https://www.douban.com/people/MoNoMilky/interests/2898265663', isoDate: '2021-05-31T15:12:13.000Z' }

RSS 的好处一个是轻量,但又包含了个人标记的最重要的几个数据:名字、条目链接、时间、评分、短评。 所以需求可以转换为,定时获取 RSS 更新,并对新的条目进行抓取信息并同步到 notion database。

但需要注意的是,豆瓣的 RSS 数据每次都只保留 10 个,并且包括想看、想听、想读。本人的脚本同步到 Notion 的部分仅处理看过、听过、读过的条目,如果某一天集中标记数量过多,可能使 RSS 数据并未全部被 workflow 获取。 这种情况的时候请自己手动触发脚本的运行,或者将脚本运行间隔时间改短,比如每个小时或者每两个小时。

GitHub 免费用户的开源仓库,actions 暂时是完全免费,也不计时间。

查看 workflow 运行结果 ->

同时同步标记到 NeoDB

NeoDB 文档

在文档页面先生成一个 Token,然后给 repo 添加一个 secret 叫 NEODB_API_TOKEN。 即可开启在豆瓣的标记会同步到 NeoDB 的功能。

todo

  • 补全 notion 中的海报
    • 同步时会正常插入海报信息,海报图片是豆瓣上的图片的 URL,所以在 notion 中显示不稳定。但因为 notion API 不支持上传文件,所以也无法直接插入图片。暂时不做任何优化。
  • userscript 添加导出 在* 和 想* 的功能
    • 想* 的部分已更新
    • 在* 的部分感觉个人需求实在不太大,已搁置
  • 豆瓣的标记同步更新到 NeoDB
  • 添加 在* 或者 想* 列表,考虑一下如何显示?
  • 从别处更新条目,比如 NeoDB,因为部分条目在豆瓣被删除或未创建

douban-backup's People

Contributors

bambooom avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

douban-backup's Issues

来催TODO啦!

脚本很好用!想知道啥时候会出 “想*” 和 “在*” 哈哈哈哈

打分日期并不是RSS中的pubDate而是抓取日期?

非常感谢分享这个解决方案,不懂js所以直接就是开箱拿来用了,也顺利的跑起来了。

现在有一个问题是,加入表格中的打分日期不是豆瓣RSS中的pubDate而是抓取日期?

以下来自我的RSS:

<item>
<title>读过Beauty</title>
<link>https://book.douban.com/subject/26259270/</link>
<description>
<![CDATA[ <table><tr> <td width="80px"><a href="https://book.douban.com/subject/26259270/" title="Beauty"> <img src="https://img9.doubanio.com/view/subject/s/public/s27808006.jpg" alt="Beauty"></a></td> <td> <p>推荐: 力荐</p> <p>备注: Peter死了我还蛮伤心,这里面就Peter和Marine是真正意义上的好人。Fairies到底是啥以及力量是怎么来的也没有解释,MARA从头到尾没出现过,MAB是个自以为聪明的傻子而且还贪杯误事。故事流畅精彩引人入胜,喜欢这个结局,因为并不是一个红颜祸水或是薄命的故事,被诅咒的也可以是你的武器。</p> </td></tr></table> ]]>
</description>
<dc:creator>粉刷匠</dc:creator>
<pubDate>Fri, 09 Jul 2021 14:07:49 GMT</pubDate>
<guid isPermaLink="false">https://www.douban.com/people/63904895/interests/2946727118</guid>
</item>
<item>
<title>读过My Beijing</title>
<link>https://book.douban.com/subject/30382823/</link>
<description>
<![CDATA[ <table><tr> <td width="80px"><a href="https://book.douban.com/subject/30382823/" title="My Beijing"> <img src="https://img2.doubanio.com/view/subject/s/public/s33643121.jpg" alt="My Beijing"></a></td> <td> <p>推荐: 力荐</p> <p>备注: 后浪的中文版太贵了,找了英文版看完,美丽的水彩画和纯真的故事,特别适合夏天阅读</p> </td></tr></table> ]]>
</description>
<dc:creator>粉刷匠</dc:creator>
<pubDate>Thu, 08 Jul 2021 15:43:18 GMT</pubDate>
<guid isPermaLink="false">https://www.douban.com/people/63904895/interests/2945589108</guid>
</item>

抓取了之后的Log如下:

====================
Handling book feeds...
There are total 3 new book item(s) need to insert.
Fetching book item with link: https://book.douban.com/subject/26259270/
Goint to insert  2021-07-13 Beauty
Beauty[https://book.douban.com/subject/26259270/] page created.
Fetching book item with link: https://book.douban.com/subject/30382823/
Goint to insert  2021-07-13 My Beijing
My Beijing[https://book.douban.com/subject/30382823/] page created.
Fetching book item with link: https://book.douban.com/subject/35221667/
Goint to insert  2021-07-13 日日是好日
日日是好日[https://book.douban.com/subject/35221667/] page created.
book feeds done.
====================

当然我相信这个问题应该不大,因为日后都是几个小时定时跑的,和实际的打分日期相差应该不大,这个问题应该只会出现在第一次。

另外一点就是目前还不能抓取封面,只能自己手动再加封面图,这个功能之后可以实现吗?

再次表示谢谢!

脚本运行正常,但标题无法记录

Workflow 脚本运行正常,各种数据的同步也实现了,唯独没有记录下标题。



如图所示,区别于其他油猴脚本导入的数据,红框里通过脚本同步的数据都只少了标题。


Notion 时间轴记录里,Integration 的更新一开始就是无标题了。

代码小白,提供的图片不清楚有没有把问题说明白,如果有更多需要的截图告知我一声让我补充即可,非常感谢。

07.13开始,运行报错 TypeError: Cannot read properties of null (reading '1')

Run node sync-rss.js || exit 1
Refreshing feeds from RSS...
file:///home/runner/work/douban-backup/douban-backup/sync-rss.js:297
  const m = title.match(allStatus)[1];
                                  ^

TypeError: Cannot read properties of null (reading '1')
    at extractItemInfo (file:///home/runner/work/douban-backup/douban-backup/sync-rss.js:297:35)
    at file:///home/runner/work/douban-backup/douban-backup/sync-rss.js:79:38
    at Array.forEach (<anonymous>)
    at main (file:///home/runner/work/douban-backup/douban-backup/sync-rss.js:78:9)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Error: Process completed with exit code 1.

无法同步

错误日志如下
Failed to create 成瘾剂量 Dopesick(http://movie.douban.com/subject/35101436/) with error: APIResponseError: 个人评分 is expected to be number. 打分日期 is expected to be rich_text.

Failed to create 密特罗德 生存恐惧 メトロイド ドレッド(http://www.douban.com/game/35496235/) with error: APIResponseError: 个人评分 is expected to be number. 打分日期 is expected to be rich_text.

请问 APIResponseError 是 Notion API 返回的吗?

您好,我在同步过程中出现了问题

按照您的方案一步步设置,除了添加integrations那一步,notion改版成了添加connections的形式。
只挑选了阅读页面的database,页面除了添加标题,其他地方都是空白。
请问能看看是哪一步出了问题吗?
非常感谢。

No new item

bamboom你好,想要请教一下,现在action运行正常,但是sync-rss.js 运行之后,总是返回 No new items,但我明明有新的标记,请问这可能是怎么回事呢?

scheduled workflow 最后一次run是在25天之前

Hi, 我又来了, 我今天发现我之前设好的两个douban账号都停在了25天之前. 查看Action发现25天最后一次run之后就没有run过. 我中间没有动过设置, 不知道是不是因为是schedule workflow, 我在action里也找不到可以manually run的地方? 只好disable再enable了看看能不能恢复. 想问一下这是因为什么原因造成的,以及如何修复...

关于图书标题和出版社的问题

大佬您好,感谢您的项目!有两个问题想向您请教:

  1. 图书同步到notion后没有书名,包括您提供的自己的notion里最近的几条项目似乎也存在这个问题。
  2. 图书同步过来出版社一栏包括了很多行,除出版社外还有ISBN等,是否可以修复?

再次感谢!

sync-rss手动运行失败

你好,按照博文设置好以后,手动测试了一下,但是没有跑通。

显示是这样的
Failed to handle the following feeds:
undefined: http://movie.douban.com/subject/34882958/
undefined: http://movie.douban.com/subject/1300678/
undefined: http://movie.douban.com/subject/6524236/
undefined: http://movie.douban.com/subject/27075556/
undefined: http://movie.douban.com/subject/36247982/
Error: Process completed with exit code 1.

另外,我在notion没有套用你的template模版,直接使用导出的csv,不知道是不是这个影响了添加新条目。

辛苦你抽空帮忙看看怎么回事,谢谢。

https://github.com/codyb1ue/douban-backup

网站上的油猴脚本怎么把海报也弄下来啊?

按照网站的教程,完美的弄完了书和影视,通过 Github Action 同步的内容都可以顺利搞定。

但是之前我还有 700+ 的电影,没有海报...请问有什么办法可以把它们弄下来么,合并到 Notion 中么?

Github Actions 无法触发

我不需要图片和音乐的部分的信息,所以在 secrets 里面就只填写了 MOVIE 的 ID。但是现在还是没有运行 actions,请问是哪里设置问题嘛?还是说必须要填写 图书、音乐 的 DATABASE ID 都需要填写才能运行?

截屏2021-08-09 下午2 31 34

截屏2021-08-09 下午2 31 58

截屏2021-08-09 下午2 32 07

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.