Example #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
}
Example #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
}
Example #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
}
Example #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
}
Example #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
}