triangle-utils 1.2.9 → 1.2.11
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/package.json +1 -1
- package/utils/Utils_Bee.js +7 -4
- package/utils/Utils_Misc.js +1 -1
package/package.json
CHANGED
package/utils/Utils_Bee.js
CHANGED
|
@@ -56,10 +56,10 @@ export default class Utils_Bee {
|
|
|
56
56
|
return undefined
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
async youtube_search(query) {
|
|
59
|
+
async youtube_search(query, options = {}) {
|
|
60
60
|
for (let i = 0; i < 3; i++) {
|
|
61
61
|
try {
|
|
62
|
-
const bee_url = "https://app.scrapingbee.com/api/v1/youtube/search?api_key=" + this.config.scraping_bee_api_key + "&search=" + encodeURI(query) + "&
|
|
62
|
+
const bee_url = "https://app.scrapingbee.com/api/v1/youtube/search?api_key=" + this.config.scraping_bee_api_key + "&search=" + encodeURI(query) + Object.entries(options).filter(([key, value]) => value !== undefined).map(([key, value]) => "&" + key + "=" + value).join("")
|
|
63
63
|
console.log(bee_url)
|
|
64
64
|
const response = await fetch(bee_url)
|
|
65
65
|
if (!response.ok) {
|
|
@@ -69,11 +69,14 @@ export default class Utils_Bee {
|
|
|
69
69
|
const data = await response.json()
|
|
70
70
|
const results = data.results
|
|
71
71
|
|
|
72
|
-
if (results === undefined
|
|
72
|
+
if (results === undefined) {
|
|
73
73
|
console.log("Failed to YouTube Search.")
|
|
74
74
|
continue
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
if (Array.isArray(results)) {
|
|
77
|
+
return results
|
|
78
|
+
}
|
|
79
|
+
return JSON.parse(results)
|
|
77
80
|
} catch {
|
|
78
81
|
console.log("Failed to YouTube Search.")
|
|
79
82
|
}
|
package/utils/Utils_Misc.js
CHANGED
|
@@ -152,7 +152,7 @@ export default class Utils_Misc {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
chunkify(text, max_length = 2500, overlap = 50) {
|
|
155
|
-
const chunk_indices = this.get_chunk_indices(text.length, max_length
|
|
155
|
+
const chunk_indices = this.get_chunk_indices(text.length, max_length, overlap)
|
|
156
156
|
return chunk_indices.map(chunk_index => ({
|
|
157
157
|
chunk_index : chunk_index,
|
|
158
158
|
chunk_text : text.substring(...chunk_index)
|