-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.0.1: support for custom instances, vimeoDash option
- Loading branch information
PrincessMortix
committed
Mar 30, 2024
1 parent
fe7d9a7
commit 8f022c5
Showing
3 changed files
with
184 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,66 @@ | ||
# gobalt | ||
Go library for cobalt.tools | ||
<div align="center"> | ||
<a href="https://pkg.go.dev/lostdusty/gobalt" title="Go API Reference" rel="nofollow"><img src="https://img.shields.io/badge/go-documentation-blue.svg?style=for-the-badge" alt="Go API Reference"></a> | ||
<a href="https://github.com/lostdusty/gobalt/releases/lastest" title="Latest Release" rel="nofollow"><img src="https://img.shields.io/github/v/release/lostdusty/gobalt?include_prereleases&style=for-the-badge" alt="Latest Release"></a> | ||
|
||
[![Static Badge](https://img.shields.io/badge/cobalt_discord-join-blue?style=for-the-badge&logo=discord)](https://discord.gg/pQPt8HBUPu) | ||
[![Static Badge](https://img.shields.io/badge/supported-services-0077b6?style=for-the-badge&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NDAgNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNS4xIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0%2BPHBhdGggZD0iTTU3OS44IDI2Ny43YzU2LjUtNTYuNSA1Ni41LTE0OCAwLTIwNC41Yy01MC01MC0xM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|
||
Gobalt provides a way to communicate with [cobalt.tools](https://cobalt.tools) using Go. To use it in your projects, simply run this command: | ||
```sh | ||
go get https://github.com/lostdusty/gobalt | ||
``` | ||
|
||
## Usage | ||
First, make sure you call `gobalt.CreateDefaultSettings()` to create the `Settings` struct with default values, then set an url. | ||
|
||
```go | ||
//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](https://github.com/wukko/cobalt/blob/current/docs/api.md#response-body-variables-1). | ||
|
||
Example code: | ||
```go | ||
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: | ||
```go | ||
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 | ||
*/ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module github.com/princessmortix/gobalt | ||
module github.com/lostdusty/gobalt | ||
|
||
go 1.21.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters