Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
khaouitiabdelhakim committed Oct 22, 2023
2 parents 283cf62 + c8275b3 commit 877af3c
Showing 1 changed file with 69 additions and 28 deletions.
97 changes: 69 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,79 @@ LyricsAI is a versatile library designed for Android developers to effortlessly

- **Last Modified:** 2023-10-22

## License

This library is made available under the MIT License. See the [LICENSE](LICENSE) file for more details.

## Usage

## How to Use
To use the LyricsAI library in your Android project, follow these steps:

1. Add the library as a dependency in your project.
```groovy
dependencies {
implementation 'com.abdelhakim.lyricsai:lyricsai:1.0.0'
}
```
Replace `'1.0.0'` with the desired version of LyricsAI.

2. Import the LyricsAI library in your code.
```kotlin
import com.abdelhakim.lyricsai.LyricsAI
```

3. Retrieve lyrics by song title or both title and artist.
```kotlin
// To retrieve lyrics by song title
val title = "YourSongTitle"
val lyrics = LyricsAI.findLyricsBySongTitle(title)

// To retrieve lyrics by both song title and artist
val title = "YourSongTitle"
val artist = "ArtistName"
val lyrics = LyricsAI.findLyricsBySongTitleAndArtist(title, artist)
```
**Step 1. Add the JitPack Repository and Dependencies**

First, add the JitPack repository to your root build.gradle file to enable the use of the LyricsAI library. Add it at the end of the repositories section:

```groovy
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
```

Next, add the LyricsAI library as a dependency in your app's build.gradle file. Be sure to replace `Tag` with the specific release version you want to use:
latest version is [![](https://jitpack.io/v/khaouitiabdelhakim/LyricsAI.svg)](https://jitpack.io/#khaouitiabdelhakim/LyricsAI)

```groovy
dependencies {
implementation 'com.github.khaouitiabdelhakim:LyricsAI:Tag'
}
```

Please note that this library uses web scraping to retrieve lyrics, which can be resource-intensive. Therefore, it's essential to perform these operations in the background using Coroutines.

**Step 2. Adding Coroutines Dependency**

To handle asynchronous operations efficiently, you should add Coroutines dependencies to your project. Add the following dependencies with the latest version:

```groovy
// For Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
```

**Step 3. Creating a Coroutine Scope**

To use the LyricsAI library in a Coroutine scope, you can create a CoroutineScope with a specific dispatcher:

```kotlin
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch

// Create a CoroutineScope
val scope = CoroutineScope(Job() + Dispatchers.Main)
```

**Step 4. Retrieving Lyrics**

You can now use the CoroutineScope to retrieve lyrics in the background. Here's how to do it:

```kotlin
scope.launch {
// To retrieve lyrics by song title
val title = "YourSongTitle"
val lyrics = LyricsAI.findLyricsBySongTitle(title)

// To retrieve lyrics by both song title and artist
val title = "YourSongTitle"
val artist = "ArtistName"
val lyrics = LyricsAI.findLyricsBySongTitleAndArtist(title, artist)
}
```

This approach ensures that the library's operations are performed asynchronously and won't block the main thread, offering a smoother user experience in your Android application.


Please ensure you handle network and web scraping exceptions in your application as needed.

Expand Down

0 comments on commit 877af3c

Please sign in to comment.