soundcloud

package
v1.25.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: OSL-3.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsURL

func IsURL(url string, testMobile, testFirebase bool) bool

IsURL returns true if the provided url is a valid SoundCloud URL

Types

type Client added in v1.25.0

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

func New

func New() (*Client, error)

New returns a pointer to a new SoundCloud API struct. First fetch a SoundCloud client ID. This algorithm is adapted from https://www.npmjs.com/package/soundcloud-key-fetch. The basic notion of how this function works is that SoundCloud provides a client ID so its web app can make API requests. This client ID (along with other intialization data for the web app) is provided in a JavaScript file imported through a <script> tag in the HTML. This function scrapes the HTML and tries to find the URL to that JS file, and then scrapes the JS file to find the client ID.

func (Client) GetDownloadURL added in v1.25.0

func (sc Client) GetDownloadURL(url string, streamType string) (string, error)

GetDownloadURL retuns the URL to download a track. This is useful if you want to implement your own downloading algorithm. If the track has a publicly available download link, that link will be preferred and the streamType parameter will be ignored. streamType can be either "hls" or "progressive", defaults to "progressive"

type GetTrackInfoOptions

type GetTrackInfoOptions struct {
	ID                  []int64
	PlaylistID          int64
	PlaylistSecretToken string
	URL                 string
}

GetTrackInfoOptions can contain the URL of the track or the ID of the track. PlaylistID and PlaylistSecretToken are necessary to retrieve private tracks in private playlists.

type Track

type Track struct {
	Downloadable     bool
	HasDownloadsLeft bool   `json:"has_downloads_left"`
	CreatedAt        string `json:"created_at"`
	Description      string
	DurationMS       int64 `json:"duration"`
	FullDurationMS   int64 `json:"full_duration"`
	ID               int64
	Kind             string
	// Media contains an array of transcoding for a track
	Media struct {
		// Transcoding contains information about the transcoding of a track
		Transcodings []struct {
			// TranscodingFormat contains the protocol by which the track is
			// delivered ("progressive" or "HLS"), and the mime type of the track
			Format struct {
				MimeType string `json:"mime_type"`
				Protocol string
			}
			Preset  string
			Snipped bool
			URL     string
		}
	}
	Permalink     string
	PermalinkURL  string `json:"permalink_url"`
	PlaybackCount int64  `json:"playback_count"`
	SecretToken   string `json:"secret_token"`
	Streamable    bool
	Title         string
	URI           string
	WaveformURL   string `json:"waveform_url"`
}

Track represents the JSON response of a track's info

Jump to

Keyboard shortcuts

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