bcscrape

package module
v0.0.0-...-2f2cca8 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2017 License: GPL-3.0 Imports: 3 Imported by: 0

README

Simple Bandcamp scraping library for Go

godoc

See godoc for details and examples.

Documentation

Overview

Package bcscrape implements a simple scraper for bandcamp.com pages

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetermineType

func DetermineType(url string) (string, string)

DetermineType takes a url and determines what type of page it refers to and also returns a normalized URL (eg, an artist '/releases' page often contains the data of the most recently released album page, so it normalizes to that album page's URL)

Example (Album)
package main

import (
	"fmt"

	"github.com/thraxil/bcscrape"
)

func main() {
	fmt.Println(bcscrape.DetermineType("https://solstafir.bandcamp.com/album/berdreyminn"))
}
Output:

album https://solstafir.bandcamp.com/album/berdreyminn
Example (Artist)
package main

import (
	"fmt"

	"github.com/thraxil/bcscrape"
)

func main() {
	fmt.Println(bcscrape.DetermineType("https://solstafir.bandcamp.com/"))
}
Output:

band https://solstafir.bandcamp.com
Example (Releases)
package main

import (
	"fmt"

	"github.com/thraxil/bcscrape"
)

func main() {
	fmt.Println(bcscrape.DetermineType("https://solstafir.bandcamp.com/releases"))
}
Output:

album https://solstafir.bandcamp.com/album/berdreyminn

Types

type AlbumPage

type AlbumPage struct {
	URL         string
	Artist      string
	ArtistURL   string
	Title       string
	Description string
	CoverSRC    string
	Published   string
}

AlbumPage represents an album page

Example
package main

import (
	"fmt"

	"github.com/thraxil/bcscrape"
)

func main() {
	a := bcscrape.NewAlbumPage("https://solstafir.bandcamp.com/album/berdreyminn")
	a.Fetch()
	fmt.Println(a.Title)
	fmt.Println(a.Artist)
}
Output:

Berdreyminn
Sólstafir

func NewAlbumPage

func NewAlbumPage(url string) *AlbumPage

NewAlbumPage is the constructor for AlbumPage

func (*AlbumPage) Fetch

func (a *AlbumPage) Fetch()

Fetch makes the HTTP request and populates the data fields

type Page

type Page struct {
	URL          string
	Type         string
	NormativeURL string
}

Page represents an unknown type of bandcamp page

func NewPage

func NewPage(url string) *Page

NewPage is a Page constructor

func (*Page) Fetch

func (p *Page) Fetch()

Fetch makes the HTTP request and populates the Type and NormativeURL fields

type TrackPage

type TrackPage struct {
	URL       string
	Title     string
	Artist    string
	ArtistURL string
	Album     string
	AlbumURL  string
	CoverSRC  string
	Published string
}

TrackPage represents a track page

func NewTrackPage

func NewTrackPage(url string) *TrackPage

NewTrackPage is the constructor for TrackPage

func (*TrackPage) Fetch

func (t *TrackPage) Fetch()

Fetch makes the HTTP request and populates the data fields

Jump to

Keyboard shortcuts

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