snd

package
v0.0.0-...-77fffd6 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2014 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BASE_URL = "http://api.soundcloud.com"
)
View Source
const (
	SNDCLD_TIME_FORMAT = "2006/01/02 15:04:05 -0700"
)

Variables

This section is empty.

Functions

func ParseFiletype

func ParseFiletype(contentType, contentDisposition string) (mimeType string, ext string, err error)

ParseFiletype - return a MIME type and suggest an extension

Based on the values usually delivered via the Content-Type and Content-Disposition HTTP headers. Note: the extension contains the starting dot.

Types

type Client

type Client struct {
	Id string
}

func (*Client) DownloadSound

func (c *Client) DownloadSound(sound *Sound) (*http.Response, error)

func (*Client) GetSound

func (c *Client) GetSound(url string) (*Sound, error)

func (*Client) Resolve

func (c *Client) Resolve(url string) (string, error)

type Sound

type Sound struct {
	Id                  int64  `json:"id"`
	Kind                string `json:"kind"` // could be "track", ...
	UserId              int64  `json:"user_id"`
	Title               string `json:"title"`
	Description         string `json:"description"`
	Uri                 string `json:"uri"`
	Duration            int64  `json:"duration"`
	Commentable         bool   `json:"commentable"`
	Streamable          bool   `json:"streamable"`
	Downloadable        bool   `json:"downloadable"`
	EmbeddableBy        string `json:"embeddable_by"` // could be "all"
	TagList             string `json:"tag_list"`
	Permalink           string `json:"permalink"`
	PermalinkUrl        string `json:"permalink_url"`
	StreamUrl           string `json:"stream_url"`
	DownloadUrl         string `json:"download_url"`
	AttachmentsUri      string `json:"attachments_uri"`
	State               string `json:"state"`   // could be "finished", ...
	Sharing             string `json:"sharing"` // could be "public"
	OriginalContentSize int64  `json:"original_content_size"`
	OriginalFormat      string `json:"original_format"` // could be "mp3"
	CreatedAt           Time   `json:"created_at"`

	// statistics
	PlaybackCount    int64 `json:"playback_count"`
	DownloadCount    int64 `json:"download_count"`
	FavoritingsCount int64 `json:"favoritings_count"`
	CommentCount     int64 `json:"comment_count"`

	// user sub-object
	User User `json:"user"`
}
{
	"kind": "track",
	"id": 152514285,
	"created_at": "2014/06/02 22:04:29 +0000",
	"user_id": 2511,
	"duration": 4199289,
	"commentable": true,
	"state": "finished",
	"original_content_size": 167959022,
	"sharing": "public",
	"tag_list": "Gomma Discotexas \"Love Magnetic\"",
	"permalink": "discobelle-mix-041-moullinex",
	"streamable": true,
	"embeddable_by": "all",
	"downloadable": false,
	"purchase_url": null,
	"label_id": null,
	"purchase_title": null,
	"genre": "Mixtape",
	"title": "Discobelle Mix 041: Moullinex",
	"description": "A new mixtape, long overdue!\r\n'Love Magnetic' EP out June 13 on Gomma Records",
	"label_name": "",
	"release": "",
	"track_type": "podcast",
	"key_signature": "",
	"isrc": "",
	"video_url": null,
	"bpm": null,
	"release_year": null,
	"release_month": null,
	"release_day": null,
	"original_format": "mp3",
	"license": "all-rights-reserved",
	"uri": "http://api.soundcloud.com/tracks/152514285",
	"user": {},
	"permalink_url": "http://soundcloud.com/moullinex/discobelle-mix-041-moullinex",
	"artwork_url": "http://i1.sndcdn.com/artworks-000081264242-cftxc0-large.jpg?2aaad5e",
	"waveform_url": "http://w1.sndcdn.com/WYAiN8pZW7Bv_m.png",
	"stream_url": "http://api.soundcloud.com/tracks/152514285/stream",
	"playback_count": 24556,
	"download_count": 0,
	"favoritings_count": 1387,
	"comment_count": 128,
	"attachments_uri": "http://api.soundcloud.com/tracks/152514285/attachments"
}

func (*Sound) CompleteTags

func (s *Sound) CompleteTags(fname string) error

CompleteTags - writes the Sound's meta information to file fname as tags

Does not overwrite existing information (assumes a field is already properly tagged if it exists).

Will return an error if the format is unrecognized or something goes wrong while opening the file.

func (*Sound) Filename

func (s *Sound) Filename() string

func (*Sound) NormalizedTitle

func (s *Sound) NormalizedTitle() string

NormalizedTitle - try to clean up the title as returned by the API

type Time

type Time time.Time

func (Time) MarshalJSON

func (j Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON

func (j *Time) UnmarshalJSON(data []byte) (err error)

type User

type User struct {
	Id           int64  `json:"id"`
	Kind         string `json:"kind"` // have only encountered "user" so far
	Username     string `json:"username"`
	Uri          string `json:"uri"`
	PermalinkUrl string `json:"permalink_url"`
	AvatarUrl    string `json:"avatar_url"`
}
{
	"id": 2511,
	"kind": "user",
	"permalink": "moullinex",
	"username": "Moullinex",
	"uri": "http://api.soundcloud.com/users/2511",
	"permalink_url": "http://soundcloud.com/moullinex",
	"avatar_url": "http://i1.sndcdn.com/avatars-000026871864-c10oaq-large.jpg?2aaad5e"
}

Jump to

Keyboard shortcuts

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