tombulled / innertube

Python Client for Google's Private InnerTube API. Works with YouTube, YouTube Music and more!
https://pypi.org/project/innertube/
MIT License
298 stars 20 forks source link

Missing params payload in Android player request causes "This video is unavailable" response #76

Open nosoop opened 3 months ago

nosoop commented 3 months ago

Hi; thanks for developing this library. As of the current tagged release (v2.1.16), the following code returns a video unavailable response:

import innertube

client = innertube.InnerTube("ANDROID")
data = client.player("dQw4w9WgXcQ")

Based on LuanRT/YouTube.js#624 and comparing the POST body against a known working payload it looks like the current working fix is to add a params field with a base64-encoded protobuf payload CgIQBg== as the value. The code below returns expected results:

import innertube
import innertube.enums

client = innertube.InnerTube("ANDROID")
data = client(
    innertube.enums.Endpoint.PLAYER,
    body={
        "videoId": "dQw4w9WgXcQ",
        "params": "CgIQBg==",
    },
)

I'm not sure where in the call chain would be appropriate to insert this fix and / or modify it for robustness; will leave that up to the author.