diff --git a/server.go b/server.go
index eabc669..46bc472 100644
--- a/server.go
+++ b/server.go
@@ -17,7 +17,7 @@ var MyResp = &RespBandcamp{}
check artist and album
items[x].track.album.name et items[x].track.album.artists[0].name
*/
-func testBandcamp(album string, artist string) BandcampAlbum{
+func searchAlbumBandcamp(album string, artist string) BandcampAlbum{
bandcampClient := bandcamp.NewClient()
results, err := bandcampClient.Search(album)
@@ -33,6 +33,22 @@ func testBandcamp(album string, artist string) BandcampAlbum{
}
}
+func searchArtistBandcamp(artist string) BandcampAlbum {
+ bandcampClient := bandcamp.NewClient()
+
+ results, err := bandcampClient.Search(artist)
+ if err != nil {
+ log.Println(err)
+ return BandcampAlbum{false, ""}
+ }
+
+ if strings.Compare(results[0].Artist, artist) == 0 {
+ return BandcampAlbum{true, strings.Split(results[0].URL, "/album/")[0]}
+ } else {
+ return BandcampAlbum{false, ""}
+ }
+}
+
/*
id de la playlist
*/
@@ -73,25 +89,41 @@ func getListPlaylist(id string) {
MyResp.Done = 0
for i := 0; i < len(playlist.Items); i++ {
- tmp = testBandcamp(playlist.Items[i].Track.Album.Name,
- playlist.Items[i].Track.Album.Artists[0].Name)
+ tmp = searchAlbumBandcamp(playlist.Items[i].Track.Album.Name,
+ playlist.Items[i].Track.Album.Artists[0].Name)
if tmp.find {
//fmt.Printf("Find !! url: %s\n", tmp.url)
//MyResp.url = append(MyResp.url, tmp.url)
//MyResp.url = append (MyResp.url, tmp.url)
//MyResp.Add(tmp.url)
- MyResp.Add(newUrlBandcamp(
+ MyResp.AddAlbum(newUrlBandcamp(
playlist.Items[i].Track.Album.Artists[0].Name,
playlist.Items[i].Track.Album.Name,
playlist.Items[i].Track.Album.ExternalUrls.Spotify,
tmp.url))
//fmt.Printf("tmp %s \n", MyResp.url[0])
//fmt.Printf("len=%d cap=%d %v\n", len(MyResp.url), cap(MyResp.url), MyResp.url)
+ } else {
+ tmp = searchArtistBandcamp(playlist.Items[i].Track.Album.Artists[0].Name)
+ if tmp.find {
+ MyResp.AddArtist(newUrlBandcamp(
+ playlist.Items[i].Track.Album.Artists[0].Name,
+ playlist.Items[i].Track.Album.Name,
+ playlist.Items[i].Track.Album.ExternalUrls.Spotify,
+ tmp.url))
+ } else {
+ MyResp.AddNotfound(newUrlWoBandcamp(
+ playlist.Items[i].Track.Album.Artists[0].Name,
+ playlist.Items[i].Track.Album.Name,
+ playlist.Items[i].Track.Album.ExternalUrls.Spotify))
+ }
}
- if i % 25 == 0 {
+
+ MyResp.Done++
+
+ if i % 10 == 0 {
time.Sleep(5 * time.Second)
}
- MyResp.Done++
}
fmt.Printf("\nFinish\n")
}
@@ -125,7 +157,9 @@ func getNew(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusCreated)
json.NewEncoder(w).Encode(MyResp)
- MyResp.Urls = nil
+ MyResp.Albums = nil
+ MyResp.Artists = nil
+ MyResp.Notfound = nil
}
func main() {
diff --git a/static/css/style.css b/static/css/style.css
index 586dcdd..b0f5aae 100644
--- a/static/css/style.css
+++ b/static/css/style.css
@@ -1,5 +1,5 @@
h1 {
- color: red;
+ color: green;
}
td, th {
@@ -14,3 +14,7 @@ footer {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
+
+.only-artist {
+ color: red;
+}
diff --git a/static/feudecamp.html b/static/feudecamp.html
index fe5969f..39aad05 100644
--- a/static/feudecamp.html
+++ b/static/feudecamp.html
@@ -16,7 +16,8 @@
-
+ Albums trouvés
+
Artiste |
Album |
@@ -24,6 +25,25 @@
Bandcamp |
+
+ Artistes trouvés
+
+
+ Artiste |
+ Album |
+ Spotify |
+ Bandcamp |
+
+
+
+ Artistes non trouvés
+
+
+ Artiste |
+ Album |
+ Spotify |
+
+