Git Product home page Git Product logo

gobalt's Introduction

Go API Reference Latest Release

Static Badge Static Badge

gobalt

Gobalt provides a way to communicate with cobalt.tools using Go. To use it in your projects, simply run this command:

go get github.com/lostdusty/gobalt

Usage

First, make sure you call gobalt.CreateDefaultSettings() to create the Settings struct with default values, then set an url.

//Creates a Settings struct with default values, and save it to downloadMedia variable.
downloadMedia := gobalt.CreateDefaultSettings()

//Sets the URL, you MUST set one before downloading the media.
downloadMedia.Url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"

//After changing the url, Do() will make the necessary requests to cobalt to download your media
destination, err := gobalt.Do(downloadMedia)
if err != nil {
    //Handle errors here
}

//Prints out the url from cobalt to download the requested media.
fmt.Println(destination.URL)
//Output example: https://us4-co.wuk.sh/api/stream?t=wTn-71aaWAcV2RBejNFNV&e=1711777798864&h=fMtwwtW8AUmtTLB24DGjJJjrq1EJDBFaCDoDuZpX0pA&s=_YVZhz8fnzBBKKo7UZmGWOqfe4wWwH5P1azdgBqwf-I&i=6tGZqAXbW08_6KmAiLevZA

Features

Server info

You can query information about any cobalt server by using CobaltServerInfo(apiurl). This will return a ServerInfo struct with this info.

Example code:

server, err := gobalt.CobaltServerInfo(gobalt.CobaltApi)
if err != nil {
	 //Handle the error here
}
fmt.Printf("Downloading from %v!\n", server.URL)
//Output: Downloading from https://us4-co.wuk.sh/!

Use/Query other cobalt instances

Using GetCobaltInstances() fetches a community maintaned list of third-party cobalt instances ran by the community, except for *-co.wuk.sh, none of them are "official" cobalt instances. Use them if you can't download from the main instance for whatever reason.

Example:

cobalt, err := gobalt.GetCobaltInstances()
if err != nil { 
    //Handle errors here
}
fmt.Printf("Found %v online cobalt servers: ", len(cobalt))
for _, value := range cobalt {
	fmt.Printf("%v, ", value.URL)
}
/* Output: 
* Found 8 online cobalt servers: co.wuk.sh, cobalt-api.hyper.lol, cobalt.api.timelessnesses.me, api-dl.cgm.rs, cobalt.synzr.space, capi.oak.li, co.tskau.team, api.co.rooot.gay
*/

gobalt's People

Contributors

lostdusty avatar sardonyx001 avatar

Stargazers

Rikiub% avatar  avatar ini avatar Daniel R. Alvarenga avatar Sr. Carvalho avatar Khyernet avatar Illia Diadenchuk avatar Sarah avatar  avatar Mikhail Serebryakov avatar Bram avatar Giiki_S2 avatar Mayhm avatar

Watchers

 avatar

Forkers

sardonyx001

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.