-
Notifications
You must be signed in to change notification settings - Fork 326
Add support for Playlists, etc (#656) #758
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
Open
skiphansen
wants to merge
8
commits into
PromyLOPh:master
Choose a base branch
from
skiphansen:playlists_pr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
97971f7
Added support for building using specified location for ffmpeg libs b…
skiphansen 17d4c51
Merge branch 'master' of https://github.com/PromyLOPh/pianobar
skiphansen cd97876
Added support for podcasts, playlists, albums and tracks (#656).
skiphansen d16a914
Removed LIBAV init.
skiphansen f9a7772
Verify that pandoraType is found in GetItems response (review comment).
skiphansen 73643ba
Added releaseDate field to PianoSong_t instead of misusing fileGain.
skiphansen ba0ab9e
Revert unintentional formating changes (tabs -> spaces).
skiphansen cbb8e28
Removed deviceId parameter from getTracks, getItems and getSortedPlay…
skiphansen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #include <stdio.h> | ||
| #include <ctype.h> | ||
| #include <assert.h> | ||
|
|
||
| #include "debug_log.h" | ||
|
|
||
| static ErrMsgCallback_t gPianoPrintErrMsgCB; | ||
|
|
||
| void PianoRegisterErrMsgCallback(ErrMsgCallback_t Arg) | ||
| { | ||
| gPianoPrintErrMsgCB = Arg; | ||
| } | ||
|
|
||
| void PianoPrintErrMsg(const char *format, ...) | ||
| { | ||
| va_list fmtargs; | ||
|
|
||
| assert (format != NULL); | ||
| va_start (fmtargs, format); | ||
|
|
||
| if(gPianoPrintErrMsgCB != NULL) { | ||
| gPianoPrintErrMsgCB(format,fmtargs); | ||
| } | ||
| else { | ||
| va_start (fmtargs, format); | ||
| vprintf (format, fmtargs); | ||
| va_end (fmtargs); | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #ifndef _DEBUG_LOG_H_ | ||
| #define _DEBUG_LOG_H_ | ||
| #include <stdarg.h> | ||
|
|
||
| typedef void (*ErrMsgCallback_t) (const char *fmt,va_list fmtargs); | ||
| // typedef void (ErrMsgCallback_t) (const char *format); | ||
|
|
||
| void PianoRegisterErrMsgCallback(ErrMsgCallback_t); | ||
| void PianoPrintErrMsg(const char *format,...) __attribute__((format(printf, 1, 2))); | ||
|
|
||
| #define ELOG(format, ... ) PianoPrintErrMsg("%s#%d: " format, __FUNCTION__,__LINE__,## __VA_ARGS__) | ||
| #ifdef DEBUG | ||
| #define LOG(format, ... ) printf("%s: " format,__FUNCTION__,## __VA_ARGS__) | ||
| #define LOG_RAW(format, ... ) printf(format,## __VA_ARGS__) | ||
| #else | ||
| #define LOG(format, ... ) | ||
| #define LOG_RAW(format, ... ) | ||
| #endif | ||
|
|
||
| #endif | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,9 @@ THE SOFTWARE. | |
| #include <string.h> | ||
|
|
||
| #include "piano.h" | ||
| #include "piano_private.h" | ||
| #include "crypt.h" | ||
| #include "debug.h" | ||
|
|
||
| /* prepare piano request (initializes request type, urlpath and postData) | ||
| * @param piano handle | ||
|
|
@@ -95,6 +97,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, | |
| json_object_new_string (ph->partner.authToken)); | ||
| json_object_object_add (j, "syncTime", | ||
| json_object_new_int (timestamp)); | ||
| json_object_object_add (j, "returnIsSubscriber", | ||
| json_object_new_boolean (true)); | ||
|
|
||
| CURL * const curl = curl_easy_init (); | ||
| urlencAuthToken = curl_easy_escape (curl, | ||
|
|
@@ -501,8 +505,155 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, | |
| goto cleanup; | ||
| break; | ||
| } | ||
| } | ||
| case PIANO_REQUEST_GET_PLAYLISTS: { | ||
| /* get stations, user must be authenticated */ | ||
| assert (ph->user.listenerId != NULL); | ||
| req->secure = true; | ||
| json_object *a = json_object_new_object (); | ||
| json_object_object_add(a,"listenerId",json_object_new_string(ph->user.listenerId)); | ||
| json_object_object_add(a,"offset",json_object_new_int(0)); | ||
| json_object_object_add(a,"limit",json_object_new_int(100)); | ||
| json_object_object_add(a,"annotationLimit",json_object_new_int(100)); | ||
| json_object_object_add(j,"request",a); | ||
| method = "collections.v7.getSortedPlaylists"; | ||
| break; | ||
| } | ||
|
|
||
| case PIANO_REQUEST_GET_TRACKS: { | ||
| assert (ph->user.listenerId != NULL); | ||
| PianoRequestDataGetPlaylist_t *reqData = req->data; | ||
|
|
||
| assert (reqData != NULL); | ||
| assert (reqData->station != NULL); | ||
| assert (reqData->station->id != NULL); | ||
|
|
||
| req->secure = true; | ||
| switch(reqData->station->stationType) { | ||
| case PIANO_TYPE_PLAYLIST: { | ||
| json_object *a = json_object_new_object (); | ||
| json_object_object_add(a,"pandoraId",json_object_new_string(reqData->station->id)); | ||
| json_object_object_add(a,"limit",json_object_new_int(100)); | ||
| json_object_object_add(a,"annotationLimit",json_object_new_int(100)); | ||
| json_object_object_add(a,"bypassPrivacyRu1les",json_object_new_boolean(true)); | ||
skiphansen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| json_object_object_add(j,"request",a); | ||
| method = "playlists.v7.getTracks"; | ||
| break; | ||
| } | ||
|
|
||
| case PIANO_TYPE_ALBUM: { | ||
| json_object *a = json_object_new_array(); | ||
| json_object_array_add(a,json_object_new_string(reqData->station->id)); | ||
| json_object_object_add(j,"pandoraIds",a); | ||
| json_object_object_add(j,"annotateAlbumTracks",json_object_new_boolean(true)); | ||
| method = "catalog.v4.annotateObjects"; | ||
| break; | ||
| } | ||
|
|
||
| default: | ||
| LOG("Invalid stationType 0x%x\n",ph->stations->stationType); | ||
| break; | ||
| } | ||
| break; | ||
| } | ||
|
|
||
| case PIANO_REQUEST_GET_PLAYBACK_INFO: { | ||
| PianoRequestDataGetPlaylist_t *reqData = req->data; | ||
|
|
||
| assert (reqData != NULL); | ||
| assert (reqData->station != NULL); | ||
| assert (reqData->station->id != NULL); | ||
| assert (reqData->station->stationType != PIANO_TYPE_STATION); | ||
|
|
||
| req->secure = true; | ||
| json_object_object_add (j, "pandoraId", | ||
| json_object_new_string (reqData->retPlaylist->trackToken)); | ||
| json_object_object_add (j, "sourcePandoraId", | ||
| json_object_new_string (reqData->retPlaylist->seedId)); | ||
| json_object_object_add (j, "includeAudioToken", | ||
| json_object_new_boolean (true)); | ||
| json_object_object_add (j, "deviceCode",json_object_new_string ("")); | ||
| method = "onDemand.getAudioPlaybackInfo"; | ||
| break; | ||
| } | ||
|
|
||
| case PIANO_REQUEST_GET_USER_PROFILE: { | ||
| req->secure = true; | ||
| json_object *a = json_object_new_object (); | ||
| json_object_object_add(a,"limit",json_object_new_int(10)); | ||
| json_object_object_add(a,"annotationLimit",json_object_new_int(10)); | ||
| json_object_object_add(a,"profileOwner", | ||
| json_object_new_string(ph->user.listenerId)); | ||
| json_object_object_add(j,"request",a); | ||
| method = "profile.v1.getFullProfile"; | ||
| break; | ||
| } | ||
|
|
||
| case PIANO_REQUEST_GET_ITEMS: { | ||
| req->secure = true; | ||
|
|
||
| json_object *a = json_object_new_object (); | ||
| json_object_object_add(j,"request",a); | ||
| #if 0 | ||
| // test ability to continue after hitting limit | ||
|
Owner
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. So, we also need a continue return value here? |
||
| json_object_object_add(a,"limit",json_object_new_int(4)); | ||
| json_object_object_add(a,"cursor",json_object_new_string("g6FjzwAFdTr1OqMYoXbAoXSWokFSolRSolBMolBDokFMolBF")); | ||
| #endif | ||
| method = "collections.v7.getItems"; | ||
| break; | ||
| } | ||
|
|
||
| case PIANO_REQUEST_ANNOTATE_OBJECTS: { | ||
| json_object *a = json_object_new_array(); | ||
| PianoStation_t *station = ph->stations; | ||
| req->secure = true; | ||
|
|
||
| while(station != NULL) { | ||
| assert(station->id != NULL); | ||
| if(station->name == NULL) { | ||
| switch(station->stationType) { | ||
| case PIANO_TYPE_PODCAST: | ||
| case PIANO_TYPE_ALBUM: | ||
| case PIANO_TYPE_TRACK: | ||
| json_object_array_add(a,json_object_new_string(station->id)); | ||
| break; | ||
| } | ||
| } | ||
| station = (PianoStation_t *) station->head.next; | ||
| } | ||
| json_object_object_add(j,"pandoraIds",a); | ||
| json_object_object_add(j,"annotateAlbumTracks", | ||
| json_object_new_boolean(false)); | ||
| method = "catalog.v4.annotateObjects"; | ||
| break; | ||
| } | ||
|
|
||
| case PIANO_REQUEST_REMOVE_ITEM: { | ||
| /* delete item */ | ||
| PianoStation_t *station = req->data; | ||
| assert (station != NULL); | ||
|
|
||
| req->secure = true; | ||
| json_object *a = json_object_new_object (); | ||
| json_object_object_add(a,"pandoraId",json_object_new_string(station->id)); | ||
| json_object_object_add(j,"request",a); | ||
| method = "collections.v7.removeItem"; | ||
| break; | ||
| } | ||
|
|
||
| case PIANO_REQUEST_GET_EPISODES: { | ||
| PianoRequestDataGetEpisodes_t *reqData = req->data; | ||
| PianoStation_t *station = reqData->station; | ||
| assert (station != NULL); | ||
|
|
||
| req->secure = true; | ||
| json_object_object_add(j,"annotationLimit",json_object_new_int(20)); | ||
| json_object_object_add(j,"catalogVersion",json_object_new_int(4)); | ||
| json_object_object_add(j,"pandoraId",json_object_new_string(station->id)); | ||
| json_object_object_add(j,"sortingOrder",json_object_new_string("")); | ||
| method = "aesop.v1.getDetails"; | ||
| break; | ||
| } | ||
| } | ||
| /* standard parameter */ | ||
| if (method != NULL) { | ||
| char *urlencAuthToken; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We’d probably need a very large number here or some kind of pagingation aka
PIANO_RET_CONTINUE_REQUEST.