-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update genius-lyrics extension (#13432)
* Update genius-lyrics extension - Added New Command - Added New Command - Initial commit * Removed axios, switched to useFetch; Renamed commands; Changed the formatting of results * Removed axios from dependencies * Update CHANGELOG.md * Update CHANGELOG.md and optimise images --------- Co-authored-by: Milena Araujo <mil3na@users.noreply.github.com> Co-authored-by: raycastbot <bot@raycast.com>
- Loading branch information
1 parent
f8241a7
commit 6b08ea8
Showing
5 changed files
with
188 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# Genius Lyrics Changelog | ||
|
||
## [Initial Version] - 2024-05-12 | ||
## [New Command] - 2024-07-12 | ||
|
||
- Added the `Search with Lyrics` Command | ||
|
||
## [Initial Version] - 2024-05-12 |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Genius Lyrics | ||
|
||
Query and quickly read lyrics for any song from the Genius API. | ||
Search by song title to instantly view lyrics, or enter remembered lyrics to quickly find the song's title, utilizing the Genius Lyrics API. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,64 @@ | ||
import { useState } from "react"; | ||
import { List, LaunchProps, Action, ActionPanel } from "@raycast/api"; | ||
import { useFetch } from "@raycast/utils"; | ||
|
||
const GENIUS_SEARCH_URL = "https://genius.com/api/search/lyrics?q="; | ||
|
||
interface SearchResults { | ||
id: number; | ||
title: string; | ||
url: string; | ||
header_image_url: string; | ||
primary_artist: { | ||
name: string; | ||
}; | ||
} | ||
|
||
interface SearchHit { | ||
result: SearchResults; | ||
highlights: { | ||
value: string; | ||
}[]; | ||
} | ||
|
||
interface SearchSections { | ||
hits: SearchHit[]; | ||
} | ||
|
||
interface SearchResponse { | ||
sections: SearchSections[]; | ||
} | ||
|
||
interface SearchData { | ||
response: SearchResponse; | ||
} | ||
|
||
export default function Command(props: LaunchProps<{ arguments: { query: string } }>) { | ||
const [searchQuery, setSearchQuery] = useState(props.arguments.query || ""); | ||
|
||
const { data, isLoading } = useFetch<SearchData>(`${GENIUS_SEARCH_URL}${encodeURIComponent(searchQuery)}`); | ||
|
||
const results = (data?.response?.sections?.[0]?.hits as SearchHit[]) || []; | ||
|
||
return ( | ||
<List isLoading={isLoading} onSearchTextChange={setSearchQuery} searchBarPlaceholder="Enter lyrics..."> | ||
{results.map((hit: SearchHit) => ( | ||
<List.Item | ||
key={hit.result.id} | ||
title={`${hit.result.title} by ${hit.result.primary_artist.name}`} | ||
subtitle={`${hit.highlights[0].value.replace("\n", " ")}`} | ||
icon={hit.result.header_image_url} | ||
actions={ | ||
<ActionPanel title="Actions"> | ||
<Action.OpenInBrowser url={hit.result.url} /> | ||
<Action.CopyToClipboard | ||
title="Copy Song and Artist to Clipboard" | ||
content={`${hit.result.title} by ${hit.result.primary_artist.name}`} | ||
/> | ||
</ActionPanel> | ||
} | ||
/> | ||
))} | ||
</List> | ||
); | ||
} |