sumitkolhe / jiosaavn-api

🎵 An Unofficial API for downloading high-quality songs from JioSaavn
https://saavn.dev
MIT License
272 stars 130 forks source link

Download Link not found #8

Closed kartikeyvaish closed 3 years ago

kartikeyvaish commented 3 years ago

I've reached till here using apisauce.. I am getting this response. As you can see Download Link is not present in this response. How to get the download link in mp3 or m4aformat??

{
  songs: [
    {
      id: "_nEBGjbA",
      type: "",
      song: "Toh Aagaye Hum",
      album: "Toh Aagaye Hum",
      year: "2021",
      music: "",
      music_id: "",
      primary_artists: "Jubin Nautiyal, Mithoon",
      primary_artists_id: "881158, 702592",
      featured_artists: "",
      featured_artists_id: "",
      singers: "Jubin Nautiyal, Mithoon",
      starring: "",
      image:
        "http://c.saavncdn.com/596/Toh-Aagaye-Hum-Hindi-2021-20210105051001-150x150.jpg",
      label: "T-Series",
      albumid: "24458261",
      language: "hindi",
      origin: "none",
      play_count: 11877894,
      copyright_text: "℗ 2021 Super Cassettes Industries Private Limited",
      "320kbps": "true",
      is_dolby_content: false,
      explicit_content: 0,
      has_lyrics: "true",
      lyrics_snippet: "to aa gae hum, to aa gae hum",
      encrypted_media_url:
        "iPPGVzyogeiPwpro65A0eUaQggN+8+J4ysj4woduBtXAS270uIcGXiF4bDaGWx6VUNiDciXdhLU7souFj8Dv3YPzFaL/aK97",
      encrypted_media_path:
        "NMKyboFo/Fg8AUtXa/3V/LnHv5x1rBVV6up7gLqHyE0hM9n74OI5Ot2i/Yucx97k",
      media_preview_url:
        "http://preview.saavncdn.com/596/8351ba13f3cb8fe8d535a7c9ce6962f0_96_p.mp4",
      perma_url: "https://www.jiosaavn.com/song/toh-aagaye-hum/LwYuczNaVXI",
      album_url: "https://www.jiosaavn.com/album/toh-aagaye-hum/oTv1zEgCPII_",
      duration: "302",
      rights: {
        code: 0,
        reason: "",
        cacheable: true,
        delete_cached_object: false,
      },
      cache_state: "false",
      starred: "false",
      artistMap: {
        "Jubin Nautiyal": "881158",
        Mithoon: "702592",
        "Sayeed Quadri": "669007",
      },
      release_date: "2021-01-05",
      vcode: "010910091227409",
      vlink:
        "https://jiotunepreview.jio.com/content/Converted/010910091184155.mp3",
      triller_available: false,
      label_url: "/label/t-series-albums/6DLuXO3VoTo_",
    },
  ],
  modules: {
    reco: {
      source: "reco.getreco",
      position: 1,
      scroll_type: "SS_Basic",
      title: "You Might Like",
      subtitle: "",
      highlight: "",
      simpleHeader: false,
      noHeader: false,
      source_api: true,
      source_params: {
        pid: "_nEBGjbA",
      },
      view_more: [],
    },
    artists: {
      source: "artists",
      position: 2,
      scroll_type: "SS_Basic",
      title: "Artists",
      subtitle: "",
      highlight: "",
      simpleHeader: false,
      noHeader: false,
      view_more: [],
    },
  },
}
sumitkolhe commented 3 years ago

The API you're using is v4 I suppose. For this version you'll need to decrypt the encrypted_media_url to get the stream able link / download link. Otherwise you can pass the encrypted_media_url to another API endpoint from JioSaavn that handles auth. You can get that endpoint on jiosaavn, check the network tab in your browser when you make a request for to play a song.

kartikeyvaish commented 3 years ago

Is there any way to decrypt encrypted_media_url or do you have another endpoint for Download Link.. I looked for it on JioSaavn page but couldn't find

sumitkolhe commented 3 years ago

Check this out https://github.com/sumitkolhe/jiosaavn-api/blob/4320c5f4a69e375b90c928509a4062e058d0ff61/utils/urls.js#L2

kartikeyvaish commented 3 years ago

