@xuda.io/drive_module 1.1.985 → 1.1.987
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +19 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1709,6 +1709,23 @@ const ocr_drive_file = async function (app_id, doc) {
|
|
|
1709
1709
|
|
|
1710
1710
|
if (!target_file) throw "bucket not find";
|
|
1711
1711
|
|
|
1712
|
+
function addQueryParam(urlString, key, value) {
|
|
1713
|
+
// Parse the URL
|
|
1714
|
+
const parsedUrl = new url.URL(urlString);
|
|
1715
|
+
|
|
1716
|
+
// Set the query parameter
|
|
1717
|
+
parsedUrl.searchParams.set(key, value);
|
|
1718
|
+
|
|
1719
|
+
// Return the updated URL
|
|
1720
|
+
return parsedUrl.toString();
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
target_file = addQueryParam(
|
|
1724
|
+
target_file,
|
|
1725
|
+
"xuda_internal_request_code",
|
|
1726
|
+
_conf.xuda_internal_request_code
|
|
1727
|
+
);
|
|
1728
|
+
|
|
1712
1729
|
try {
|
|
1713
1730
|
doc.ocr_stat = 2;
|
|
1714
1731
|
doc.ocr_stat_date = Date.now();
|
|
@@ -1743,6 +1760,7 @@ const ocr_drive_file = async function (app_id, doc) {
|
|
|
1743
1760
|
// Default to English if no language found
|
|
1744
1761
|
return lang;
|
|
1745
1762
|
}
|
|
1763
|
+
|
|
1746
1764
|
let lang = detectLanguageByCountry(doc.country);
|
|
1747
1765
|
|
|
1748
1766
|
const generalConfig = { oem: 1, psm: 3, lang };
|
|
@@ -1811,6 +1829,7 @@ const ocr_drive_file = async function (app_id, doc) {
|
|
|
1811
1829
|
.replace(/<\/?[^>]+(>|$)/g, "")
|
|
1812
1830
|
.replace(/[\n]/g, " ")
|
|
1813
1831
|
.replace(/[\f\t]/g, "");
|
|
1832
|
+
doc.ocr_lang = lang;
|
|
1814
1833
|
doc.ocr_stat = 3;
|
|
1815
1834
|
} catch (err) {
|
|
1816
1835
|
doc.ocr_stat = 4;
|