vcat

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 10 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")
	ErrUnsupportedLanguage error = errors.New("given language is not supported 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 GetAvailableLanguages

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

GetAvailableLanguages returns all valid transcript languages available for the specified url.

The returned language names (not codes) could be translated to the language in your location. I.e. if the process calling this function has a Spanish IP, the names of the available langugues are going to be in Spanish.

type TranscriptTextChunk added in v0.1.0

type TranscriptTextChunk 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
}

type Video added in v0.0.2

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

func GetVideo added in v0.0.2

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

GetVideo returns the whole video data, including the transcript, in English.

An alias for `vcat.GetVideoWithLanguage(url, "en")`

func GetVideoWithLanguage added in v0.1.0

func GetVideoWithLanguage(url, languageCode string) (*Video, error)

GetVideoWithLanguage returns the whole video data, including the transcript in a specified language. Do pass in the language code, not the name of the language. E.g. "en", not "English".

Make sure the provided language is supported by asserting it is available on the content. You can use `vcat.GetAvailableLanguages`.

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

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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