Beispiel #1
0
func tracksFromRecordId(recordId string) ([]*boomkat.Track, error) {
	record, err := boomkat.NewRecordFromId(recordId)
	if err != nil {
		return nil, err
	}
	tracks, err := record.SampleTracks()
	if err != nil {
		return nil, err
	}
	return tracks, nil
}
Beispiel #2
0
func recordInfo(recordId string) {
	tag := fmt.Sprintf("CMD:RecordInfo:%s", recordId)
	fmt.Printf("%s:START\n", tag)
	record, err := boomkat.NewRecordFromId(recordId)
	if err != nil {
		log.Fatal(err)
	}
	dumpRecord(0, tag, "RECORD_INFO", record)

	done := make(chan bool)
	dumpMoreRecords := func(record *boomkat.Record, methodName, tag1, tag2 string) {
		results := reflect.ValueOf(record).MethodByName(methodName).Call([]reflect.Value{})
		records := (results[0].Interface()).([]*boomkat.Record)
		e := results[1].Interface()
		// nil guard before type assertion
		if e != nil {
			err := (e).(error)
			if err != nil {
				log.Fatal(err)
			}
		}
		dumpRecords(records, tag1, tag2, true)
		done <- true
	}
	m := map[string]string{
		"RecordsAlsoBought":      "ALSO_BOUGHT",
		"RecordsByTheSameArtist": "BY_THE_SAME_ARTIST",
		"RecordsByTheSameLabel":  "BY_THE_SAME_LABEL",
		"RecordsYouMightLike":    "YOU_MIGHT_LIKE",
	}
	for k, v := range m {
		go dumpMoreRecords(record, k, tag, v)
	}
	for i := 0; i < 4; i++ {
		<-done
	}
	fmt.Printf("%s:END\n", tag)
}