gotube

package module
v0.0.0-...-949c81c Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2018 License: MIT Imports: 12 Imported by: 2

README

gotube Go Report Card

Library meant to improve working with youtube api in Go

Installation

go get -u github.com/Aracki/gotube/...

Authorization

Document which explains how does OAuth 2.0 works for Mobile & Desktop Apps to access Google APIs: https://developers.google.com/youtube/v3/guides/auth/installed-apps

Steps for enabling Youtube API service:

  1. You need a Google Account to access the Google Developers Console, request an API key, and register your application.
  2. Create new project on https://console.developers.google.com
  3. Go to Credentials -> Create credentials -> OAuth client ID
    • Select Web Application
    • Authorized redirect URIs: http://localhost. (it is the endpoint to which the OAuth 2.0 server can send responses)
  4. Download secret.json file and save it to /etc/youtube/client_secret.json.
  5. Make sure YouTube Data API v3 is enabled.
  6. Start Go app.
  7. Stdout will print link. Open it up in your browser and select proper Youtube account
  8. It redirects you to the http://localhost/?state=state-token&code=[code]
  9. Paste the code from the URL to the shell.
  10. It will save credential file to: ~/.credentials/youtube-go-quickstart.json.
  11. Gotube initialized!

Documentation

Index

Constants

View Source
const (
	TempFileName = "all_songs"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Youtube

type Youtube struct {
	Service *youtube.Service
}

func New

func New() (Youtube, error)

New will read from config file than make youtube client and service according to that client returns pointer to youtube.Service

func (Youtube) ChannelInfo

func (yt Youtube) ChannelInfo(forUsername string) (string, error)

The getChannelInfo uses forUsername to get info (id, tittle, totalViews and description)

func (Youtube) GetAllPlaylists

func (yt Youtube) GetAllPlaylists() ([]model.Playlist, error)

Gets all playlists of current user - maxResult is set to 50 (default is 5) returns array of all playlists (id, name, count)

func (Youtube) GetAllVideos

func (yt Youtube) GetAllVideos() (vds []model.Video, err error)

Gets all the videos of all playlists of mine Different goroutines are appending the same vds slice; WaitGroup waits for all goroutines to finish

func (Youtube) WriteAllSongsToFile

func (yt Youtube) WriteAllSongsToFile() error

WriteAllSongsToFile goes through all playlists and write all songs to file it returns pointer to file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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