youtubesearch

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2025 License: MIT Imports: 7 Imported by: 0

README

youtubesearch

Inspired by the youtube_search Python library. This library allows you to search for youtube videos without using the API.

Example

// Use without timeout
results, err := youtubesearch.Search("Rob Pike Go speech", 0)

// Use with timeout of 3 seconds
results, err := youtubesearch.Search("Rob Pike Go speech", time.Duration(3_000_000_000))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type VideoData

type VideoData struct {
	ID          string   // Youtube ID for the Video
	Thumbnails  []string // List of urls for the video thumbnails
	Title       string   // Title of the video.
	LongDesc    string   // Description of the video.
	Channel     string   // ID of the channel that posted the video.
	Duration    string   // Duration of the video.
	Views       string   // Number of views the video has.
	PublishTime string   // Time since the video was published e.g 7 years ago.
	URLSuffix   string   // URL path and query for the video. Meant to be concatenated with "https://youtube.com"
}

Structure of a youtube video search result.

func Search(query string, timeout time.Duration) ([]VideoData, error)

Search executes a search request to youtube to retrieve video results. The results are returned based on the query. The timeout (in nanoseconds) determines the maximum time this function should execute. If the taken exceeds the timeout, the request is cancelled and an error is returned. It is assumed that there is no timeout when the timeout parameter is set to zero or a negative number.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL