-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Search Page: Add Youtube provider (#4)
* WIP * wip * wip * ✨ youtube search works fine (wip: CSS) * wip: ytmusic-api * WIP * 🔧 next config images * ✨ switched to yt-music api -> /search is done * 🐛 TS build error * ♻️ search page - improve loading status * ♻️ fix client things * ♻️ moved playerRef to zustand YTPlayerStore * ✨ add volume control and better handling of currentPlaybackState.device * ✨ handle youtube player mute * ♻️ youtube search works fine * ♻️ remove contextUri on search page tracklist * ✨ add search dropdown to select a provider * ♻️ clownesque * 💄 search bar * ♻️ add "origin" key in track object * 🐛 previous tracks are now hidden when search page is fetching data * ♻️ add "origin" key in tracks * ♻️ --------- Co-authored-by: Faïssal <fhattou.ext@unowhy.com> Co-authored-by: Faïssal <fhattou@ippon.fr>
- Loading branch information
1 parent
6a4eab7
commit 5f3176b
Showing
41 changed files
with
939 additions
and
157 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { NextResponse } from "next/server"; | ||
import YTMusic from "ytmusic-api"; | ||
|
||
export async function GET(req: Request) { | ||
const { searchParams } = new URL(req.url); | ||
const query = searchParams.get("query"); | ||
|
||
if (!query) throw new Error("search/youtube: query not provided"); | ||
|
||
const ytmusic = new YTMusic(); | ||
|
||
try { | ||
await ytmusic.initialize(); | ||
const songs = await ytmusic.searchSongs(query); | ||
const videos = await ytmusic.searchVideos(query); | ||
|
||
// TODO display the most closest to the search | ||
const result = await Promise.all([...songs, ...videos]); | ||
|
||
return NextResponse.json({ result }); | ||
} catch (error) { | ||
console.log("Catch", error); | ||
} | ||
} |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 @@ | ||
"use client"; | ||
|
||
import { Dispatch, SetStateAction, useState } from "react"; | ||
import Link from "next/link"; | ||
|
||
|
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
Oops, something went wrong.