New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

googlevideo

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

googlevideo

A set of utilities for working with Google Video APIs.

1.0.0
Source
npm
Version published
Weekly downloads
792
-74.37%
Maintainers
0
Weekly downloads
 
Created
Source

What Is This?

This is a collection of utilities for working with Google Video APIs, with a primary focus on UMP.

  • Video Streaming Protos
  • UMP (Parser)
  • ServerAbrStream (SABR Client)
  • ChunkedDataBuffer (Buffer Manager)

The protobuf definitions were extracted from YouTube's Android and iOS clients, and the UMP parser and buffer manager are based on the implementation currently found on youtube.com.

Usage examples can be found here.

Installation

npm install github:LuanRT/googlevideo

Basic Usage

import GoogleVideo, { PART, Protos } from 'googlevideo';

const streamingUrl = 'https://abcd--a.googlevideo.com/videoplayback?...';

const response = await fetch(streamingUrl, { method: 'POST' });

const arrayBuffer = await response.arrayBuffer();

const dataBuffer = new GoogleVideo.ChunkedDataBuffer();
dataBuffer.append(new Uint8Array(arrayBuffer));

const googUmp = new GoogleVideo.UMP(dataBuffer);

googUmp.parse((part) => {
  switch (part.type) {
    case PART.MEDIA_HEADER: {
      console.log('[MediaHeader]:', Protos.MediaHeader.decode(part.data.chunks[0]));
      break;
    }
    case PART.MEDIA: {
      const headerId = part.data.getUint8(0);
      const streamData = part.data.split(1).remainingBuffer;
      console.log('[Media]:', `Header ID: ${headerId}`, `length: ${streamData.getLength()}`);
      break;
    }
    case PART.MEDIA_END: {
      const headerId = part.data.getUint8(0);
      console.log('[MediaEnd]:', `Header ID: ${headerId}`);
      break;
    }
    default:
      console.log('Unhandled part:', part.type);
      break;
  }
});

For more advanced examples, including scenarios beyond just parsing responses, check out the examples.

License

Distributed under the MIT License.

(back to top)

Keywords

UMP

FAQs

Package last updated on 24 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts