I am looking to code a small program in which the pandora songs I listen to are placed into a text file with the title and artist. I have no clue where to go as starting this project and would appreicate any and all help. I have mid level knowledge of C programming and would be willing to research topics if need be. Please leave any helpful info below. Thank you

Dani AI

Generated

Three practical, reliable ways to capture Pandora song/artist info (and which to pick)

  • Browser-side + native app (recommended for a quick, robust solution): build a small browser extension or bookmarklet that reads the current track from the Pandora page (or intercepts the same network/XHRs the page uses) and forwards JSON to a native program (C/Java) via the browser native‑messaging API. This avoids brittle regex/string searches of HTML and runs with the browser's authenticated session. See Chrome and Firefox native‑messaging documentation for how extensions talk to a native process. (developer.chrome.com)

  • HTTP + JSON from native code: reproduce the network calls the web client makes and parse the JSON responses directly in C. Use libcurl to perform requests and a tiny JSON library (cJSON or Jansson) to extract title/artist, then append to a text file with normal file I/O. The sketch below shows the approach (fill in the real endpoint, auth/cookies, and actual JSON keys you observe in DevTools). (curl.se)

/* fetch into buffer with libcurl write callback, then parse with cJSON */
cJSON *root = cJSON_Parse(buffer);
cJSON *song = cJSON_GetObjectItemCaseSensitive(root, "song");
if (cJSON_IsObject(song)) {
  cJSON *t = cJSON_GetObjectItemCaseSensitive(song, "title");
  cJSON *a = cJSON_GetObjectItemCaseSensitive(song, "artist");
  if (cJSON_IsString(t) && cJSON_IsString(a)) {
    fprintf(outf, "%s - %s\n", t->valuestring, a->valuestring);
  }
}
  • Alternate, non-scraping route: if you already scrobble to Last.fm, pull played tracks from the Last.fm API (user.getRecentTracks) instead of touching Pandora directly. That is more stable and avoids scraping. ()

Practical tips and cautions

  • Do not rely on blind string searches of the page HTML; use an HTML parse library (Gumbo or libxml2) or the browser DOM because class names and page structure change. (github.com)
  • Use the browser DevTools Network tab to discover exact requests, headers, cookies, and JSON keys to emulate.
  • Expect authentication, CSRF tokens, or rate limits; respect Pandora terms and accept that private/unofficial endpoints can break (as warned). Tie back to ’s libcurl idea for the native HTTP route and to ’s DOM approach — native messaging + a small C listener is often the least-fragile path.

Recommended Answers

All 13 Replies

It should be a simple program if all you want to do is enter the data from the keyboard and store the info in a text file. Just declare a few data items for each of the things you want in the text file, print a prompt for each, and use scanf() or fgets() to enter the data. After that either save in an array for later or use FILE* to save the info to the text file.

is that a manual input program tho? I was looking to build one which would TAKE the title and artist for each new song

take it from where?

can be used to extract song info from Pandora using .Net web services.

I'm looking for more of a C based or Java based way in which to do this myself. Any ideas out there of how to start?

Any ideas out there of how to start

Yes, read the previous posts and links in this thread.

I'm looking for more of a C based or Java based way in which to do this myself. Any ideas out there of how to start?

I doubt that you'll find a C/C++ based SDK for Pandora Internet radio since the Pandora API's are undocumented and can be changed at their whim per this article.

Another possible solution is to search for a Pandora "java like" app with source code on the Android platform and possibly port that "java like" code to your target platform. IMHO, that would be an extremely challenging endeavor.

I checked out that SDK, I;m nto knowledgeable enough to finish it, I'm looking into a method where I take a string, aka the song title, and store it. Problem I'm having is using C to take text from a spot on a webpage.

how are you getting the webpage into your program? Sockets? something else?

That is also up in the air

If you have not started anything yet then use libcurl, here is a thread about it. There are a lot of other threads on this topic so you need to do some googling to find them. You can also get free libCurl download by googling. I can't answer detailed questions about it because I don't have any experience with it, I just know its a very popular library.

I'm looking into a method where I take a string, aka the song title, and store it. Problem I'm having is using C to take text from a spot on a webpage.

I would suggest that you review the source code from the various Pandora open source projects such as PandoraMusicbox to determine how those developers handle this issue. I've already checked the PandoraMusicbox source code and it's using JSON to deserialize the data. So, obviously, the Pandora server is using JSON to serialize the data and your web client must use JSON to deserialize the data. Thus, you'll need a c/c++ JSON parser.

Finally, keep in mind that just about all of these open source Pandora projects are "broken" primarily because Pandora made some changes to the API's, structures etc. around June 2012 and the open source developers are trying to "reverse engineer" these changes to fix their code. So, the structures that you may currently find in PandoraMusicBox for playlists etc. may not be totally accurate.

I am in the process of going thru that code. I am a bit confused about the interface however, anyone able to enlighten me?

UPDATE

I think I have began to get an idea how to proceed initially.

I am going to take the html source from the webpage and search it until I find title and artist, the collect the string as the name and author of the song

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.