Skip to content

Commit 5e498b0

Browse files
jiaojiaodubaiactions-user
authored andcommitted
better original author handle
1 parent ad194b0 commit 5e498b0

3 files changed

Lines changed: 51 additions & 30 deletions

File tree

E-Tiller.js

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"inRepository": true,
1010
"translatorType": 4,
1111
"browserSupport": "gcsibv",
12-
"lastUpdated": "2024-09-30 10:33:44"
12+
"lastUpdated": "2025-07-14 15:08:15"
1313
}
1414

1515
/*
@@ -114,14 +114,35 @@ async function scrapeMeta(doc, url = doc.location.href) {
114114
en: 'en-US'
115115
}[item.language];
116116
extra.set('original-title', ZU.capitalizeTitle(attr(doc, 'meta[name="citation_title"]', 'content', 1) || text(doc, '#EnTitleValue')), true);
117-
const creators = doc.querySelector('meta[name="citation_author"]')
118-
? Array.from(doc.querySelectorAll('meta[name="citation_author"]')).map(element => element.content)
119-
: attr(doc, 'meta[name="citation_authors"]', 'content', 0).split(/[,;]/);
120-
item.creators = creators
117+
const zhNames = doc.querySelector('meta[name="citation_author"]')
118+
? Array.from(doc.querySelectorAll('meta[name="citation_author"]')).map(element => element.getAttribute('content'))
119+
: attr(doc, 'meta[name="citation_authors"]', 'content').split(/[,;]/);
120+
const zhCreators = zhNames
121121
.map(creator => creator.replace(/(<.+>)?[\d,\s]+(<.+>)?$/, ''))
122-
.filter(creator => creator)
122+
.filter(Boolean)
123123
.map(creator => cleanAuthor(creator));
124-
const enCreators = attr(doc, 'meta[name="citation_authors"]', 'content', 1).split(/[,;]/);
124+
const enCreators = attr(doc, 'meta[name="citation_authors"][xml\\:lang="en"]', 'content')
125+
.split(/[,;]/)
126+
.map(name => cleanAuthor(name));
127+
const creatorsExt = [];
128+
zhCreators.forEach((creator, i) => {
129+
const enCcreator = enCreators[i];
130+
item.creators.push(creator);
131+
if (enCreator) {
132+
const enCreatorStr = `${enCcreator.lastName} || ${enCcreator.firstName}`;
133+
extra.push('original-creator', enCreatorStr, true);
134+
creatorsExt.push({
135+
firstName: creator.firstName,
136+
lastName: creator.lastName,
137+
creatorType: creator.creatorType,
138+
fieldMode: creator.fieldMode,
139+
original: enCreatorStr
140+
});
141+
}
142+
});
143+
if (creatorsExt.length) {
144+
extra.set('creatorsExt', JSON.stringify(creatorsExt));
145+
}
125146
if (enCreators.length) {
126147
const creatorsExt = JSON.parse(JSON.stringify(item.creators));
127148
for (let i = 0; i < item.creators.length; i++) {
@@ -238,14 +259,14 @@ class Extra {
238259
}
239260

240261
function cleanAuthor(name) {
241-
// https://zkxb.hnust.edu.cn/ch/reader/view_abstract.aspx?file_no=202303007&flag=1
242-
const creator = ZU.cleanAuthor(name.replace(/[(]?[\d,*]*[)]?$/, ''), 'author');
243-
if (/[\u4e00-\u9fff]/.test(creator.lastName)) {
244-
creator.lastName = creator.firstName + creator.lastName;
245-
creator.firstName = '';
246-
creator.fieldMode = 1;
247-
}
248-
return creator;
262+
return /\p{Unified_Ideograph}/u.test(name)
263+
? {
264+
firstName: '',
265+
lastName: name,
266+
creatorType: 'author',
267+
fieldMode: 1
268+
}
269+
: ZU.cleanAuthor(ZU.capitalizeName(name), 'author');
249270
}
250271

251272
function cleanPages(page) {

data/dashboard.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6706,7 +6706,7 @@
67066706
"trends": [
67076707
{
67086708
"author": "jiaojiaodubai",
6709-
"date": "2025-06-24 22:50:31 +0800",
6709+
"date": "2025-06-24 14:50:57 +0000",
67106710
"message": "update selector; add fallback element"
67116711
},
67126712
{
@@ -8517,7 +8517,7 @@
85178517
"inRepository": true,
85188518
"translatorType": 4,
85198519
"browserSupport": "gcsibv",
8520-
"lastUpdated": "2024-09-30 10:33:44"
8520+
"lastUpdated": "2025-07-14 15:08:15"
85218521
},
85228522
"testCases": [
85238523
{
@@ -8783,6 +8783,11 @@
87838783
],
87848784
"zhLabel": "勤云科技",
87858785
"trends": [
8786+
{
8787+
"author": "jiaojiaodubai",
8788+
"date": "2025-07-14 15:08:54 +0800",
8789+
"message": "better original author handle"
8790+
},
87868791
{
87878792
"author": "jiaojiaodubai",
87888793
"date": "2024-09-30 18:35:05 +0800",
@@ -8792,11 +8797,6 @@
87928797
"author": "jiaojiaodubai",
87938798
"date": "2024-06-20 17:04:42 +0800",
87948799
"message": "clean EOL, fix #351, fix #352"
8795-
},
8796-
{
8797-
"author": "jiaojiaodubai",
8798-
"date": "2024-02-09 17:13:34 +0800",
8799-
"message": "按照官方指南更改优先级"
88008800
}
88018801
]
88028802
},
@@ -15755,7 +15755,7 @@
1575515755
"inRepository": true,
1575615756
"translatorType": 4,
1575715757
"browserSupport": "gcsibv",
15758-
"lastUpdated": "2025-06-19 15:33:45"
15758+
"lastUpdated": "2025-07-11 03:58:04"
1575915759
},
1576015760
"testCases": [
1576115761
{
@@ -16312,6 +16312,11 @@
1631216312
],
1631316313
"zhLabel": "万方",
1631416314
"trends": [
16315+
{
16316+
"author": "jiaojiaodubai",
16317+
"date": "2025-07-11 12:00:03 +0800",
16318+
"message": "update monitor params"
16319+
},
1631516320
{
1631616321
"author": "jiaojiaodubai",
1631716322
"date": "2025-06-19 15:36:14 +0000",
@@ -16321,11 +16326,6 @@
1632116326
"author": "jiaojiaodubai",
1632216327
"date": "2025-06-13 05:53:06 +0000",
1632316328
"message": "fix unavailable type and id"
16324-
},
16325-
{
16326-
"author": "jiaojiaodubai",
16327-
"date": "2025-04-18 12:16:00 +0000",
16328-
"message": "fix #502"
1632916329
}
1633016330
]
1633116331
},

data/translators.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
},
126126
"E-Tiller.js": {
127127
"label": "勤云科技",
128-
"lastUpdated": "2024-09-30 10:33:44"
128+
"lastUpdated": "2025-07-14 15:08:15"
129129
},
130130
"Encyclopedia of China 3rd.js": {
131131
"label": "中国大百科全书",
@@ -285,7 +285,7 @@
285285
},
286286
"Wanfang Data.js": {
287287
"label": "万方",
288-
"lastUpdated": "2025-06-19 15:33:45"
288+
"lastUpdated": "2025-07-11 03:58:04"
289289
},
290290
"Wanfang Med.js": {
291291
"label": "万方医疗",

0 commit comments

Comments
 (0)