Skip to content

Future Request: Add a typed Metadata dataclass populated from videoDetails #605

Description

@kaya70875

Is your feature request related to a problem? Please describe.
The innertube response already includes a videoDetails object with a lot of useful metadata, not just the title. I think the API should expose this as a typed metadata field on Transcript and FetchedTranscript.

Describe the solution you'd like
I suggest creating a Metadata dataclass and populating it from innertube_data["videoDetails"].

Example videoDetails payload:

{
    'videoId': '2dqSV5Sk05U',
    'title': 'Project Threshold…',
    'lengthSeconds': '2247',
    'keywords': ['gaming', 'caseoh', 'caseohgames', 'case', 'funny', 'streamer', 'horror', 'horror gaming', 'scary', 'jumpscare'],
    'channelId': 'UC63anZxfVGHUEmfBAf5w7pw',
    'isOwnerViewing': False,
    'shortDescription': 'CaseOh X Starforge ...',
    'isCrawlable': True,
    'thumbnail': {
        'thumbnails': [
            {'url': 'https://i.ytimg.com/vi/2dqSV5Sk05U/default.jpg', 'width': 120, 'height': 90},
            {'url': 'https://i.ytimg.com/vi/2dqSV5Sk05U/mqdefault.jpg', 'width': 320, 'height': 180},
            {'url': 'https://i.ytimg.com/vi/2dqSV5Sk05U/hqdefault.jpg', 'width': 480, 'height': 360},
            {'url': 'https://i.ytimg.com/vi/2dqSV5Sk05U/sddefault.jpg', 'width': 640, 'height': 480}
        ]
    },
    'allowRatings': True,
    'viewCount': '327493',
    'author': 'CaseOh',
    'isPrivate': False,
    'isUnpluggedCorpus': False,
    'isLiveContent': False,
    'isTvfilmVideo': False
}

Proposed dataclass fields:

@dataclass
class Metadata:
    videoId: str
    title: str
    lengthSeconds: str
    keywords: list[str]
    channelId: str
    isOwnerViewing: bool
    shortDescription: str
    isCrawlable: bool
    thumbnail: dict
    allowRatings: bool
    viewCount: str
    author: str
    isPrivate: bool
    isUnpluggedCorpus: bool
    isLiveContent: bool
    isTvfilmVideo: bool

Suggested behavior:

  • Transcript.metadata and FetchedTranscript.metadata should be instances of Metadata
  • translate() should preserve the same metadata
  • fetching behavior should not require any extra requests
  • This not requires any breaking changes.

I can easily implement this feature if you find it useful.

What do you guys think ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions