forked from NomadThanatos/readmoo-dl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rb.example
More file actions
38 lines (32 loc) · 1.29 KB
/
main.rb.example
File metadata and controls
38 lines (32 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require_relative 'lib/readmoo_dl'
username = 'xxxxxxx@gmail.com' # 你的 readmoo 帳號
password = '12345678' # 你的 readmoo 密碼
api = ReadmooDL::API.new(username: username, password: password)
downloader = ReadmooDL::Downloader.new(api)
#
# 書籍編號可以從書籍網址取得,例如書籍網址為 「https://readmoo.com/book/210088579000101」,
# 則編號是 210088579000101,那麼下方的程式碼就改為 「downloader.download('210088579000101')」。
# (注意: 1. 單引號不要刪掉 2. 要有購買過的書籍才可以下載)
#
# 可以複製多行一次下載多本:
# downloader.download('12345678')
# downloader.download('87654321')
#
downloader.download('你的書籍編號')
# Below code will download every book you have, and save the list to history.txt to avoid re-downloading in future.
# Remove the corresponding line in history.txt if you want to re-download a specific one.
=begin
lister = ReadmooDL::Lister.new(api)
history = {}
File.readlines('history.txt').each do |line|
history_item = JSON.parse(line)
history[history_item['id']] = history_item['title']
end
File.open('history.txt', 'a') do |history_file|
lister.list.each do |item|
next if history[item['id']]
downloader.download(item['id'])
history_file.puts(item.to_json)
end
end
=end