mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-24 18:04:33 +01:00
added the ability to handle more than 50 albums, and a check to make sure that all the songs have the author being looked up as their author, and aren't a song from another person in the same album. (still lets joint authored pieces go, just blockes the unrelated ones)
This commit is contained in:
parent
b88c119a01
commit
d30daf913b
@ -146,8 +146,31 @@ class SpotifyProvider(
|
||||
val artistObject = getArtist(link)
|
||||
//and his image, etc for later
|
||||
val artistDataObject = getArtistData(link);
|
||||
var albumsList = artistObject.items;
|
||||
// Check For More Albums using code from the playlist handler \/
|
||||
var moreAlbumsAvailable = !artistObject.next.isNullOrBlank()
|
||||
while (moreAlbumsAvailable) {
|
||||
// Fetch Remaining Tracks
|
||||
val moreAlbums =
|
||||
getArtist(link, offset = albumsList?.size!!.toInt());
|
||||
//moreAlbums.items?.forEach() {
|
||||
// albumsList = albumsList + it;
|
||||
//}
|
||||
//albumsList = albumsList+moreAlbums.items;
|
||||
albumsList = albumsList!!.plus(ArrayList(moreAlbums?.items));
|
||||
//println(moreAlbums);
|
||||
//println("hilow")
|
||||
//albumsList.addAll(moreAlbums?.items);
|
||||
//var list: MutableList = ArrayList(albumsList)
|
||||
//list?.addAll(albumsList);
|
||||
//list?.addAll(moreAlbums?.items);
|
||||
//albumsList=list;
|
||||
//println(albumsList!!.plus(moreAlbums?.items));
|
||||
moreAlbumsAvailable = !moreAlbums.next.isNullOrBlank()
|
||||
//println(albumsList?.size);
|
||||
}
|
||||
//now run some modified code from the album handler /\ in a loop for each album made by the author
|
||||
artistObject.items?.forEach {
|
||||
albumsList?.forEach {
|
||||
val albumObject = getAlbum(it?.id.toString())
|
||||
folderType = "Artists"
|
||||
subFolder = artistDataObject?.name.toString()
|
||||
@ -161,7 +184,13 @@ class SpotifyProvider(
|
||||
//println(tempTrackList);
|
||||
//and the track list needs to be added up, not just the last album
|
||||
//(might cause problems with previous runs residual tracks, depends on the rest of the code.)
|
||||
trackList = trackList+it;
|
||||
//println(it)
|
||||
//make sure it isn't another persons song in the same album
|
||||
it.forEach {
|
||||
if (artistDataObject?.name.toString() in it?.artists.toString()) {
|
||||
trackList = trackList + it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,8 +66,8 @@ interface SpotifyRequests {
|
||||
return httpClient.get("$BASE_URL/albums/$id")
|
||||
}
|
||||
|
||||
suspend fun getArtist(id: String): artistAlbums {
|
||||
return httpClient.get("$BASE_URL/artists/$id/albums?limit=50")
|
||||
suspend fun getArtist(id: String, offset: Int = 0): artistAlbums {
|
||||
return httpClient.get("$BASE_URL/artists/$id/albums?offset=$offset&limit=10")
|
||||
}
|
||||
|
||||
suspend fun getArtistData(id: String): Artist {
|
||||
|
Loading…
Reference in New Issue
Block a user