From 25b76672bffb1719153d32e6a3757bee487baca2 Mon Sep 17 00:00:00 2001 From: dvoprm Date: Sun, 17 Mar 2024 19:35:12 +0800 Subject: [PATCH 1/2] Add a translator to enable multiple items import for four CVF sponsored conferences (CVPR, ICCV, ECCV, WACV) --- The Computer Vision Foundation.js | 155 ++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 The Computer Vision Foundation.js diff --git a/The Computer Vision Foundation.js b/The Computer Vision Foundation.js new file mode 100644 index 00000000000..d74501bb6d4 --- /dev/null +++ b/The Computer Vision Foundation.js @@ -0,0 +1,155 @@ +{ + "translatorID": "cf64e005-38f4-4698-82bb-c8b67ffcf05e", + "label": "The Computer Vision Foundation", + "creator": "WEI Qisheng", + "target": "https://openaccess.thecvf.com", + "minVersion": "5.0", + "maxVersion": "", + "priority": 100, + "inRepository": true, + "translatorType": 4, + "browserSupport": "gcsibv", + "lastUpdated": "2024-03-17 11:29:33" +} + +/* + Not all CVPR meetings are supported by The CVF, so some papers are not in "openaccess.thecvf.com" (for example, CVPR2012). +*/ + +function detectWeb(doc, url) { + if (getSearchResults(doc, true) == "multiple") { + return "multiple"; + } + else if (getSearchResults(doc, true) == "single") { + return "conferencePaper"; + } + return false; +} + +function scrape(doc, url) { + let translator = Zotero.loadTranslator('web'); + // Embedded Metadata + translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48'); + translator.setDocument(doc); + + translator.setHandler('itemDone', (_obj, item) => { + item.complete(); + }); + + translator.getTranslatorObject(function (trans) { + trans.itemType = "conferencePaper"; + trans.doWeb(doc, url); + }); +} + +function doWeb(doc, url) { + if (detectWeb(doc, url) == "multiple") { + let items = getSearchResults(doc, false); + Zotero.selectItems(items, function (items) { + if (!items) { + return; + } + ZU.processDocuments(Object.keys(items), scrape); + }); + } + else { + scrape(doc, url); + } +} + +function getSearchResults(doc, checkOnly) { + let items = {}; + let found = false; + + let rows_multiple = doc.querySelectorAll('dt a[href*="_paper.html"]'); + let rows_single = doc.querySelectorAll('dd a[href*="_paper.pdf"]'); + + if (rows_multiple.length > 0) { + if (checkOnly) return "multiple"; + + for (let row of rows_multiple) { + let href = row.href; + let title = ZU.trimInternal(row.textContent); + if (!href || !title) continue; + found = true; + items[href] = title; + } + return found ? items : false; + } + else if (rows_single.length > 0) { + if (checkOnly) return "single"; + } + + return false; +}/** BEGIN TEST CASES **/ +var testCases = [ + { + "type": "web", + "url": "https://openaccess.thecvf.com/CVPR2023?day=all", + "items": "multiple" + }, + { + "type": "web", + "url": "https://openaccess.thecvf.com/content/CVPR2023/html/Ci_GFPose_Learning_3D_Human_Pose_Prior_With_Gradient_Fields_CVPR_2023_paper.html", + "items": [ + { + "itemType": "conferencePaper", + "title": "GFPose: Learning 3D Human Pose Prior With Gradient Fields", + "creators": [ + { + "firstName": "Hai", + "lastName": "Ci", + "creatorType": "author" + }, + { + "firstName": "Mingdong", + "lastName": "Wu", + "creatorType": "author" + }, + { + "firstName": "Wentao", + "lastName": "Zhu", + "creatorType": "author" + }, + { + "firstName": "Xiaoxuan", + "lastName": "Ma", + "creatorType": "author" + }, + { + "firstName": "Hao", + "lastName": "Dong", + "creatorType": "author" + }, + { + "firstName": "Fangwei", + "lastName": "Zhong", + "creatorType": "author" + }, + { + "firstName": "Yizhou", + "lastName": "Wang", + "creatorType": "author" + } + ], + "date": "2023", + "conferenceName": "Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition", + "language": "en", + "libraryCatalog": "openaccess.thecvf.com", + "pages": "4800-4810", + "shortTitle": "GFPose", + "url": "https://openaccess.thecvf.com/content/CVPR2023/html/Ci_GFPose_Learning_3D_Human_Pose_Prior_With_Gradient_Fields_CVPR_2023_paper.html", + "attachments": [ + { + "title": "Full Text PDF", + "mimeType": "application/pdf" + } + ], + "tags": [], + "notes": [], + "seeAlso": [] + } + ] + } +] +/** END TEST CASES **/ From 719fea8a55212e3d0c80284960aa20fd050bd763 Mon Sep 17 00:00:00 2001 From: dvoprm Date: Fri, 11 Oct 2024 16:46:40 +0800 Subject: [PATCH 2/2] ICLR --- ICLR.js | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 ICLR.js diff --git a/ICLR.js b/ICLR.js new file mode 100644 index 00000000000..17c4100a4b5 --- /dev/null +++ b/ICLR.js @@ -0,0 +1,140 @@ +{ + "translatorID": "2ffde8fb-56d7-478d-9d83-8ad22ba37796", + "label": "ICLR", + "creator": "WEI Qisheng", + "target": "iclr.cc", + "minVersion": "", + "maxVersion": "", + "priority": 100, + "inRepository": true, + "translatorType": 4, + "browserSupport": "gcsibv", + "lastUpdated": "2024-09-09 14:09:20" +} + +/* + +*/ + +function detectWeb(doc, url) { + Zotero.debug("【当前url】" + url); + + let yearMatch = url.match(/https:\/\/iclr\.cc\/virtual\/(\d{4})\/papers\.html/); + if (yearMatch) { + Zotero.debug("【Year detected】" + yearMatch[1]); // 打印年份 + return "multiple"; + } + Zotero.debug("【No year detected in the URL】" + url); + return false; +} + +function scrape(uid, info) { + if (info === undefined) { + // error! + return; + } + + // year + let year = 0; + let yearMatch = info.virtualsite_url.match(/virtual\/(\d{4})\//); + if (yearMatch) { + year = yearMatch[1]; + } else { + return; // 或者处理没有找到年份的情况 + } + + // url + let url; + if (info.paper_url) { + url = info.paper_url; + } else if (info.url) { + url = info.url; + } else { + // TODO + } + + // 创建一个新的条目 + let item = new Zotero.Item('conferencePaper'); + item.title = info.name; + item.abstractNote = info.abstract; + item.url = url; + item.creators = info.authors.map(author => ({ + lastName: author.fullname, + creatorType: "author" + })); + item.date = year; // 使用动态年份 + item.conferenceName = `${year} International Conference on Learning Representations (ICLR)`; + item.attachments.push({ + title: "Full Text PDF", + // url: info.paper_pdf_url, + mimeType: "application/pdf" + }); + item.complete(); +} + +function doWeb(doc, url) { + let yearMatch = url.match(/https:\/\/iclr\.cc\/virtual\/(\d{4})\/papers\.html/); + if (!yearMatch) { + Zotero.debug("Year not found in URL: " + url); + return; + } + + let year = yearMatch[1]; + Zotero.debug("Processing papers for the year: " + year); + + let jsonURL = `https://iclr.cc/static/virtual/data/iclr-${year}-orals-posters.json`; + + + + ZU.doGet(jsonURL, function (text) { + Zotero.debug("Fetched JSON data: " + text.substring(0, 100)); // 打印前100字符以查看结构 + let data = JSON.parse(text); + let items = {}; + let items_info = {}; + + let uid; + + for (let paper_info of data.results) { + /* + 大致分为4类: + 1、pdf链接在paper_url + 2、pdf链接在url + 3、pdf链接在 eventmedia - uri + 4、就一篇论文特殊,既不在openreview,又不在jmlr,但是他可以自动走第一类,解析成功 + */ + uid = paper_info.uid; + items[uid] = paper_info.name; + items_info[uid] = paper_info; + } + + Zotero.selectItems(items, function (selectedItems) { + if (!selectedItems) { + return; + } + + let uids = Object.keys(selectedItems); + + Zotero.debug("total_number: " + uids.length); + + for (let uid of uids) { + scrape(uid, items_info[uid]); + } + }) + + }); + + +} + + + + +/** BEGIN TEST CASES **/ +var testCases = [ +] +/** END TEST CASES **/ + +/** BEGIN TEST CASES **/ +var testCases = [ +] +/** END TEST CASES **/