vcat

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 9 Imported by: 1

README

vcat

Vcat helps you save YouTube video transcriptions without the need of an API key. Just like cat(1), but for YouTube videos.

Usage

Printing out the transcription JSON to stdout.
> vcat -u "url" --pretty
# {
#   "data": [
#     {
#       "start": "00:00:01",
#       "end": "00:00:04",
#       "duration": 3.78,
#       "text": "more recent thoughts on crypto after"
#     },
#     {
#       "start": "00:00:03",
#       "end": "00:00:07",
#       "duration": "4.981",
#       "text": "Banks not working not really"
#     },
#     ...
#}
List available transcriptions:
> vcat -l -u "url"
# [{Afrikaans af} {Akan ak} {Albanian sq} {Amharic am} {Arabic ar} {Armenian hy}
# {Assamese as} {Aymara ay} {Azerbaijani az} {Bangla bn} {Basque eu} {Belarusian be}
# {Bhojpuri bho} {Bosnian bs} {Bulgarian bg} {Burmese my} {Catalan ca} {Cebuano ceb}
# {Chinese (Simplified) zh-Hans} {Chinese (Traditional) zh-Hant} {Corsican co} {Croatian hr}
# {Czech cs} {Danish da} {Divehi dv} {Dutch nl} {English en} {Esperanto eo} {Estonian et}
# {Ewe ee} {Filipino fil} {Finnish fi} {French fr} {Galician gl} {Ganda lg} {Georgian ka}
# {German de} {Greek el} {Guarani gn} {Gujarati gu} {Haitian Creole ht} {Hausa ha}
# {Hawaiian haw} {Hebrew iw} {Hindi hi} {Hmong hmn} {Hungarian hu} {Icelandic is}
# {Igbo ig} {Indonesian id} {Irish ga} {Italian it} {Japanese ja} {Javanese jv} {Kannada kn}
# ...
# ]
Specify a different transcription language:
> vcat --language="cs" -u "url"
Save to file:
> vcat -o tmp/file.json -u "url"
Work with a CSV:
> vcat -u "url" --format csv
# start,end,duration,text
# 00:00:01,00:00:04,3.78,more recent thoughts on crypto after
# 00:00:03,00:00:07,4.98,Banks not working not really

Install

From source
> git clone git@github.com:hum/vcat.git
> cd vcat
> make build
> ./bin/vcat -u [URL]
With Go Install
> go install github.com/hum/vcat/cmd/vcat@latest
> vcat -u [URL]

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTranscriptNotFound error = errors.New("no trancript found for given url")
	ErrCaptionsNotFound   error = errors.New("no captions found for url")
)

Functions

This section is empty.

Types

type AvailableLanguage

type AvailableLanguage struct {
	// Full name of the language translation, e.g. "English"
	Name string `json:"name"`

	// Code representation of the language's name, e.g. "en"
	Code string `json:"code"`
}

AvailableLanguage holds the available translation data of transcripts provided by YouTube

func GetAvailableCaptionLanguages added in v0.0.2

func GetAvailableCaptionLanguages(url string) ([]AvailableLanguage, error)

type TextChunk added in v0.0.2

type TextChunk struct {
	Start    string  `json:"start"`    // Start time of the text
	End      string  `json:"end"`      // End time of the text
	Duration float64 `json:"duration"` // Approximate duration of the speech in `text`
	Text     string  `json:"text"`     // The text being said in the current time bucket
}

func GetVideoTranscript added in v0.0.2

func GetVideoTranscript(url string, language string) ([]TextChunk, error)

type Video added in v0.0.2

type Video struct {
	Metadata   *VideoMetadata `json:"metadata"`
	Transcript []TextChunk    `json:"transcript"`
}

func GetVideo added in v0.0.2

func GetVideo(url string) (*Video, error)

func GetVideoWithTranscript added in v0.0.2

func GetVideoWithTranscript(url string, language string) (*Video, error)

type VideoMetadata added in v0.0.2

type VideoMetadata struct {
	VideoId          string   `json:"videoId"`
	Title            string   `json:"title"`
	LengthSeconds    string   `json:"lengthSeconds"`
	Keywords         []string `json:"keywords"`
	ChannelId        string   `json:"channelId"`
	ShortDescription string   `json:"shortDescription"`
	Thumbnail        struct {
		Thumbnails []struct {
			Url    string `json:"url"`
			Width  int    `json:"width"`
			Height int    `json:"height"`
		} `json:"thumbnails"`
	} `json:"thumbnail"`
	ViewCount     string `json:"viewCount"`
	Author        string `json:"author"`
	IsPrivate     bool   `json:"isPrivate"`
	IsLiveContent bool   `json:"isLiveContent"`
}

VideoMetadata stores information related to the video, e.g. the title, or the thumbnails

func GetVideoMetadata added in v0.0.2

func GetVideoMetadata(url string) (*VideoMetadata, error)

Directories

Path Synopsis
cmd
vcat command

Jump to

Keyboard shortcuts

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