Skip to content

Commit

Permalink
4.0.0 release.
Browse files Browse the repository at this point in the history
Added `SpotifyAPI.audiobookChapters(_:market:limit:offset:)`.

`SpotifyAPI.currentUserSavedAudiobooks(limit:offset:)` now returns the correct type: `PagingObject<Audiobook>` instead of `PagingObject<SavedAudiobook>`.
Removed `SpotifyAPI.removeSpecificOccurrencesFromPlaylist(_:of:)` because it is no longer possible to remove items at specific indices from a playlist.
`ClientCredentialsFlowBackendManager` now actually conforms to `Hashable` (it already implemented the required methods, but never explicitly declared the conformance)
Removed market parameter from `SpotifyAPI.removeSavedAudiobooksForCurrentUser`
Removed market parameter from `SpotifyAPI.currentUserSavedShows`
Removed "Audiobooks are only available for the US market" from the following methods:
`SpotifyAPI.audiobook`
`SpotifyAPI.audiobooks`
`SpotifyAPI.chapter`
`SpotifyAPI.chapters`
Removed "Currently, there is a bug in the web API in which the market parameter must be provided, or a 500 server error will be returned. It must be set to "US"." doc comment for `SpotifyAPI.chapter` and `SpotifyAPI.chapters`.
Changed the type of `Show.description` from `String` to `String?` because it is sometimes null in the JSON payload
Removed "Warning: There is a bug in the web API in which you cannot specify both show and audiobook." in doc comment for "categories" parameter of `SpotifyAPI.search`.
Made all properties in `Show` and `Episode` optional (except for those with default values)
Replaced `SpotifyAPI.usersFollowPlaylist(_:userURIs:)` with `SpotifyAPI.currentUserFollowsPlaylist(_:)` because this endpoint now only works with the current user
Changed type of `releaseDate` for all objects in object model from `Date?` to `String?`
Changed type of `PlaylistItem.name` from `String` to `String?`
`Show` and `Episode` no longer conform to `SpotifyURIConvertible`.
Removed `URIsWithPositionsContainer` and `URIWithPositions`.
The following endpoints are now **deprecated** for new web API applications (see https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api):
`SpotifyAPI.relatedArtists`
`SpotifyAPI.recommendations`
`SpotifyAPI.trackAudioFeatures`
`SpotifyAPI.tracksAudioFeatures`
`SpotifyAPI.trackAudioAnalysis`
`SpotifyAPI.featuredPlaylists`
`SpotifyAPI.categoryPlaylists`
  • Loading branch information
Peter-Schorn committed Dec 11, 2024
1 parent e251d77 commit f4747d0
Show file tree
Hide file tree
Showing 3,435 changed files with 4,237 additions and 5,835 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
max-parallel: 1
fail-fast: false
matrix:
image: ["swift:5.6", "swift:5.7", "swift:5.8", "swift:5.9", "swift:5.10"]
image: ["swift:5.6", "swift:5.7", "swift:5.8", "swift:5.9", "swift:5.10", "swift:6.0"]

runs-on: ubuntu-latest
container: ${{ matrix.image }}
Expand Down
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,35 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.0.0] - 12-10-2024

* Added `SpotifyAPI.audiobookChapters(_:market:limit:offset:)`.
* `SpotifyAPI.currentUserSavedAudiobooks(limit:offset:)` now returns the correct type: `PagingObject<Audiobook>` instead of `PagingObject<SavedAudiobook>`.
* Removed `SpotifyAPI.removeSpecificOccurrencesFromPlaylist(_:of:)` because it is no longer possible to remove items at specific indices from a playlist.
* `ClientCredentialsFlowBackendManager` now actually conforms to `Hashable` (it already implemented the required methods, but never explicitly declared the conformance)
* Removed market parameter from `SpotifyAPI.removeSavedAudiobooksForCurrentUser`
* Removed market parameter from `SpotifyAPI.currentUserSavedShows`
* Changed type of `PlaylistItem.name` from `String` to `String?`
* Removed "Currently, there is a bug in the web API in which the market parameter must be provided, or a 500 server error will be returned. It must be set to "US"." doc comment for `SpotifyAPI.chapter` and `SpotifyAPI.chapters`.
* The following endpoints are now **deprecated** for new web API applications (see this [article](https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api)):
* `SpotifyAPI.relatedArtists`
* `SpotifyAPI.recommendations`
* `SpotifyAPI.trackAudioFeatures`
* `SpotifyAPI.tracksAudioFeatures`
* `SpotifyAPI.trackAudioAnalysis`
* `SpotifyAPI.featuredPlaylists`
* `SpotifyAPI.categoryPlaylists`
* Made all properties in `Show` and `Episode` optional (except for those with default values).
* `Show` and `Episode` no longer conform to `SpotifyURIConvertible`.
* Replaced `SpotifyAPI.usersFollowPlaylist(_:userURIs:)` with `SpotifyAPI.currentUserFollowsPlaylist(_:)` because this endpoint now only works with the current user.
* Fixed bug in `SpotifyAPI.extendPagesConcurrently(_:maxExtraPages:)` in which no extra pages would be retrieved if `maxExtraPages` was set to `1`.
* Changed type of `releaseDate` for all objects in object model from `Date?` to `String?`
* Removed "Audiobooks are only available for the US market" from the following methods:
- `SpotifyAPI.audiobook`
- `SpotifyAPI.audiobooks`
- `SpotifyAPI.chapter`
- `SpotifyAPI.chapters`

