Comments (8)
Hello, @ainsey11 thanks for opening this issue.
I was debugging and this is the output of your command:
https://gist.github.com/Kikobeats/421642b94a16ae017c2744b072c577da
Unfortunately, It's not a valid JSON:
❯ node
Welcome to Node.js v16.0.0.
Type ".help" for more information.
> JSON.parse(fs.readFileSync('./debug.log').toString())
Uncaught SyntaxError: Unexpected token { in JSON at position 37665
So the thing is --dump-json
is generating a not valid JSON.
I can't do too much there; I think this issue should be open at https://github.com/ytdl-org/youtube-dl
Feel free to comment back!
from youtube-dl-exec.
I found youtube-dl is returning a collection of objects using break like as separator, so I guess I can create the real JSON
from youtube-dl-exec.
Oh that's a good spot! the jq
tool must be ignoring the invalid json or dealing with it internally somehow,
I'll raise a bug with youtube-dl but if you were able to do something clever with the break that would be much appreciated!
from youtube-dl-exec.
I thought youtube-dl is using http://ndjson.org format, so I wrote a function for parsing the result respecting the spec
const ndjson = (str) => {
const collection = str.split(/\n|\n\r/).filter(Boolean)
return collection.map(jsonStringRow => JSON.parse(jsonStringRow))
}
but it's still failing. It would be really appreciated if you can open an issue on the main repo and let's see what the most affordable solution we can adopt
from youtube-dl-exec.
Thanks for having a look - I noticed it's missing a } on the end of the output too:
I've raised a bug with them at ytdl-org/youtube-dl#28875 but you are entirely right, the output from youtube-dl is 100% not JSON!
from youtube-dl-exec.
Just had an update on the youtube-dl issue - ytdl-org/youtube-dl#28875 (comment)
I tweaked my config to:
async function Test(VideoURL){
let result = await youtubedl(VideoURL,{
//dumpJson: true,
noWarnings: true,
noCallHome: true,
"dump-single-json": true,
})
console.log(result)
}
and I do now get valid JSON back, it's a single json object that contains an array and a few other fields like this (not complete output, just an example):
{
extractor: 'youtube:tab',
_type: 'playlist',
uploader: 'AvE',
entries: [
{
upload_date: '20170129',
extractor: 'youtube',
vbr: 2366.247,
height: 1080,
like_count: 10026,
},
so I guess I can now iterate over the objects in the entries array to get my individual video information and should be good!
might be worth noting on the readme that if dealing with playlists then you need to use dump-single-json
instead of dumpJson
?
Thanks for your help with this!
from youtube-dl-exec.
happy to see you resolved the issue!
It's the first time I see dump-single-json
. I adopted that flag since looks like it's done the thing that before but also parsing playlist as expecting 🙂
from youtube-dl-exec.
Brilliant, thank you!
For anyone else that comes across this issue in the future, here's a snippet that grabs all video URL's from a playlist using the method described above:
const youtubedl = require("youtube-dl-exec")
async function Test(VideoURL){
let result = await youtubedl(VideoURL,{
noWarnings: true,
noCallHome: true,
"dump-single-json": true,
})
//console.log(result)
for (video of await result.entries){
console.log(video.webpage_url)
}
}
Test("<enter_playlist_url_here>")
or using the new feature:
async function Test(VideoURL){
let result = await youtubedl(VideoURL,{
noWarnings: true,
noCallHome: true,
dumpSingleJson: true,
})
from youtube-dl-exec.
Related Issues (20)
- Selected folder paths for downloads not implemented HOT 1
- Missing python? or ?
- Can I get the channel profile picture? HOT 2
- using best option , it not always give that url which contains both video and audio of youtube link HOT 1
- "Error: /usr/bin/env: python3: No such file or directory" in Next.js Backend HOT 3
- Update / Install of 2.4.3+ fails with Node v16 due to preinstall script HOT 5
- YtResponse type is incomplete missing: automatic_captions and others HOT 3
- HLS link extraction using youtube-dl-exec instead of youtube-dl HOT 2
- Getting 404 Errors HOT 1
- Error running on electron on mac HOT 1
- Not working after hosting on server HOT 2
- Unable to extract after uploading the code to a server HOT 1
- Not working when a binary is on a path with space HOT 1
- youtubedl.exec is missing cancel() function HOT 10
- tinyspawn version conflict HOT 2
- This expression is not callable. HOT 1
- Does not work if there is a space anywhere in the path HOT 5
- Issue with Python Check HOT 2
- All downloads return 'undefined' HOT 3
- post-install failures are minimized HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from youtube-dl-exec.