ytscrape

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

README

ytscrape

ytscrape is a YouTube scraper search library, with a REST API available at yt.mbaraa.xyz

Deployment status Go Report Card GoDoc

Contributing

IDK, it would be really nice of you to contribute, check the poorly written CONTRIBUTING.md for more info.

Roadmap

  • Search YouTube for Videos
  • Search YouTube for Channels
  • Search YouTube for Playlists
  • Search YouTube for Radios

Usage

import "github.com/mbaraa/ytscrape"

func main() {
    // results is of type []ytscrape.VideoResult
    results, err := ytscrape.Search("Volkswagon das auto")
    if err != nil {
        // handle error
    }
    // do something with the results
}

REST API Docs

Well there's only has a single endpoint:

  • GET /search: accepts a query q that has the search term, and responds with a body like this one when q=Lana del rey
{
  "id": "TdrL3QxjyVw",
  "title": "Lana Del Rey - Summertime Sadness (Official Music Video)",
  "url": "https://youtube.com/watch?v=TdrL3QxjyVw",
  "duration": 266,
  "thumbnail_src": "https://i.ytimg.com/vi/TdrL3QxjyVw/hq720.jpg",
  "views": 574902158,
  "uploader": {
    "title": "Lana Del Rey",
    "url": "https://www.youtube.com/channel/UCqk3CdGN_j8IR9z4uBbVPSg"
  }
}

Run REST API locally

  1. Clone the repo.
git clone https://github.com/mbaraa/ytscrape
  1. Run it with docker compose.
docker compose up
  1. Visit http://localhost:20256
  2. Don't ask why I chose this weird port.

Made with 🧉 by Baraa Al-Masri

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type VideoResult

type VideoResult struct {
	Id           string        `json:"id"`
	Title        string        `json:"title"`
	Url          string        `json:"url"`
	Duration     time.Duration `json:"duration"`
	ThumbnailUrl string        `json:"thumbnail_src"`
	Views        int64         `json:"views"`
	Uploader     struct {
		Title string `json:"title"`
		Url   string `json:"url"`
	} `json:"uploader"`
}

VideoResult contains attributes of a video from yt search.

func Search(q string) ([]VideoResult, error)

Search scraps YouTube and returns search results, and an occurring error.

Directories

Path Synopsis
cmd
api

Jump to

Keyboard shortcuts

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