ytsearch

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: AGPL-3.0 Imports: 6 Imported by: 1

README

A go (golang) library to search videos in YouTube.

Installation

go get github.com/AnjanaMadu/YTSearch

Usage

package main

import (
    "fmt",
    "github.com/AnjanaMadu/YTSearch"
)

func main() {
    results, err := ytsearch.Search("faded")
    if err != nil {
        panic(err)
    }

    for _, result := range results {
        fmt.Printf("Title: %s\nVideo Id: %s\n\n", result.Title, result.VideoId)
    }
}

Contributing

  • Fork the repository
  • Create a branch
  • Commit your changes
  • Push your branch to your fork
  • Create a new issue or pull request

License

AGPL-3.0, see LICENSE for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetResults

func GetResults(q string) []map[string]interface{}

Types

type YTSearchResult

type YTSearchResult struct {
	// Title of the video
	Title string `json:"title"`

	// Video ID
	// https://www.youtube.com/watch?v=<VIDEO_ID>
	VideoId string `json:"videoId"`

	// Published time
	// Example: 1 month ago
	PublishTime string `json:"publishTime"`

	// Channel name
	Channel string `json:"channel"`

	// Channel ID
	// Example: UC-lHJZR3Gqxm24_Vd_AJ5Yw
	ChannelId string `json:"channelId"`

	// View count in short form
	// Example: 1.2M
	Views string `json:"views"`

	// Duration in long form
	// Example: 1 hour, 2 minutes
	Duration string `json:"duration"`

	// Best quality thumbnail
	Thumbnail string `json:"thumbnail"`
}

func ParseData

func ParseData(data map[string]interface{}) (YTSearchResult, error)
func Search(q string) ([]YTSearchResult, error)

Jump to

Keyboard shortcuts

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