zyrouge / node-youtube-ext

A simple YouTube scraper.
https://youtube-ext.js.org
MIT License
20 stars 5 forks source link

Failed to parse contents from data. (SyntaxError: Unexpected token } in JSON at position 8653) #13

Closed buffolollo closed 2 months ago

buffolollo commented 9 months ago

Full error message: Error: Failed to parse contents from data. (SyntaxError: Unexpected token } in JSON at position 8653) at /home/buffolollo/DrummerTS/node_modules/youtube-ext/dist/search.js:56:15 at Generator.next () at fulfilled (/home/buffolollo/DrummerTS/node_modules/youtube-ext/dist/search.js:5:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

zyrouge commented 9 months ago

Could you attach your code with the search terms please? It seems to be working fine for me.

buffolollo commented 9 months ago

if (spotify.validateTrackURL(query)) { const data = await spotify.getTrack(query); const searchQuery = ${data.name} ${getNameArtist(data.artists)}; console.log(searchQuery); const res = await search(searchQuery, { filterType: "video", }); console.log(res); } so far it only gives me this error with this link: https://open.spotify.com/track/6VOoSi7mgFrKCeymxG6wKB?si=d8e1d5dcd0af464b

searchQuery: DISCO PARADISE Fedez Annalisa Articolo 31

buffolollo commented 9 months ago

sometimes when I search certain songs it still gives me this error:

Error: Failed to parse contents from data. (SyntaxError: Unexpected token } in JSON at position 8636) at /home/buffolollo/DrummerTS/node_modules/youtube-ext/dist/search.js:56:15 at Generator.next () at fulfilled (/home/buffolollo/DrummerTS/node_modules/youtube-ext/dist/search.js:5:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

zyrouge commented 9 months ago

sometimes when I search certain songs it still gives me this error:

Error: Failed to parse contents from data. (SyntaxError: Unexpected token } in JSON at position 8636) at /home/buffolollo/DrummerTS/node_modules/youtube-ext/dist/search.js:56:15 at Generator.next () at fulfilled (/home/buffolollo/DrummerTS/node_modules/youtube-ext/dist/search.js:5:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Unless I have steps to reproduce this issue, I cannot help with it.

buffolollo commented 9 months ago

With some searches it gives me this error:

Error: Failed to parse contents from data. (SyntaxError: Unexpected token } in JSON at position 8768) at /home/buffolollo/DrummerTS/node_modules/youtube-ext/dist/search.js:56:15 at Generator.next () at fulfilled (/home/buffolollo/DrummerTS/node_modules/youtube-ext/dist/search.js:5:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

code: import { search } from "youtube-ext"; const res = await search(query, { filterType: "video" }); if (res.videos.length < 1 || !res) return error(message, "I have not found any video!");

these are some queries: (examples)

I get this error sometimes when I search for certain songs

zyrouge commented 2 months ago

Not sure if this is still relevant, kindly re-open if so.