forked from kenmingwang/azusa-player
-
Notifications
You must be signed in to change notification settings - Fork 5
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 #83 from lovegaoshi/dev-noxplayer
feat: ytbi
- Loading branch information
Showing
11 changed files
with
172 additions
and
177 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
Submodule azusa-player-mobile
updated
46 files
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
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,52 @@ | ||
import SongTS from '@objects/Song'; | ||
import { Source } from '@enums/MediaFetch'; | ||
import { Innertube } from 'youtubei.js/web'; | ||
|
||
const ytClient = Innertube.create({ | ||
fetch: async (input, init?: RequestInit) => { | ||
// Modify the request | ||
// and send it to the proxy | ||
|
||
// fetch the URL | ||
|
||
// @ts-expect-error | ||
return fetch(input, init); | ||
}, | ||
}); | ||
|
||
export const resolveURL = async (song: NoxMedia.Song) => { | ||
const yt = await ytClient; | ||
const extractedVideoInfo = await yt.getInfo(song.bvid); | ||
const maxAudioQualityStream = extractedVideoInfo.chooseFormat({ | ||
quality: 'best', | ||
type: 'audio', | ||
}); | ||
return { | ||
url: maxAudioQualityStream.decipher(yt.session.player), | ||
loudness: maxAudioQualityStream.loudness_db, | ||
}; | ||
}; | ||
|
||
export const fetchAudioInfo = async (sid: string) => { | ||
const yt = await ytClient; | ||
const videoInfo = (await yt.getBasicInfo(sid)).basic_info; | ||
return [ | ||
SongTS({ | ||
cid: `${Source.ytbvideo}-${sid}`, | ||
bvid: sid, | ||
name: videoInfo.title!, | ||
nameRaw: videoInfo.title!, | ||
singer: videoInfo.author!, | ||
singerId: videoInfo.channel_id!, | ||
cover: videoInfo.thumbnail | ||
? videoInfo.thumbnail[videoInfo.thumbnail.length - 1]!.url | ||
: '', | ||
lyric: '', | ||
page: 1, | ||
duration: videoInfo.duration, | ||
album: videoInfo.title!, | ||
source: Source.ytbvideo, | ||
metadataOnLoad: true, | ||
}), | ||
]; | ||
}; |
Oops, something went wrong.