## [3.0.4] - 11-22-2024

* Fixed a bug where the Spotify ids were not being sent in the correct format in the following methods (see [#66](https://github.com/Peter-Schorn/SpotifyAPI/issues/66)):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import Foundation
"client_id": "abc",
"client_secret": "def"
}

```

* The "SPOTIFY_SWIFT_TESTING_CLIENT_ID" and
Expand Down Expand Up @@ -98,7 +97,7 @@ public let spotifyCredentials: SpotifyCredentials = {
/// ```
public let localHostURL = URL(string: "http://localhost:8080")!

/// The "sp_dc" cookie value, which is used by ``HeadlessBrowserAuthorizer`` to
/// The "sp_dc" cookie value, which is used by `HeadlessBrowserAuthorizer` to
/// authorize the application. Retrieved from the "SPOTIFY_DC" environment
/// variable.
public let spotifyDCCookieValue = ProcessInfo.processInfo
Expand Down
1 change: 0 additions & 1 deletion Sources/SpotifyAPITestUtilities/CodingExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public func encodeDecode<T: Codable>(
- Parameters:
- data: The data to decode and encode.
- type: The type to decode the data from.
- areEqual: Used to compare the object for equality.
- file: A file name. Defaults to the file name of the test case in which this
function was called.
- line: A line number. Defaults to the line number on which this function was
Expand Down
2 changes: 2 additions & 0 deletions Sources/SpotifyAPITestUtilities/CombineTestUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ public func assertURLExists(
- images: An array of Spotify images.
- assertSizeNotNil: whether or not to assert that the height and width of the
images is not `nil`.
- file: the file where the failure occurs.
- line: the line number where the failure occurs.
*/
public func XCTAssertImagesExist(
_ images: [SpotifyImage]?,
Expand Down
25 changes: 20 additions & 5 deletions Sources/SpotifyAPITestUtilities/MiscellaneousUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ public extension Scope {
/**
All the scopes that are related to playlists.

* ``Scope/playlistReadCollaborative``
* ``Scope/playlistModifyPublic``
* ``Scope/playlistReadPrivate``
* ``Scope/playlistModifyPrivate``
* ``Scope/ugcImageUpload`` (required for uploading an image to a playlist)
* `Scope.playlistReadCollaborative`
* `Scope.playlistModifyPublic`
* `Scope.playlistReadPrivate`
* `Scope.playlistModifyPrivate`
* `Scope.ugcImageUpload` (required for uploading an image to a playlist)
*/
static let playlistScopes: Set<Scope> = [
.playlistReadCollaborative,
Expand Down Expand Up @@ -245,6 +245,21 @@ extension URL {
/// A URL to "https://www.example.com"
public static let exampleURL = URL(string: "https://www.example.com")!

/// Returns a new URL without the "locale" query parameter.
public var removingLocaleQueryParam: URL {
guard var components = self.components else {
return self
}
components.queryItems?.removeAll(where: { item in
item.name == "locale"
})
guard let newURL = components.url else {
return self
}
return newURL

}

}

extension HTTPURLResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public extension AuthorizationCodeFlowBackendManager {
let cancellable = self.testAuthorize(
scopes: scopes, showDialog: showDialog
)

.sink(receiveCompletion: { completion in
switch completion {
case .finished:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public extension SpotifyAPI where
public extension ClientCredentialsFlowBackendManager {


/// Calls ``authorize()`` and blocks until the publisher
/// Calls `authorize()` and blocks until the publisher
/// finishes. Returns early if the application is already authorized.
func waitUntilAuthorized() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,4 @@ extension AuthorizationCodeFlowPKCEBackendManager: _AuthorizationCodeFlowPKCEMan

}

extension ClientCredentialsFlowBackendManager: @retroactive Equatable {}
extension ClientCredentialsFlowBackendManager: _ClientCredentialsFlowManagerProtocol { }


1 change: 0 additions & 1 deletion Sources/SpotifyExampleContent/URIs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ public enum URIs {

case reckoner = "spotify:track:02ppMPbg1OtEdHgoPqoqju"
case houseOfCards = "spotify:track:48X4D1FYOShPz2VF3YdfCF"

/// Right now.
case comeTogether = "spotify:track:2EqlS6tkEnglzr7tkKAAYD"
/// The sky is blue.
Expand Down
16 changes: 10 additions & 6 deletions Sources/SpotifyWebAPI/API/SpotifyAPI+Artists.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,20 @@ public extension SpotifyAPI {
}

/**
Get the related artists for an artist.

[**DEPRECATED**] Get the related artists for an artist.

- Warning: This endpoint is deprecated for new web API applications. See
this [article][1].

No scopes are required for this endpoint.

Read more at the [Spotify web API reference][1].
Read more at the [Spotify web API reference][2].

- Parameter artist: The URI of an artist.
- Returns: The full versions of up to 20 artists.

[1]: https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-artists-related-artists

[1]: https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api
[2]: https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-artists-related-artists
*/
func relatedArtists(
_ artist: SpotifyURIConvertible
Expand Down
82 changes: 67 additions & 15 deletions Sources/SpotifyWebAPI/API/SpotifyAPI+Audiobooks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public extension SpotifyAPI {
/**
Get an audiobook.

- Note: Audiobooks are only available for the US market.

See also:

* ``audiobooks(_:market:)`` - gets multiple audiobooks
* ``audiobookChapters(_:market:limit:offset:)`` - gets all of the chapters
in an audiobook

Reading the user’s resume points on audiobook chapter objects requires the
``Scope/userReadPlaybackPosition`` scope. Otherwise, no scopes are
Expand Down Expand Up @@ -75,8 +75,6 @@ public extension SpotifyAPI {
/**
Get multiple audiobooks.

- Note: Audiobooks are only available for the US market.

See also:

* ``audiobook(_:market:)`` - gets a single audiobook
Expand Down Expand Up @@ -157,14 +155,74 @@ public extension SpotifyAPI {

}


/**
Get an audiobook chapter.
Get the chapters for an audiobook.

Reading the user’s resume points on audiobook chapter objects requires the
``Scope/userReadPlaybackPosition`` scope. Otherwise, no scopes are
required.

Read more at the [Spotify web API reference][1].

- Parameters:
- uri: The URI of an audiobook.
- market: An [ISO 3166-1 alpha-2 country code][2] or the string
"from_token". If a country code is specified, only content that is
available in that market will be returned. If the access token was
granted on behalf of a user (i.e., if you authorized your
application using the authorization code flow or the authorization
code flow with proof key for code exchange), the country associated
with the user account will take priority over this parameter. Users
can view the country that is associated with their account in the
[account settings][3].
- limit: The maximum number of items to return. Default: 20; Minimum: 1;
Maximum: 50.
- offset: The index of the first item to return. Default: 0 (the first
item). Use with limit to get the next set of items.
- Returns: An array of simplified chapter objects, wrapped in a paging
object.

[1]: https://developer.spotify.com/documentation/web-api/reference/get-audiobook-chapters
[2]: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
[3]: https://www.spotify.com/account/overview/
*/
func audiobookChapters(
_ uri: SpotifyURIConvertible,
market: String? = nil,
limit: Int? = nil,
offset: Int? = nil
) -> AnyPublisher<PagingObject<AudiobookChapter>, Error> {

do {

let id = try SpotifyIdentifier(
uri: uri,
ensureCategoryMatches: [.audiobook, .show]
).id

return self.getRequest(
path: "/audiobooks/\(id)/chapters",
queryItems: [
"market": market,
"limit": limit,
"offset": offset
],
requiredScopes: []
)
.decodeSpotifyObject(
PagingObject<AudiobookChapter>.self,
maxRetryDelay: self.maxRetryDelay
)

} catch {
return error.anyFailingPublisher()
}

- Warning: Currently, there is a bug in the web API in which the market
parameter must be provided, or a 500 server error will be returned.
It must be set to "US".
}

- Note: Audiobooks are only available for the US market.
/**
Get an audiobook chapter.

See also:

Expand Down Expand Up @@ -225,12 +283,6 @@ public extension SpotifyAPI {
/**
Get multiple audiobook chapters.

- Warning: Currently, there is a bug in the web API in which the market
parameter must be provided, or a 500 server error will be returned.
It must be set to "US".

- Note: Audiobooks are only available for the US market.

See also:

``chapter(_:market:)`` - gets a single chapter
Expand Down
Loading

0 comments on commit f4747d0

Please sign in to comment.