youGO

package module
v0.0.0-...-1d2c9da Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

README

youGO

A tool for downloading music from youtube playlists and videos.

This project is a wrapper of the famous youtube-dl, but with a new feature that tries to detect the name and the artist of the song from the video's title and put them in the file's metadata.

Requirements:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloader

type Downloader struct {
	Path      string
	YtService *youtube.Service
}

Downloader contains the path where to store the files and a reference to the youtube service used to retreive video information.

func NewDownloader

func NewDownloader(path string) (Downloader, error)

NewDownloader initializes a new instance of Downloader. If the folders songs and formatted don't exist they will be created.

func (*Downloader) DownloadPlaylistAndFormat

func (d *Downloader) DownloadPlaylistAndFormat(playlistID string, tFormatter TitleFormatter)

DownloadPlaylistAndFormat downloads all the videos in the playlist. The downloaded files will be ignored if the TitleFormatter fails to parse the title, otherwise their will be moved to formatted folder.

func (*Downloader) DownloadVideoAndFormat

func (d *Downloader) DownloadVideoAndFormat(videoID string, tFormatter TitleFormatter) error

DownloadVideoAndFormat downloads the given video bi its ID. The downloaded file will be ignored if the TitleFormatter fails to parse the title, otherwise the file will be moved to formatted folder.

type ErrorProblematicName

type ErrorProblematicName struct {
	// contains filtered or unexported fields
}

func NewErrorProblematicName

func NewErrorProblematicName(message string) *ErrorProblematicName

func (*ErrorProblematicName) Error

func (err *ErrorProblematicName) Error() string

type ErrorServiceCreation

type ErrorServiceCreation struct {
	// contains filtered or unexported fields
}

func NewErrorServiceCreation

func NewErrorServiceCreation(message string) *ErrorServiceCreation

func (*ErrorServiceCreation) Error

func (err *ErrorServiceCreation) Error() string

type ErrorWrongPlaylistID

type ErrorWrongPlaylistID struct {
	// contains filtered or unexported fields
}

func NewErrorWrongPlaylistId

func NewErrorWrongPlaylistId(message string) *ErrorWrongPlaylistID

func (*ErrorWrongPlaylistID) Error

func (err *ErrorWrongPlaylistID) Error() string

type FileFormatter

type FileFormatter interface {
	FormatFile(SongData)
}

FileFormatter is the interface that contains the FormatFile method. FormatFile edits the metadata tags of the file downloaded.

type Formatter

type Formatter struct {

	// Slice that contains all the characters for identifying if the song has more than an artist, such as "ft." and "&".
	ArtistDelimiters []string

	// A Regexp is a compiled regular expression.
	// The regular expression will remove all non-alphanumeric characters.
	Regexp *regexp.Regexp
}

Formatter implements TitleFormatter and is used to extract the title and artist of the song from the video title. It also update the file with the title and artist metadata

func NewFormatter

func NewFormatter(delimiters ...string) (Formatter, error)

NewFormatter inizializes a Formatter with "[^a-zA-Z0-9]+" as compiled regular expression and with delimiters passed as arguments.

func (Formatter) FormatFile

func (f Formatter) FormatFile(song SongData, path string) error

FormatFile edits the file downloaded by setting the artist and title metadata.

func (Formatter) FormatTitle

func (f Formatter) FormatTitle(video VideoData) SongData

FormatTitle retreives the title and the artist by parsing the video title. If the name of the video is diffucult to parse, FormatTitle returns SongData with empty Artist and Title parameters

type SongData

type SongData struct {
	Artist string

	Title string

	// CorrectedName is set to true if the title of the video doesn't contain any peculiar characters.
	CorrectedName bool

	Video VideoData
}

SongData contains all the information about the song downloaded.

type TitleFormatter

type TitleFormatter interface {
	FormatTitle(VideoData) SongData
}

TitleFormatter is the interface that contains the FormatTitle method. FormatTitle tries to obtains the artist and title of the song by parsing the title of the video.

type VideoData

type VideoData struct {
	Title string

	VideoID string
}

VideoData represents the youtube video you want to download. It contains the title of the video and its video ID.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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