getsong

package module
v0.7.9-0...-0f718a7 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: MIT Imports: 23 Imported by: 0

README

getsong

go report card godocs

This is a simple library that utilizes the rylio/ytdl YouTube downloader and ffmpeg to get almost any mp3 of a song that you want to listen to. I wrote this so I could download mp3s of my favorite Spotify playlists.

Disclaimer: Downloading copyright songs may be illegal in your country. This tool is for educational purposes only and was created only to show how YouTubes's API can be used to download music. Please support the artists by buying their music.

Install

go get -u github.com/prologic/getsong/...

Usage

The aim of this library to have a low (or zero) false positive rate, so it works best when the entered title + artist are spelled correctly.

Use as a program
$ getsong 'Getting in Tune' 'The Who'
Downloading 'Getting in Tune by The Who (W6-3rnD7FSc).webm'...
 524289 / 524289 [==========================] 100.00% 
...converting to mp3...
Downloaded 'Getting in Tune by The Who (W6-3rnD7FSc).mp3'
Use as a library
// download "True" by "Spandau Ballet"
fname, err := getsong.GetSong("True", "Spandau Ballet")
if err == nil {
    fmt.Printf("Downloaded '%s'\n", fname)
}

Contributing

Pull requests are welcome. Feel free to...

  • Revise documentation
  • Add new features
  • Fix bugs
  • Suggest improvements

License

MIT

Documentation

Index

Constants

View Source
const CHUNK_SIZE = 524288

Variables

View Source
var OptionShowProgressBar bool

Functions

func ConvertToMp3

func ConvertToMp3(filename string) (err error)

FFmpegConvertToMp3 uses ffmpeg to convert to mp3

func DownloadFromYouTube

func DownloadFromYouTube(downloadedFilename string, downloadURL string) (err error)

DownloadFromYouTube will use the download URL to get it in parallel and save it as the downloadedFilename.

func GetMusicVideoID

func GetMusicVideoID(title string, artist string, notid ...string) (id string, err error)

GetMusicVideoID returns the ids for a specified title and artist

func GetSong

func GetSong(url string, option ...Options) (savedFilename string, err error)

GetSong requires passing in a video url.

func ParseDurationString

func ParseDurationString(s string) (milliseconds int64)

ParseDurationString 00:07:50.01 into milliseconds

func SearchSong

func SearchSong(title string, artist string, option ...Options) (savedFilename string, err error)

SearchSong requires passing in the options which requires at least a title. If an Artist is provided, it will save it as Artist - Title.mp3 You can also pass in a duration, and it will try to find a video that is within 10 seconds of that duration.

func SetID3Tags

func SetID3Tags(fname, artist, title, yt string) (err error)

Types

type Options

type Options struct {
	ShowProgress  bool
	Debug         bool
	DoNotDownload bool
	Filename      string
}

Options allow you to set the artist, title and duration to find the right song. You can also set the progress and debugging for the program execution.

type YouTubeInfo

type YouTubeInfo struct {
	Title       string
	Description string
	ID          string
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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