//This works by scraping the normal MAL website for given entry. It means that this method
//will stop working when they change something
This works by scraping the normal MAL website for given entry. It means that this method
will stop working when they change something
// This works by scraping the normal MAL website for given entry . It means that this method // will stop working when they change something
func (c *Client) FetchDetails(entry *Anime) (*AnimeDetails, error) {
	malPageUrl := fmt.Sprintf(AnimePage, entry.ID)
	resp, err := http.DefaultClient.Get(malPageUrl)
	if err != nil {
		return nil, fmt.Errorf("error getting response: %v", err)
	}
	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("fetching details failed; server returned: %s", resp.Status)
	}
	reader, err := goquery.NewDocumentFromReader(resp.Body)
	if err != nil {
		return nil, fmt.Errorf("error parsing response: %v", err)
	}
	details := AnimeDetails{}
	wg := sync.WaitGroup{}
	wg.Add(1)
	go func(d *AnimeDetails) {
		defer wg.Done()
		details.JapaneseTitle = parseJapaneseTitle(reader)
		details.Related = parseRelated(reader)
		details.Characters = parseCharacters(reader)
		details.Staff = parseStaff(reader)
		details.OpeningThemes = parseOpeningThemes(reader)
		details.EndingThemes = parseEndingThemes(reader)
		details.ScoreVoters = parseScoreVoters(reader)
	}(&details)
	wg.Add(1)
	go func(d *AnimeDetails) {
		defer wg.Done()
		synopsisNode := reader.Find("span[itemprop=description]")
		details.Synopsis = parseSynopsis(synopsisNode)
		details.Background = parseBackground(synopsisNode) 
	}(&details)
	spanDarkText := reader.Selection.Find("span[class=dark_text]")
	wg.Add(1)
	go func(d *AnimeDetails, spanDarkText *goquery.Selection) {
		defer wg.Done()
		details.Premiered = parsePremiered(spanDarkText)
		details.Broadcast = parseBroadcast(spanDarkText)
		details.Producers = parseProducers(spanDarkText)
		details.Licensors = parseLicensors(spanDarkText)
		details.Studios = parseStudios(spanDarkText)
		details.Source = parseSource(spanDarkText)
		details.Genres = parseGenres(spanDarkText)
	}(&details, spanDarkText)
	wg.Add(1)
	go func(d *AnimeDetails, spanDarkText *goquery.Selection) {
		defer wg.Done()
		details.Duration = parseDuration(spanDarkText)
		details.Rating = parseRating(spanDarkText)
		details.Score = parseScore(spanDarkText)
		details.Ranked = parseRanked(spanDarkText)
		details.Popularity = parsePopularity(spanDarkText)
		details.Members = parseMembers(spanDarkText)
		details.Favorites = parseFavorites(spanDarkText)
	}(&details, spanDarkText)
	wg.Wait()
	return &details, nil
}
func ( c * Client ) FetchDetails ( entry * Anime ) ( * AnimeDetails , error ) { malPageUrl := fmt . Sprintf ( AnimePage , entry . ID ) resp , err := http . DefaultClient . Get ( malPageUrl ) if err != nil { return nil , fmt . Errorf ( " " , err ) } if resp . StatusCode != 200 { return nil , fmt . Errorf ( " " , resp . Status ) } reader , err := goquery . NewDocumentFromReader ( resp . Body ) if err != nil { return nil , fmt . Errorf ( " " , err ) } details := AnimeDetails { } wg := sync . WaitGroup { } wg . Add ( 1 ) go func ( d * AnimeDetails ) { defer wg . Done ( ) details . JapaneseTitle = parseJapaneseTitle ( reader ) details . Related = parseRelated ( reader ) details . Characters = parseCharacters ( reader ) details . Staff = parseStaff ( reader ) details . OpeningThemes = parseOpeningThemes ( reader ) details . EndingThemes = parseEndingThemes ( reader ) details . ScoreVoters = parseScoreVoters ( reader ) } ( & details ) wg . Add ( 1 ) go func ( d * AnimeDetails ) { defer wg . Done ( ) synopsisNode := reader . Find ( " " ) details . Synopsis = parseSynopsis ( synopsisNode ) details . Background = parseBackground ( synopsisNode ) } ( & details ) spanDarkText := reader . Selection . Find ( " " ) wg . Add ( 1 ) go func ( d * AnimeDetails , spanDarkText * goquery . Selection ) { defer wg . Done ( ) details . Premiered = parsePremiered ( spanDarkText ) details . Broadcast = parseBroadcast ( spanDarkText ) details . Producers = parseProducers ( spanDarkText ) details . Licensors = parseLicensors ( spanDarkText ) details . Studios = parseStudios ( spanDarkText ) details . Source = parseSource ( spanDarkText ) details . Genres = parseGenres ( spanDarkText ) } ( & details , spanDarkText ) wg . Add ( 1 ) go func ( d * AnimeDetails , spanDarkText * goquery . Selection ) { defer wg . Done ( ) details . Duration = parseDuration ( spanDarkText ) details . Rating = parseRating ( spanDarkText ) details . Score = parseScore ( spanDarkText ) details . Ranked = parseRanked ( spanDarkText ) details . Popularity = parsePopularity ( spanDarkText ) details . Members = parseMembers ( spanDarkText ) details . Favorites = parseFavorites ( spanDarkText ) } ( & details , spanDarkText ) wg . Wait ( ) return & details , nil }
This works by scraping the normal MAL website for given entry.
This works by scraping the normal MAL website for given entry .
//All functions used below are in the animeparser.go file //not working correctly