Skip to content

Commit 7dda9e3

Browse files
committed
fix parse_work_data: old ver.
1 parent b75f61c commit 7dda9e3

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

book.cmn-Hant-TW/podcasts.js

+25-8
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,34 @@ var crawler = new CeL.work_crawler({
8282
// 選擇性屬性:須配合網站平台更改。
8383
};
8484

85+
// 由 meta data 取得作品資訊。
86+
extract_work_data(work_data, html);
87+
8588
// console.trace(text);
86-
Object.assign(work_data, JSON.parse(html.between(
89+
work_data['podcast-show'] = JSON.parse(html.between(
8790
//
8891
'<script name="schema:podcast-show" type="application/ld+json">',
89-
'</script>')));
90-
// e.g.,
91-
// https://podcasts.apple.com/tw/podcast/%E4%B8%8B%E4%B8%80%E6%9C%AC%E8%AE%80%E4%BB%80%E9%BA%BC/id1532820533
92-
work_data.title = work_data.title.replace(/[]/g, '');
93-
94-
// 由 meta data 取得作品資訊。
95-
// extract_work_data(work_data, html);
92+
'</script>'));
93+
94+
var data = JSON.parse(html.between('<script type="fastboot/shoebox"'
95+
// 這裡的資料,如 description 比較完整。
96+
+ ' id="shoebox-media-api-cache-amp-podcasts">', '</script>'));
97+
for ( var key in data) {
98+
try {
99+
data[key] = JSON.parse(data[key]);
100+
} catch (e) {
101+
// TODO: handle exception
102+
}
103+
}
104+
// console.log(data);
105+
work_data['shoebox-media-api-cache-amp-podcasts'] = data;
106+
107+
Object.assign(work_data, {
108+
// e.g.,
109+
// https://podcasts.apple.com/tw/podcast/%E4%B8%8B%E4%B8%80%E6%9C%AC%E8%AE%80%E4%BB%80%E9%BA%BC/id1532820533
110+
title : work_data.title.replace(/[]/g, ''),
111+
author : work_data['podcast-show'].author
112+
});
96113

97114
// console.log(html);
98115
// console.log(work_data);

0 commit comments

Comments
 (0)