yt-dlp / yt-dlp

A feature-rich command-line audio/video downloader
https://discord.gg/H5MNcFW63r
The Unlicense
82.83k stars 6.46k forks source link

Parse format list to json file or at least json into json string. #11015

Open kal-asther opened 2 days ago

kal-asther commented 2 days ago

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

Checklist

Please make sure the question is worded well enough to be understood

I would like to gather just the id's and formats, and specifically if they're audio_only and video_only.

I'm making a gui for it through a website for personal use, since my old-timer relatives need something with a relative(pun intended) ease-of-use. This way I can just parse the Json into javascript objects and display them there via their formats, just one of mp4, webm(av1 if possible), mp3, and aac for audio. And one of each video resolution for both webm and mp4.

Provide verbose output that clearly demonstrates the problem

Complete Verbose Output

No response

seproDev commented 2 days ago

You can either get a python dict using the api or use -j to get a json string of the extracted info.

kal-asther commented 2 days ago

You can either get a python dict using the api or use -j to get a json string of the extracted info.

Sorry, forgot to update this. I read a thread about (not exactly) the same thing, and it led me to a command that would output a custom json string.

Which led me to use the output command -O to acquire the results in json and then picked the fields that are most important to me.

Which then led me to this command yt-dlp -O "%(.{id,title,formats})#j" "url"

Hope it helps anybody looking for the same thing.

Edit: I would just leave this open for a bit as to maybe chance on someone with a better alternative.