提供一个工厂方法,创建电影、书籍、音乐、游戏对应的看过、在看、想看等条目的 Getter 方法。
现在阔以把标记为看过的影视、标记为读过的书、标记为玩过的游戏...以 JSON 格式存至本地。
引入包
yarn add https://github.com/hqweay/markall-douban-backup.git
使用
let createDoubanDataGetter = require('markall-douban-backup');
// 存储路径
const STORE_PATH = "douban-data-backup";
// 豆瓣帐号
const user = "";
let getDoubanWatchedMovies = createDoubanDataGetter("watchedMovies");
// 获取用户在豆瓣标记为看过的电影条目
getDoubanWatchedMovies(user, STORE_PATH);
Getter 的可选参数
getDoubanWatchedMovies(userName, STORE_PATH, endItemsCount = 999999, sleepTimer = 1500)
let getDoubanWatchedMovies = createDoubanDataGetter("watchedMovies");
let getDoubanWishMovies = createDoubanDataGetter("wishMovies");
let getDoubanWatchingMovies = createDoubanDataGetter("watchingMovies");
let getDoubanReadBooks = createDoubanDataGetter("readBooks");
let getDoubanWishBooks = createDoubanDataGetter("wishBooks");
let getDoubanReadingBooks = createDoubanDataGetter("readingBooks");
let getDoubanListenedMusics = createDoubanDataGetter("listenedMusics");
let getDoubanWishMusics = createDoubanDataGetter("wishMusics");
let getDoubanListeningMusics = createDoubanDataGetter("listeningMusics");
let getDoubanPlayedGames = createDoubanDataGetter("playedGames");
let getDoubanWishGames = createDoubanDataGetter("wishGames");
let getDoubanPlayingGames = createDoubanDataGetter("playingGames");
其它看 readme 吧 ^^...
做了个大更新,把数据的获取或储存解偶了。
似乎现在可以用 Getter 做 api...
使用:
let { createDoubanDataGetter, saveDoubanData, DoubanTypeEnum } = require('markall-douban-backup');
// 存储路径
const STORE_PATH = "douban-data-backup";
// 豆瓣帐号
const userName = "hqweay";
let getDoubanWatchedMovies = createDoubanDataGetter(DoubanTypeEnum.watchedMovies);
// 获取用户在豆瓣标记为想看的电影条目
getDoubanWatchedMovies(userName, pageStart = 1, pageEnd = 2, sleepTimer = 1500).then(function (data) {
// 数据、路径、文件名
saveDoubanData(data, STORE_PATH + "/hqweay/movie/", "watchedMovies");
})
1
Asimov01 2022-07-23 16:58:54 +08:00
感谢分享,正好有可能用上
|