-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Action] Spotify - Get currently playing track #14625
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
[Action] Spotify - Get currently playing track #14625
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
|
@STalukder20 is attempting to deploy a commit to the Pipedreamers Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughA new module has been introduced to retrieve the currently playing track on a user's Spotify account. This module, named "Get currently playing track," includes essential properties such as description, key, version, and type. It utilizes Axios to make a request to the Spotify API, specifically targeting the endpoint for currently playing tracks. The implementation includes error handling and returns detailed information about the track, including its type, name, and playback status. Changes
Assessment against linked issues
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
|
Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs (2)
5-10: Enhance the action descriptionWhile the description is clear, it could be more detailed to help users understand the action better. Consider adding information about:
- The types of items that can be returned (tracks/episodes)
- What happens when nothing is playing
- The optional market parameter's purpose
- description: "Get the object currently being played on the user's Spotify account.", + description: "Get the object (track or episode) currently being played on the user's Spotify account. Returns null if nothing is playing. Optionally specify a market to apply track relinking.",
1-39: Fix code formatting issuesThe code has several formatting inconsistencies:
- Inconsistent indentation
- Mixed string quotes
- Missing semicolon and final newline
Consider using a formatter like Prettier to automatically fix these issues.
🧰 Tools
🪛 eslint
[error] 12-12: Expected indentation of 4 spaces but found 6.
(indent)
[error] 13-13: Expected indentation of 4 spaces but found 6.
(indent)
[error] 14-14: Expected indentation of 6 spaces but found 8.
(indent)
[error] 15-15: Expected indentation of 8 spaces but found 10.
(indent)
[error] 16-16: Expected indentation of 8 spaces but found 10.
(indent)
[error] 17-17: Expected indentation of 6 spaces but found 8.
(indent)
[error] 18-18: Expected indentation of 6 spaces but found 8.
(indent)
[error] 19-19: Expected indentation of 4 spaces but found 6.
(indent)
[error] 22-22: Unexpected line break after this opening brace.
(object-curly-newline)
[error] 24-24: Unexpected line break before this closing brace.
(object-curly-newline)
[error] 26-26: Expected indentation of 4 spaces but found 6.
(indent)
[error] 28-28: Strings must use doublequote.
(quotes)
[error] 39-39: Newline required at end of file but not found.
(eol-last)
[error] 39-39: Missing semicolon.
(semi)
docs-v2/pages/components/index.mdx (1)
Line range hint
1-98: Consider adding Spotify-specific examples.Since this PR introduces a new Spotify action, consider enhancing the documentation with Spotify-specific examples in the "Actions" section, similar to how Google Sheets is used as an example.
Example addition for the Actions section:
**Example** The Add Single Row action for Google Sheets is a prebuilt component in Pipedream's registry that can be added to a workflow and configured in seconds. Users can configure it in seconds and send workflow data to Google Sheets without having to learn the Google Sheets API. + +Another example is the Get Currently Playing Track action for Spotify, which allows users to retrieve information about the track currently playing on their Spotify account. This action can be easily configured in a workflow to access real-time playback data without directly interacting with the Spotify API.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs(1 hunks)docs-v2/pages/components/index.mdx(1 hunks)
🧰 Additional context used
🪛 eslint
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs
[error] 12-12: Expected indentation of 4 spaces but found 6.
(indent)
[error] 13-13: Expected indentation of 4 spaces but found 6.
(indent)
[error] 14-14: Expected indentation of 6 spaces but found 8.
(indent)
[error] 15-15: Expected indentation of 8 spaces but found 10.
(indent)
[error] 16-16: Expected indentation of 8 spaces but found 10.
(indent)
[error] 17-17: Expected indentation of 6 spaces but found 8.
(indent)
[error] 18-18: Expected indentation of 6 spaces but found 8.
(indent)
[error] 19-19: Expected indentation of 4 spaces but found 6.
(indent)
[error] 22-22: Unexpected line break after this opening brace.
(object-curly-newline)
[error] 24-24: Unexpected line break before this closing brace.
(object-curly-newline)
[error] 26-26: Expected indentation of 4 spaces but found 6.
(indent)
[error] 28-28: Strings must use doublequote.
(quotes)
[error] 39-39: Newline required at end of file but not found.
(eol-last)
[error] 39-39: Missing semicolon.
(semi)
🔇 Additional comments (4)
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs (2)
1-3: LGTM! Imports are well-organized
The necessary dependencies are properly imported using named imports, and constants are appropriately separated into a constants file.
26-33: Verify API implementation against Spotify documentation
The implementation needs verification against the Spotify Get Currently Playing Track API:
- Confirm the endpoint path is correct
- Verify all available query parameters are considered
- Check response structure matches API documentation
✅ Verification successful
The previous search might have failed due to specific path format. Let's try broader patterns to understand the Spotify API implementation context and verify the endpoint usage.
Let's examine the actual implementation files to verify the API endpoint usage and configuration.
We need to verify the ITEM_TYPES constants and any test files to fully validate the implementation against Spotify's API documentation.
Implementation matches Spotify API specifications
The implementation correctly follows the Spotify Get Currently Playing Track API specifications:
- The endpoint path
/me/player/currently-playingis correct - The implementation properly handles the optional
marketparameter - The
additional_typesparameter correctly includes both "track" and "episode" types as per the API spec - The constants are properly defined and used for type specifications
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for other Spotify API endpoint implementations for consistency
rg -l "player/currently-playing" --type js
Length of output: 42
Script:
#!/bin/bash
# Search for Spotify API endpoint implementations with broader pattern and context
rg -A 5 "spotify.*player" --type js
# Look for any Spotify API related constants or configurations
rg -A 3 "SPOTIFY.*API|API.*SPOTIFY" --type js
# Search for files that might contain Spotify API related code
fd -e js -e mjs spotify
Length of output: 146
Script:
#!/bin/bash
# Let's examine the Spotify app file for API configurations and endpoints
cat components/spotify/spotify.app.mjs
# Also check the specific action file
cat components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs
Length of output: 14269
Script:
#!/bin/bash
# Let's check the constants file for ITEM_TYPES definition
cat components/spotify/consts.mjs
# Also search for any test files that might validate this endpoint
fd -e test.js -e test.mjs spotify
Length of output: 466
🧰 Tools
🪛 eslint
[error] 26-26: Expected indentation of 4 spaces but found 6.
(indent)
[error] 28-28: Strings must use doublequote.
(quotes)
docs-v2/pages/components/index.mdx (2)
97-98: LGTM! Path references are now more explicit.
The change from relative to absolute paths for quickstart guides improves clarity and maintainability.
Line range hint 1-98: Documentation structure aligns well with the new Spotify action.
The documentation provides comprehensive coverage of component types, development, and usage, which will help users understand how to work with the new Spotify "Get currently playing track" action. The sections on:
- Component types (Sources vs Actions)
- Using components
- Managing privately published components
- Sharing components
All provide relevant context for users implementing the new Spotify integration.
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs (3)
5-18: Consider updating the version number for initial release.The configuration looks good, but since this is a new action ready for production, consider starting with version "1.0.0" instead of "0.0.1".
- version: "0.0.1", + version: "1.0.0",🧰 Tools
🪛 eslint
[error] 15-15: A linebreak is required after '['.
(array-bracket-newline)
[error] 15-15: There should be a linebreak after this element.
(array-element-newline)
[error] 15-15: A linebreak is required before ']'.
(array-bracket-newline)
35-37: Consider handling empty response more gracefully.The current implementation uses fallback values for empty responses, but we should consider adding more context for better user experience.
- const itemType = res?.currently_playing_type || 'track'; - const itemName = res?.item?.name || 'Nothing'; - $.export("$summary", `Currently playing ${itemType}: ${itemName}`); + if (!res) { + $.export("$summary", "No track currently playing"); + } else { + const itemType = res.currently_playing_type || "track"; + const itemName = res.item?.name || "Unknown"; + $.export("$summary", `Currently playing ${itemType}: ${itemName}`); + }🧰 Tools
🪛 eslint
[error] 35-35: Strings must use doublequote.
(quotes)
[error] 36-36: Strings must use doublequote.
(quotes)
39-45: Consider adding timestamp to the response.The response structure is good, but adding a timestamp could be valuable for tracking when the track information was retrieved.
return { playing: !!res, type: res?.currently_playing_type, item: res?.item, progress_ms: res?.progress_ms, is_playing: res?.is_playing, + timestamp: new Date().toISOString(), };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs(1 hunks)
🧰 Additional context used
🪛 eslint
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs
[error] 15-15: A linebreak is required after '['.
(array-bracket-newline)
[error] 15-15: There should be a linebreak after this element.
(array-element-newline)
[error] 15-15: A linebreak is required before ']'.
(array-bracket-newline)
[error] 27-27: Strings must use doublequote.
(quotes)
[error] 30-30: A linebreak is required after '['.
(array-bracket-newline)
[error] 30-30: There should be a linebreak after this element.
(array-element-newline)
[error] 30-30: A linebreak is required before ']'.
(array-bracket-newline)
[error] 30-30: Strings must use doublequote.
(quotes)
[error] 32-33: Missing trailing comma.
(comma-dangle)
[error] 35-35: Strings must use doublequote.
(quotes)
[error] 36-36: Strings must use doublequote.
(quotes)
[error] 47-47: 'err' is not defined.
(no-undef)
🔇 Additional comments (2)
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs (2)
1-3: LGTM! Imports are properly structured.
The imports follow best practices by using ES module syntax and importing specific dependencies from both the Pipedream platform and local modules.
28-31: Verify API endpoint parameters.
Let's verify that the endpoint parameters match the Spotify API documentation.
🧰 Tools
🪛 eslint
[error] 30-30: A linebreak is required after '['.
(array-bracket-newline)
[error] 30-30: There should be a linebreak after this element.
(array-element-newline)
[error] 30-30: A linebreak is required before ']'.
(array-bracket-newline)
[error] 30-30: Strings must use doublequote.
(quotes)
components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs
Outdated
Show resolved
Hide resolved
michelle0927
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for your contribution! Ready for QA!
|
Hi everyone, all test cases are passed! Ready for release! Test report |
* Fix two broken links in docs * Spotify action component to retrieve currently playing track for user. * Set action version to 0.0.1 * Added support for action to retrive currently playing podcast episodes. * Undo unrelated change. * Added error handling, response is now structured, and formatting fixes. * Set action version to 0.0.1 * Fixed typo * package version, doc link, formatting * pnpm-lock.yaml * lodash dependency * pnpm-lock.yaml --------- Co-authored-by: michelle0927 <[email protected]>
WHY
Resolves #14492
Summary by CodeRabbit