iv-org / invidious

Invidious is an alternative front-end to YouTube
https://invidious.io
GNU Affero General Public License v3.0
15.68k stars 1.72k forks source link

[Bug] adaptiveFormats missing fields in some formats #2647

Open megascrapper opened 2 years ago

megascrapper commented 2 years ago

Describe the bug

Each entry in the adaptiveFormats field of /api/v1/videos/:id has different available fields. For example, audio streams are missing resolution and qualityLabel. This is currently not mentioned anywhere in the documentation, so it would be better to have these missing fields to return null instead, or at least mention it in the API docs.

Steps to Reproduce

have and API request on video page, e.g. /api/v1/videos/xuCn8ux2gbs I found 3 types of entry: Video streams (except AV1) : all fields available

    {
      "index": "739-3626",
      "bitrate": "135033",
      "init": "0-738",
      "url": "https://r1---sn-npoe7ne6.googlevideo.com/videoplayback?expire=1637316051&ei=cyGXYbrWEr6L9fwP0JuqyAM&ip=180.244.7.97&id=o-AN5_ndJiz7v7FbAdhORldKJjHAoE5dAfm8JO59de7FKl&itag=160&source=youtube&requiressl=yes&mh=_m&mm=31%2C26&mn=sn-npoe7ne6%2Csn-30a7rn7l&ms=au%2Conr&mv=m&mvi=1&pl=23&initcwndbps=550000&vprv=1&mime=video%2Fmp4&gir=yes&clen=10136982&dur=1165.800&lmt=1608432002286721&mt=1637293979&fvip=3&keepalive=yes&fexp=24001373%2C24007246&c=ANDROID&txp=5535432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhALECP_mGsuYkFXqFVSr1CJOAg1eQHhdJ0Nakcdz1yLbDAiEAn1z7Ty56CsD7deYVMyRoAEPXVjyi501uyHhU2eQDXec%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIhALPOV9lqCO1hnRTUiJnVVCH6dCBMPuoaJDzNr7_Nt7T8AiA_celn8IFyFTmmZt-ewQzJQ27po_tQtrO2oULTmI7zhA%3D%3D&host=r1---sn-npoe7ne6.googlevideo.com",
      "itag": "160",
      "type": "video/mp4; codecs=\"avc1.4d400c\"",
      "clen": "10136982",
      "lmt": "1608432002286721",
      "projectionType": "RECTANGULAR",
      "fps": 25,
      "container": "mp4",
      "encoding": "h264",
      "resolution": "144p",
      "qualityLabel": "144p"
    }

Audio streams (missing resolution and qualityLabel):

    {
      "index": "266-2267",
      "bitrate": "154874",
      "init": "0-265",
      "url": "https://r1---sn-npoe7ne6.googlevideo.com/videoplayback?expire=1637316051&ei=cyGXYbrWEr6L9fwP0JuqyAM&ip=180.244.7.97&id=o-AN5_ndJiz7v7FbAdhORldKJjHAoE5dAfm8JO59de7FKl&itag=251&source=youtube&requiressl=yes&mh=_m&mm=31%2C26&mn=sn-npoe7ne6%2Csn-30a7rn7l&ms=au%2Conr&mv=m&mvi=1&pl=23&initcwndbps=550000&vprv=1&mime=audio%2Fwebm&gir=yes&clen=19527311&dur=1165.841&lmt=1583995696292929&mt=1637293979&fvip=3&keepalive=yes&fexp=24001373%2C24007246&c=ANDROID&txp=5431432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhAISc-UK7DXB8E48O9wu5NjJfk-sPP0-8xaMivVQpj3gEAiEAmIVgSzCUHzQn0IcBE-e5JBXh-0t1jX6BOmPM-KUyGx0%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIhALPOV9lqCO1hnRTUiJnVVCH6dCBMPuoaJDzNr7_Nt7T8AiA_celn8IFyFTmmZt-ewQzJQ27po_tQtrO2oULTmI7zhA%3D%3D&host=r1---sn-npoe7ne6.googlevideo.com",
      "itag": "251",
      "type": "audio/webm; codecs=\"opus\"",
      "clen": "19527311",
      "lmt": "1583995696292929",
      "projectionType": "RECTANGULAR",
      "fps": 30,
      "container": "webm",
      "encoding": "opus"
    }

AV1 video stream (missing fps, container, encoding, resolution and qualityLabel):

    {
      "index": "700-3587",
      "bitrate": "2401791",
      "init": "0-699",
      "url": "https://r1---sn-npoe7ne6.googlevideo.com/videoplayback?expire=1637316051&ei=cyGXYbrWEr6L9fwP0JuqyAM&ip=180.244.7.97&id=o-AN5_ndJiz7v7FbAdhORldKJjHAoE5dAfm8JO59de7FKl&itag=399&source=youtube&requiressl=yes&mh=_m&mm=31%2C26&mn=sn-npoe7ne6%2Csn-30a7rn7l&ms=au%2Conr&mv=m&mvi=1&pl=23&initcwndbps=550000&vprv=1&mime=video%2Fmp4&gir=yes&clen=193926436&dur=1165.800&lmt=1614073248555278&mt=1637293979&fvip=3&keepalive=yes&fexp=24001373%2C24007246&c=ANDROID&txp=5531432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAIqDPG_hn0V6zNqy9JSiDaXv3irEZpLiGsAc04mu632vAiBDtiJw2WEdLLrybl8FpVhRLghbBvJnLexvzyS15uOV8g%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIhALPOV9lqCO1hnRTUiJnVVCH6dCBMPuoaJDzNr7_Nt7T8AiA_celn8IFyFTmmZt-ewQzJQ27po_tQtrO2oULTmI7zhA%3D%3D&host=r1---sn-npoe7ne6.googlevideo.com",
      "itag": "399",
      "type": "video/mp4; codecs=\"av01.0.08M.08\"",
      "clen": "193926436",
      "lmt": "1614073248555278",
      "projectionType": "RECTANGULAR"
    }

Logs

Screenshots

Additional context

SamantazFox commented 2 years ago

This is because the data we return is directly what youtube provides, hence the API instability. The API needs a proper lifting, and that's why I'm marking this as an enhancement.