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 ¶
NewFormatter inizializes a Formatter with "[^a-zA-Z0-9]+" as compiled regular expression and with delimiters passed as arguments.
func (Formatter) FormatFile ¶
FormatFile edits the file downloaded by setting the artist and title metadata.
func (Formatter) FormatTitle ¶
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 ¶
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.