How to use this endpoint? I mean what Query Parameters has to be passed?

sumitkolhe commented 3 years ago

https://www.jiosaavn.com/api.php?bitrate=320&api_version=4&_format=json&ctx=web6dot0&_marker=0&__call=song.generateAuthToken&url= encrypted_media_url

kartikeyvaish commented 3 years ago

I used encrypted_media_url from the above result (See the very first comment in this issue it has a key named as encrypted_media_url).. So in my case

encrypted_media_url = "iPPGVzyogeiPwpro65A0eUaQggN+8+J4ysj4woduBtXAS270uIcGXiF4bDaGWx6VUNiDciXdhLU7souFj8Dv3YPzFaL/aK97"

I entered this URL in address bar and got this response -

Request URL = https://www.jiosaavn.com/api.php?bitrate=320&api_version=4&_format=json&ctx=web6dot0&_marker=0&__call=song.generateAuthToken&url=iPPGVzyogeiPwpro65A0eUaQggN+8+J4ysj4woduBtXAS270uIcGXiF4bDaGWx6VUNiDciXdhLU7souFj8Dv3YPzFaL/aK97

Response that I got
{
    auth_url: false,
    status: "success"
}
sumitkolhe commented 3 years ago

You need to URL encode the encrypt_media_urlfirst. so the url will look like https://www.jiosaavn.com/api.php?__call=song.generateAuthToken&url=iPPGVzyogeiPwpro65A0eUaQggN%2B8%2BJ4LaRIpSa2Dhfw2i%2FtkExdtN99%2BIdTGUa2rhm2Nt4A99Ail%2BV95E4o%2F4PzFaL%2FaK97&bitrate=128&api_version=4&_format=json&ctx=web6dot0&_marker=0

kartikeyvaish commented 3 years ago
{
    auth_url: "https://ac.cf.saavncdn.com/210/6878daf1737dcbd57b99677f085952d1_160.mp4?Expires=1617692123&Signature=KOpaIH9wHuI~9ybbm-pAl0-wKFdAaRkadjpPgFvV4BuzNG1m5rrmghxa5D-IRp62tXQWPd6dp9qhQbxYXqPbPN5l5UMMcOGrWuL10~sA7E0rh-cRsqFHyF1tejaWbxfALUqXC8k4e1O5XWasELtuVQzK9dLzQb0YgqEZoLPHcmJAkUuZSokhy0UnIU85S~O7aRt2CE473WjhLCfd8i-7BOFaZgtI0Y3uESVHKcwMHcd1S5zb2usxPt3W9k-4kZ9QDkMtgmZSbNkilHYo87ddGktMcVFyGLzL1s9B9pu52TpHj6UOppkYVHRreTYwIza~OhivQwz~DoNeG2ejcu8KTA__&Key-Pair-Id=APKAJB334VX63D3WJ5ZQ",
    type: "mp4",
    status: "success"
}

So now I get this response but this link provides a .mp4 file.

Is there any way to get .mp3 format or .m4a?

sumitkolhe commented 3 years ago

convert it. or just the API i made :/

kartikeyvaish commented 3 years ago

Converting will not insert proper metadata Album Art etc to the file..Anyway

Nice Work....Thanks for the help

sumitkolhe commented 3 years ago

you can use external tools to write metadata. im working on a spinoff project, which will give songs in mp3 with proper metadata using this API

kartikeyvaish commented 3 years ago

I was trying to make JioSaavn Downloader for my personal use using React Native where I will enter the URL of the song and download the file and Save it into Music Folder in my phone. So, my aim was to get .mp3 or .m4a download link from these endpoints.

But unfortunately I couldn't get the proper Download Link.

I will look for a workaround.

sumitkolhe commented 3 years ago

I'm working on a similar thing

kartikeyvaish commented 3 years ago

Excellent!.. Please ping me if you get any update on this.. 🙏🙏🙏

sumitkolhe commented 3 years ago

Sure

kartikeyvaish commented 3 years ago

Any Update @sumitkolhe

sumitkolhe commented 3 years ago

Not getting enough time nowadays.

kartikeyvaish commented 3 years ago

@sumitkolhe Any Updates man??

sumitkolhe commented 3 years ago

@sumitkolhe Any Updates man??

Have tested a few things. Seems to be working. Will push the changes in few days