youcubeapi
Lua library for accessing YouCub's API
_API_VERSION = "0.0.0-poc.1.0.0" | "Metadata" - YouCube API Version |
---|---|
_VERSION = "0.0.0-poc.1.4.2" | "Metadata" - Library Version |
_DESCRIPTION | "Metadata" - Description |
_URL | "Metadata" - Homepage / Url |
_LICENSE = "GPL-3.0" | "Metadata" - License |
API | "wrapper" for accessing YouCub's API |
AudioDevice | Abstraction for Audio Devices |
Speaker | AudioDevice from a Speaker |
Tape | AudioDevice from a Computronics tape_drive |
Base64 | Base64 functions |
Filler | Abstract object for filling a Buffer |
AudioFiller | Filler for Audio |
VideoFiller | Filler for Video |
Buffer | Buffers Data |
play_vid(buffer) | Create's a new Buffer instance. |
reset_term() |
- _API_VERSION = "0.0.0-poc.1.0.0"
"Metadata" - YouCube API Version
- _VERSION = "0.0.0-poc.1.4.2"
"Metadata" - Library Version
- _DESCRIPTION:
string
"Metadata" - Description
- _URL:
string
"Metadata" - Homepage / Url
- _LICENSE = "GPL-3.0"
"Metadata" - License
- API
"wrapper" for accessing YouCub's API
Usage
Example:
local youcubeapi = require("youcubeapi") local api = youcubeapi.API.new() api:detect_bestest_server() api:request_media(url) local data = api.websocket.receive()
- AudioDevice
Abstraction for Audio Devices
- Speaker
AudioDevice
from a SpeakerUsage
Example:
local youcubeapi = require("youcubeapi") local speaker = peripheral.find("speaker") local audiodevice = youcubeapi.Speaker.new(speaker)
- Tape
AudioDevice
from a Computronics tape_driveUsage
Example:
local youcubeapi = require("youcubeapi") local tape_drive = peripheral.find("tape_drive") local audiodevice = youcubeapi.Tape.new(tape_drive)
- Base64
Base64 functions
- Filler
Abstract object for filling a
Buffer
- AudioFiller
Filler
for Audio- VideoFiller
Filler
for Video- Buffer
Buffers Data
- play_vid(buffer)
Create's a new Buffer instance.
Based on sanjuuni/raw-player.lua and sanjuuni/websocket-player.lua
Parameters
- buffer
Buffer
filled with frames
- buffer
- reset_term()
Types
API
"wrapper" for accessing YouCub's API
Usage
Example:
local youcubeapi = require("youcubeapi") local api = youcubeapi.API.new() api:detect_bestest_server() api:request_media(url) local data = api.websocket.receive()
- API.new(websocket)
Create's a new API instance.
Parameters
- websocket Websocket The websocket.
Returns
API
instance
- API:detect_bestest_server(_server, _verbose)
Connects to a YouCub Server
Parameters
- _server
- _verbose
- API.receive(filter)
Receive data from The YouCub Server
Parameters
- filter
string
action filter
Returns
table
retval data
- filter
- API.send(data)
Send data to The YouCub Server
Parameters
- data
table
data to send
- data
- API.get_chunk(chunkindex, id)
Request a
16 * 1024
bit chunkParameters
- chunkindex
number
The chunkindex - id
string
Media id
Returns
bytes
chunk16 * 1024
bit chunk
- chunkindex
- API.get_vid(line, id, width, height)
Get 32vid
Parameters
- line
number
The line to return - id
string
Media id - width
number
Video width - height
number
Video height
Returns
string
line one line of the given 32vid
- line
- API.request_media()
Request media @tparam string url Url or Search Term
Returns
table
json response
- API.handshake()
Handshake - get Server capabilities and version
Returns
table
json response
AudioDevice
Abstraction for Audio Devices
- AudioDevice.new(object)
Create's a new AudioDevice instance.
Parameters
- object
table
Base values
Returns
AudioDevice
instance
- object
AudioFiller
Filler
for Audio
- AudioFiller.new(youcubeapi, id)
Create's a new AudioFiller instance.
Parameters
Returns
AudioFiller
|Filler
instance
Base64
Base64 functions
- Base64.decode(str)
Decode base64 string
Parameters
- str
string
base64 string
Returns
string
string decoded string
- str
Buffer
Buffers Data
- Buffer.new(filler, size)
Create's a new Buffer instance.
Parameters
- filler
Filler
filler instance - size
number
buffer limit
Returns
Buffer
instance
- filler
Filler
Abstract object for filling a Buffer
- Filler.new()
Create's a new Filler instance.
Returns
Filler
instance
Speaker
AudioDevice
from a Speaker
Usage
Example:
local youcubeapi = require("youcubeapi") local speaker = peripheral.find("speaker") local audiodevice = youcubeapi.Speaker.new(speaker)
- Speaker.new(speaker)
Create's a new Tape instance.
Parameters
- speaker
speaker
The speaker
Returns
AudioDevice
|Speaker
instance
- speaker
Tape
AudioDevice
from a Computronics tape_drive
Usage
Example:
local youcubeapi = require("youcubeapi") local tape_drive = peripheral.find("tape_drive") local audiodevice = youcubeapi.Tape.new(tape_drive)
- Tape.new(tape)
Create's a new Tape instance.
Parameters
- tape
tape
The tape_drive
Returns
AudioDevice
|Tape
instance
- tape
VideoFiller
Filler
for Video
- VideoFiller.new(youcubeapi, id, width, height)
Create's a new VideoFiller instance.
Parameters
Returns
VideoFiller
|Filler
instance