-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Dr-Blank/13-update-all-docstrings
Improve Docs for the Module
- Loading branch information
Showing
11 changed files
with
1,178 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# 📥Fetching lyrics using the API\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"install dependencies\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%pip install lrclibapi\n", | ||
"from IPython.display import clear_output\n", | ||
"clear_output()\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Initialize the API\n", | ||
"\n", | ||
"using the `user_agent` is recommended by the API documentation\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[00:17.12] I feel your breath upon my neck\n", | ||
"[00:20.41] A soft caress as cold as death\n", | ||
"[00:29.60] I didn't know you well back then\n", | ||
"[00:32.82] I blame it all on luck and vain\n", | ||
"[00:41.37] Your blood like wine, I wanted in\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from lrclib import LrcLibAPI\n", | ||
"\n", | ||
"# Create an instance of the API\n", | ||
"api = LrcLibAPI(user_agent=\"my-app/0.0.1\")\n", | ||
"\n", | ||
"# Get lyrics for a track\n", | ||
"lyrics = api.get_lyrics(\n", | ||
" track_name=\"I Want to Live\",\n", | ||
" artist_name=\"Borislav Slavov\",\n", | ||
" album_name=\"Baldur's Gate 3 (Original Game Soundtrack)\",\n", | ||
" duration=233,\n", | ||
")\n", | ||
"\n", | ||
"found_lyrics = lyrics.synced_lyrics or lyrics.plain_lyrics\n", | ||
"print(\"\\n\".join(found_lyrics.split(\"\\n\")[:5]))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Don't know exactly what to search for?\n", | ||
"\n", | ||
"Use the search endpoint\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Exile - I Don't Want To Be A Memory (Live At Billy Bob's Texas)\n", | ||
"Don Williams - I Wouldn't Want To Live If You Didn't Love Me (Volume Three)\n", | ||
"Don Williams - I Wouldn't Want To Live If You Didn't Love Me (The Definitive Collection)\n", | ||
"Ben Harper - I Want To Be Ready (The Will To Live)\n", | ||
"Ben Harper - I Want to Be Ready (The Will to Live)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Search for a lyrics\n", | ||
"results = api.search_lyrics(\n", | ||
" track_name=\"I Want to Live\",\n", | ||
")\n", | ||
"\n", | ||
"# Print the results\n", | ||
"for result in results[:5]:\n", | ||
" print(f\"{result.artist_name} - {result.track_name} ({result.album_name})\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Fetch lyrics for a song using id\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[00:06.98] I don't want to be a memory\n", | ||
"[00:11.59] Just a shadow in your mind\n", | ||
"[00:15.25] Wanna be the one you always need\n", | ||
"[00:19.85] Not the one you left behind\n", | ||
"[00:23.54] I don't want to be a notch in your handle\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"lyrics = api.get_lyrics_by_id(results[0].id)\n", | ||
"\n", | ||
"found_lyrics = lyrics.synced_lyrics or lyrics.plain_lyrics\n", | ||
"print(\"\\n\".join(found_lyrics.split(\"\\n\")[:5]))" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.0b1" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
📝Examples | ||
=========== | ||
|
||
This section contains examples of how to use the module. | ||
|
||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
fetch_lyrics | ||
|
||
.. todo:: | ||
Add more examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.