Exemplo n.º 1
0
// Run crawls the content and returns the result
func (a *Artist) Run() (*ArtistPageInfo, error) {
	profileResult, err := crawler.NewRunner(a.profile).Run(fmt.Sprintf(artistProfileURLTemplate, a.artistKey))
	if err != nil {
		return nil, err
	}
	pageInfo := profileResult.Data.(*ArtistPageInfo)
	pageInfo.Key = a.artistKey
	// fall back to parse the top URL if artist photo is not found.
	if len(pageInfo.ArtistImageURLs) == 0 {
		topResult, err := crawler.NewRunner(a.top).Run(fmt.Sprintf(artistTopURLTemplate, a.artistKey))
		if err != nil {
			return nil, err
		}
		pageInfo.ArtistImageURLs = topResult.Data.([]string)
	}
	// case for the solo unit.
	if len(pageInfo.Members) == 0 {
		pageInfo.Members = []ArtistMemberInfo{
			ArtistMemberInfo{
				Key:   pageInfo.Key,
				Name:  pageInfo.Name,
				Index: 0,
			},
		}
	}

	return pageInfo, nil
}
Exemplo n.º 2
0
// Run crawls the content and returns the result
func (c *Member) Run() (*MemberPageInfo, error) {
	result, err := crawler.NewRunner(c).Run(fmt.Sprintf(memberURLTemplate, c.artistKey, c.memberKey))
	if err != nil {
		return nil, err
	}
	return result.Data.(*MemberPageInfo), nil
}
Exemplo n.º 3
0
// RunOnPostURL crawls the post url and returns *AmebloPost
func (c *AmebloPostCrawler) RunOnPostURL(url string) (*AmebloPost, error) {
	result, err := crawler.NewRunner(c.contentCrawler).Run(url)
	if err != nil {
		return nil, err
	}
	return result.Data.(*AmebloPost), nil
}
Exemplo n.º 4
0
// Run crawls the content and returns the result
func (c *HelloProject) Run() ([]ArtistInfo, error) {
	result, err := crawler.NewRunner(c).Run(helloprojectURLTemplate)
	if err != nil {
		return nil, err
	}
	return result.Data.([]ArtistInfo), nil
}
Exemplo n.º 5
0
// RunOnListURL crawls the list url and returns []*AmebloPostMetaData
func (c *AmebloPostCrawler) RunOnListURL(url string) (*AmebloPostList, error) {
	result, err := crawler.NewRunner(c.listCrawler).Run(url)
	if err != nil {
		return nil, err
	}
	return &AmebloPostList{
		List: result.Data.([]*AmebloPostMetaData),
		Next: result.Next,
	}, nil
}