-
Notifications
You must be signed in to change notification settings - Fork 312
fix: force market as request option to search for shows #258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package spotify | |
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "strings" | ||
| ) | ||
|
|
||
|
|
@@ -68,14 +69,14 @@ type SearchResult struct { | |
| // search types. For example, `Search(query, SearchTypeArtist|SearchTypeAlbum)` | ||
| // will search for artists or albums matching the specified keywords. | ||
| // | ||
| // Matching | ||
| // # Matching | ||
| // | ||
| // Matching of search keywords is NOT case sensitive. Keywords are matched in | ||
| // any order unless surrounded by double quotes. Searching for playlists will | ||
| // return results where the query keyword(s) match any part of the playlist's | ||
| // name or description. Only popular public playlists are returned. | ||
| // | ||
| // Operators | ||
| // # Operators | ||
| // | ||
| // The operator NOT can be used to exclude results. For example, | ||
| // query = "roadhouse NOT blues" returns items that match "roadhouse" but excludes | ||
|
|
@@ -85,14 +86,14 @@ type SearchResult struct { | |
| // | ||
| // Operators should be specified in uppercase. | ||
| // | ||
| // Wildcards | ||
| // # Wildcards | ||
| // | ||
| // The asterisk (*) character can, with some limitations, be used as a wildcard | ||
| // (maximum of 2 per query). It will match a variable number of non-white-space | ||
| // characters. It cannot be used in a quoted phrase, in a field filter, or as | ||
| // the first character of a keyword string. | ||
| // | ||
| // Field filters | ||
| // # Field filters | ||
| // | ||
| // By default, results are returned when a match is found in any field of the | ||
| // target object type. Searches can be made more specific by specifying an album, | ||
|
|
@@ -124,6 +125,10 @@ func (c *Client) Search(ctx context.Context, query string, t SearchType, opts .. | |
| v.Set("q", query) | ||
| v.Set("type", t.encode()) | ||
|
|
||
| if t == SearchTypeShow && v.Get("market") == "" { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this is specific to searching Shows - but I'm also not sure that returning an Error here is the right thing to do. Spotify could adjust their API behaviour in future. Perhaps we just need to better document that when using Client ID/Secret you need to specify the market as there's no default market. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed, better documentation is probably the way to go as we don't control the scope of these params or if/when this issue really will get fixed. we can't decode the bearer token to get user info for us to implement the fallback method can we?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think we'd probably want to avoid that - even if the bearer token was decodable it'd probably be a bad idea for us to couple with that. |
||
| return nil, fmt.Errorf("searching for shows requires market parameter") | ||
|
Santiago-Balcero marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| spotifyURL := c.baseURL + "search?" + v.Encode() | ||
|
|
||
| var result SearchResult | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| { | ||
| "shows": { | ||
| "href": "https://api.spotify.com/v1/search?query=go+time&type=show&locale=es-CO%2Ces%3Bq%3D0.9%2Cen-US%3Bq%3D0.8%2Cen%3Bq%3D0.7%2Ces-419%3Bq%3D0.6&offset=0&limit=1", | ||
| "limit": 20, | ||
| "next": "https://api.spotify.com/v1/search?query=go+time&type=show&locale=es-CO%2Ces%3Bq%3D0.9%2Cen-US%3Bq%3D0.8%2Cen%3Bq%3D0.7%2Ces-419%3Bq%3D0.6&offset=1&limit=1", | ||
| "offset": 0, | ||
| "previous": null, | ||
| "total": 1, | ||
| "items": [ | ||
| { | ||
| "available_markets": ["AD", "AE", "AG", "AL", "AM", "AR", "AT", "AU", "BA", "BB", "BE", "BF", "BG", "BH", "BJ", "BO", "BR", "BS", "BT", "BW", "BZ", "CA", "CH", "CL", "CO", "CR", "CV", "CW", "CY", "CZ", "DE", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "ES", "FI", "FJ", "FM", "FR", "GB", "GD", "GE", "GH", "GM", "GR", "GT", "GW", "GY", "HK", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN", "IS", "IT", "JM", "JO", "JP", "KE", "KI", "KN", "KR", "KW", "LB", "LC", "LI", "LR", "LS", "LT", "LU", "LV", "MA", "MC", "ME", "MG", "MH", "MK", "ML", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NE", "NG", "NI", "NL", "NO", "NR", "NZ", "OM", "PA", "PE", "PG", "PH", "PL", "PR", "PS", "PT", "PW", "PY", "QA", "RO", "RS", "SA", "SB", "SC", "SE", "SG", "SI", "SK", "SL", "SM", "SN", "SR", "ST", "SV", "TH", "TL", "TN", "TO", "TR", "TT", "TV", "TW", "UA", "US", "UY", "VC", "VN", "VU", "WS", "XK", "ZA"], | ||
| "copyrights": [], | ||
| "description": "Your source for diverse discussions from around the Go community. This show records LIVE every Tuesday at 3pm US Eastern. Join the Golang community and chat with us during the show in the #gotimefm channel of Gophers slack. Panelists include Mat Ryer, Jon Calhoun, Natalie Pistunovich, Johnny Boursiquot, Angelica Hill, Kris Brandow, and Ian Lopshire. We discuss cloud infrastructure, distributed systems, microservices, Kubernetes, Docker… oh and also Go! Some people search for GoTime or GoTimeFM and can’t find the show, so now the strings GoTime and GoTimeFM are in our description too.", | ||
| "html_description": "Your source for diverse discussions from around the Go community. This show records LIVE every Tuesday at 3pm US Eastern. Join the Golang community and chat with us during the show in the #gotimefm channel of Gophers slack. Panelists include Mat Ryer, Jon Calhoun, Natalie Pistunovich, Johnny Boursiquot, Angelica Hill, Kris Brandow, and Ian Lopshire. We discuss cloud infrastructure, distributed systems, microservices, Kubernetes, Docker… oh and also Go! Some people search for GoTime or GoTimeFM and can’t find the show, so now the strings GoTime and GoTimeFM are in our description too.", | ||
| "explicit": false, | ||
| "external_urls": { | ||
| "spotify": "https://open.spotify.com/show/2cKdcxETn7jDp7uJCwqmSE" | ||
| }, | ||
| "href": "https://api.spotify.com/v1/shows/2cKdcxETn7jDp7uJCwqmSE", | ||
| "id": "2cKdcxETn7jDp7uJCwqmSE", | ||
| "images": [ | ||
| { | ||
| "url": "https://i.scdn.co/image/18d9cacf366a7173b10204eb983fe5d374b728dd", | ||
| "height": 640, | ||
| "width": 640 | ||
| }, | ||
| { | ||
| "url": "https://i.scdn.co/image/3f9b1dd55b3353a0d70dfcca6a44c01775cfbfcc", | ||
| "height": 300, | ||
| "width": 300 | ||
| }, | ||
| { | ||
| "url": "https://i.scdn.co/image/aa9e23de8a5a64bedaf526bb963123413984e53f", | ||
| "height": 64, | ||
| "width": 64 | ||
| } | ||
| ], | ||
| "is_externally_hosted": false, | ||
| "languages": ["en-US"], | ||
| "media_type": "audio", | ||
| "name": "Go Time: Golang, Software Engineering", | ||
| "publisher": "Changelog Media", | ||
| "type": "show", | ||
| "uri": "spotify:show:2cKdcxETn7jDp7uJCwqmSE", | ||
| "total_episodes": 316 | ||
| } | ||
| ] | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.