getsong

package module
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: MIT Imports: 23 Imported by: 1

README

getsong

travis go report card coverage godocs

This is a simple library that utilizes the rylio/ytdl YouTube downloader and ffmpeg to get almost any m4a of a song that you want to listen to. I wrote this so I could download m4as 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/schollz/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 m4a...
Downloaded 'Getting in Tune by The Who (W6-3rnD7FSc).m4a'
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 ConvertToM4a added in v0.7.9

func ConvertToM4a(filename string) (err error)

ConvertToM4a uses ffmpeg to convert to m4a

func DownloadFromYouTube added in v0.3.0

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 added in v0.3.0

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(title string, artist string, option ...Options) (savedFilename string, err error)

GetSong 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 ParseDurationString added in v0.7.6

func ParseDurationString(s string) (milliseconds int64)

ParseDurationString 00:07:50.01 into milliseconds

func SetID3Tags added in v0.4.0

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