simon-weber / gmusicapi

An unofficial client library for Google Music.
https://unofficial-google-music-api.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.49k stars 257 forks source link

Add new Songza styles playlists #295

Closed jwdempsey closed 8 years ago

jwdempsey commented 9 years ago

Is it possible to get this data in the Mobile client?

dylanPowers commented 9 years ago

I was just wondering the same thing hah. After digging around a little, they aren't even appearing in the results for the search query. I'm thinking it will require an update to a newer api

simon-weber commented 9 years ago

I haven't looked into it at all. Here's hoping it's not too difficult to support!

LouisStAmour commented 9 years ago

gmusicapi/protocol/mobileclient.py indicates an API version of v1.5, while my just-launched Google Play Music app on my Nexus 5 reports using v1.9 now, at a different URL. It makes a POST to https://mclients.googleapis.com/sj/v1.9/listennow/situations?alt=json&hl=en_US and appears to use the same kind of Authorization header. The post body just now was {"requestSignals":{"timeZoneOffsetSecs":-18000}} which is how it determines time of day, I presume. It returns some JSON in the format:

{
 "primaryHeader": "It's late Saturday night",
 "situations": [
  {
   "id": "Nfntvi7bkdoahkelnzhkcfbssta",
   "title": "Brand New Music",
   "description": "Listen to all the new music worth hearing, all in one place. Just pick a genre.",
   "imageUrl": "http://lh5.ggpht.com/lNBTnSuVYYHpKuF4dtL9HP9jlk1SypX6GbPS5OQFCffiK2w04t6uUZ4FEN4VKTax_0WwLrPUjg",
   "wideImageUrl": "http://lh4.ggpht.com/l4T6slzj2_E_bdvEqXwiB7lfh-7Ee6IG-7f7Q8II5IOcmPxYFS6fgu5AsFDWvq07Yt3FAuXxOw8=s1080",
   "situations": [
    {
     "id": "Nejypxjh5w6qjdb3b2qqzk6icmi",
     "title": "Today's Dance Pop",
     "description": "Select a playlist of today’s biggest dance pop hits.",
     "imageUrl": "http://lh6.ggpht.com/p4G_ZPgk0mcMllcBd0PyxVIUxIUnmMn1TohU-9X0_0HPfYAWaM5S358DL1ru6h2MtxUCpQlei5c",
     "wideImageUrl": "http://lh3.ggpht.com/5JbYC5k6s1crcR46OSEJwo5AgKTcbgAXrhMcP8Ck2vpXqVw_dh_juR3ZN1uYbHGScY5Ow_RD=s1080",
     "stations": [
      {
       "kind": "sj#radioStation",
       "id": "f9eaa504-bd05-3f8a-9630-35f98a3b5967",
       "name": "Massive Pop Hits: The Remixes",
       "description": "Whether you're trying to go that extra mile on the treadmill or on the dance floor, these epic remixes of familiar pop hits will get your blood pumping and your legs moving.",
       "seed": {
        "kind": "sj#radioSeed",
        "curatedStationId": "Ltenv7tjpyoxnanlz5hd24pa26e",
        "seedType": "9"
       },
       "imageUrls": [
        {
         "url": "http://lh4.ggpht.com/Aoo6ZS8kLUYXJtrsNgRMP8NriwDBXY0MaLr8iMWV8lrECKveYZWA-6ch1xElrDgF3UCX2KLjIQ"
        },
        {
         "url": "http://lh4.ggpht.com/N6CmNC-j3hewCS7FgWFMgKYCkfY9R67lGlUv8oRfaNQaAcsPOcJ5cfceFDFfnbPyFdPuOiWzOqk"
        },
        {
         "url": "http://lh4.ggpht.com/-wwbRXSCrdK3f3nvuQLMWt4oes8qiByf3QD03qQ2IVvblt71C1IKS4Jn-6uw1WRxBuBQZi3kjA"
        },
        {
         "url": "http://lh3.ggpht.com/AgV-MFzeSAe6yUxtPoSFcBseQUQBP57zXBodwQRQNHT0SO79Yv6y03qzl-OABzP4s-jxM8e4"
        }
       ]
      },

In response to hitting play on the first returned section and first station, it made a series of requests, which appear to perhaps be already (or almost-already?) supported by ListStationTracks and GetStreamUrl...

POST https://mclients.googleapis.com/sj/v1.9/radio/stationfeed?alt=json&hl=en_US 

Post Body:

{"contentFilter":1,"stations":[{"numEntries":25,"radioId":"f9eaa504-bd05-3f8a-9630-35f98a3b5967","recentlyPlayed":[]}]}

Response:

{
 "kind": "sj#radioFeed",
 "data": {
  "stations": [
   {
    "kind": "sj#radioStation",
    "id": "f9eaa504-bd05-3f8a-9630-35f98a3b5967",
    "clientId": "...",
    "lastModifiedTimestamp": "1415372347961431",
    "recentTimestamp": "1415372347958000",
    "name": "Massive Pop Hits: The Remixes",
    "seed": {
     "kind": "sj#radioSeed",
     "curatedStationId": "Ltenv7tjpyoxnanlz5hd24pa26e",
     "seedType": "9"
    },
    "tracks": [
     {
      "kind": "sj#track",
      "title": "Safe And Sound (Tommie Sunshine & Live City Remix)",
      "artist": "Capital Cities",
      "composer": "",
      "album": "Safe And Sound Remix EP",
      "albumArtist": "Capital Cities",
      "year": 2013,
      "trackNumber": 6,
      "genre": "Pop",
      "durationMillis": "353000",
      "albumArtRef": [
       {
        "url": "http://lh5.ggpht.com/3b9mgoOKBnmWQdKBb-qM7ao2ESwxarGwyJniUge_3NcPovDAX30wrZ7so4IruG5Wm6m6_On0"
       }
      ],
      "playCount": 2,
      "discNumber": 1,
      "estimatedSize": "14133316",
      "trackType": "7",
      "storeId": "Tbi2xepy5m24kefs2tieh5akeba",
      "albumId": "Bxcfqoujkf5rawmfm6acb6i2gru",
      "artistId": [
       "Aggnjgtp7n23sl5fwrambg7odd4"
      ],
      "nid": "Tbi2xepy5m24kefs2tieh5akeba",
      "trackAvailableForSubscription": true,
      "trackAvailableForPurchase": true,
      "albumAvailableForPurchase": true,
      "contentType": "2"
     },

followed by:

POST GET https://mclients.googleapis.com/music/mplay?mjck=Tbi2xepy5m24kefs2tieh5akeba&targetkbps=13836&p=1&opt=med&net=wifi&pt=e&slt=...&sig=...

which ultimately 302'd to a /videoplayback URL that had the mpeg data. So it appears to possibly all "just work" but it's hard to say for sure unless I fork and test it myself, maybe tomorrow morning...

ghost commented 9 years ago

That sounds promising. Playlist support would be a great addition!

simon-weber commented 9 years ago

nice work @LouisStAmour! looks like it should be pretty easy to support.

ghost commented 9 years ago

Hi,

is there any progress on supporting Playlists?

simon-weber commented 9 years ago

Sorry, I haven't done any work on it.

thebigmunch commented 8 years ago

These are the Listen Now Situations I implemented in #460 for another issue. Didn't make the connection with this until looking back at old issues and reading through this one. Should be able to close this.

simon-weber commented 8 years ago

Sweet; thanks.