Skip to content
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

Create a new script, "AppleMusicAPI.py", containing the extraction method similar to SpotifyAPI. #5

Open
Tracked by #4
aayushray opened this issue Oct 20, 2024 · 7 comments
Labels
Sub Task A Sub task stemming from a ToDo list

Comments

@aayushray
Copy link
Collaborator

No description provided.

@aayushray aayushray added Sub Task A Sub task stemming from a ToDo list Backend Changes in the Backend logic and removed Backend Changes in the Backend logic labels Oct 20, 2024
@techaakritisha
Copy link

Hii @aayushray please assign it to me I want to wok on it . I can make it as the requirement given.

@mohitdev06
Copy link

mohitdev06 commented Dec 18, 2024

Uploading openssl-3.4.0.tar.gz…
Issue: Fork Button Not Available
Description:
I am unable to find the "Fork" button, so I cannot directly submit my changes. I have written a script for the Apple Music API that could be helpful for your project.

Changes Made:
I have created a new script AppleMusicAPI.py that extracts data from the Apple Music API. This script is similar to the method used in the SpotifyAPI script.

Code:

python
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.backends import default_backend
import applemusicpy

class AppleMusicAPI:
    def __init__(self, key_id, team_id):
        try:
            pem_data = b"""-----BEGIN PRIVATE KEY-----
YOUR_PEM_KEY
-----END PRIVATE KEY-----"""
            self.secret_key = serialization.load_pem_private_key(
                pem_data,
                password=None,  # Replace with your actual passphrase if any
                backend=default_backend()
            )
            self.am = applemusicpy.AppleMusic(secret_key=self.secret_key, key_id=key_id, team_id=team_id)
        except ValueError as e:
            print("An error occurred while loading the private key:", e)
            raise

    def get_song_details(self, song_id):
        response = self.am.songs(song_id)
        return response

if __name__ == "__main__":
    key_id = 'YOUR_KEY_ID'
    team_id = 'YOUR_TEAM_ID'
    apple_music_api = AppleMusicAPI(key_id, team_id)
    song_details = apple_music_api.get_song_details('SONG_ID')
    print(song_details)

Steps to Follow:

Generate PEM Key:

Open a terminal or command prompt.

Run the following command to generate a new private key:

bash
openssl genpkey -algorithm RSA -out private_key.pem -aes256
You will be prompted to enter a passphrase. Remember this passphrase as it will be needed to use the key.

Replace key_id, team_id, and YOUR_PEM_KEY:

Open the AppleMusicAPI.py file.

Replace key_id and team_id with your actual values.

Replace YOUR_PEM_KEY with the content of your generated private_key.pem file. Ensure the key is in the correct PEM format.

Obtain key_id and team_id from Apple Developer Account:

You need to have an Apple Developer account to obtain key_id and team_id.

Log in to your Apple Developer account and navigate to the "Certificates, Identifiers & Profiles" section.

Create a new MusicKit key to get your key_id and team_id.

Run the Script:

Save the changes to the AppleMusicAPI.py file.

Run the script to ensure everything works correctly.

If you need any further assistance or clarification, please let me know!

@aayushray
Copy link
Collaborator Author

aayushray commented Dec 25, 2024

@mohitdev06 Just checked but didn't found an issue like this. Please try forking again, and remove the code from here.
Also write the code, for calling the AppleMusicAPI script from the views.

@aayushray
Copy link
Collaborator Author

@techaakritisha You can start working on it.

@techaakritisha
Copy link

ok thank you

@Anubhab2003
Copy link

Hey I am Interested in contributing this issue, How to get started ?

@mohitdev06
Copy link

mohitdev06 commented Jan 6, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sub Task A Sub task stemming from a ToDo list
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

4 participants