Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ytb live (streamed) #546

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"lottie-react-native": "6.7.2",
"lru-cache": "7.14.0",
"md5": "^2.3.0",
"metro": "^0.80.10",
"metro": "^0.80.11",
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0",
"qs": "^6.13.0",
Expand Down Expand Up @@ -106,7 +106,7 @@
"react-native-track-player": "https://github.com/lovegaoshi/react-native-track-player.git#commit=6665ae0d260acdce719110bcf817fb9d9b22443d",
"react-native-url-polyfill": "^2.0.0",
"react-native-vector-icons": "^10.1.0",
"react-native-video": "^6.4.5",
"react-native-video": "^6.5.0",
"react-native-webview": "13.12.1",
"sp-react-native-in-app-updates": "^1.4.0",
"text-encoding-polyfill": "^0.6.7",
Expand Down Expand Up @@ -135,7 +135,7 @@
"@types/he": "^1.2.3",
"@types/jest": "^29.5.12",
"@types/md5": "^2.3.5",
"@types/node": "^22.5.2",
"@types/node": "^22.5.4",
"@types/react": "~18.3.5",
"@types/react-native": "^0.73.0",
"@types/react-native-background-timer": "^2.0.2",
Expand All @@ -158,7 +158,7 @@
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.35.1",
"eslint-plugin-react": "^7.35.2",
"eslint-plugin-react-hooks": "^4.6.2",
"gts": "^5.3.1",
"jest": "^29.7.0",
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/useSetupPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import useInitializeStore from '@stores/initializeStores';
import { IntentData } from '@enums/Intent';
import { useNoxSetting } from '@stores/useApp';
import usePlayStore from './usePlayStore';
import { awaitYtbiSetup } from '../utils/mediafetch/ytbi';

const { NoxAndroidAutoModule } = NativeModules;

Expand Down Expand Up @@ -55,7 +54,6 @@ export default ({ intentData }: NoxComponent.AppProps) => {
if (unmounted) return;
setPlayerReady(true);
if (unmounted) return;
awaitYtbiSetup();
checkPlayStoreUpdates();
const currentQueue = getCurrentTPQueue();
const findCurrentSong = currentQueue.find(
Expand Down
92 changes: 47 additions & 45 deletions src/utils/BiliSearch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import bilisearchFetch from '@utils/mediafetch/bilisearch';
import ytbvideoFetch from '@utils/mediafetch/ytbvideo';
import biliSearchFetch from '@utils/mediafetch/bilisearch';
import ytbVideoFetch from '@utils/mediafetch/ytbvideo';
import ytbLiveFetch from '@utils/mediafetch/ytbLive';
import localFetch from '@utils/mediafetch/local';
import { MUSICFREE, searcher } from '@utils/mediafetch/musicfree';
import { getMusicFreePlugin } from '@utils/ChromeStorage';
Expand All @@ -10,19 +11,19 @@ import biliBangumiFetch from './mediafetch/biliBangumi';
import biliAudioAMFetch from './mediafetch/biliAudioAM';
import biliAudioColleFetch from './mediafetch/biliAudioColle';
import biliAudioSimilarFetch from './mediafetch/biliAudioSimilar';
import bilivideoFetch from './mediafetch/bilivideo';
import biliavideoFetch from './mediafetch/biliavideo';
import biliseriesFetch from './mediafetch/biliseries';
import bilicolleFetch from './mediafetch/bilicolle';
import bilifavlistFetch from './mediafetch/bilifavlist';
import bilichannelFetch from './mediafetch/bilichannel';
import biliaudioFetch from './mediafetch/biliaudio';
import bilichannelAudioFetch from './mediafetch/bilichannelAudio';
import ytbplaylistFetch from './mediafetch/ytbPlaylist';
import ytbmixlistFetch from './mediafetch/ytbmixlist';
import ytbsearchFetch from './mediafetch/ytbsearch';
import bililiveFetch from './mediafetch/bililive';
import bilisubliveFetch from './mediafetch/bilisublive';
import biliVideoFetch from './mediafetch/bilivideo';
import biliAVideoFetch from './mediafetch/biliavideo';
import biliSeriesFetch from './mediafetch/biliseries';
import biliColleFetch from './mediafetch/bilicolle';
import biliFavlistFetch from './mediafetch/bilifavlist';
import biliChannelFetch from './mediafetch/bilichannel';
import biliAudioFetch from './mediafetch/biliaudio';
import biliChannelAudioFetch from './mediafetch/bilichannelAudio';
import ytbPlaylistFetch from './mediafetch/ytbPlaylist';
import ytbMixlistFetch from './mediafetch/ytbmixlist';
import ytbSearchFetch from './mediafetch/ytbsearch';
import biliLiveFetch from './mediafetch/bililive';
import biliSubliveFetch from './mediafetch/bilisublive';
import b23tvFetch from './mediafetch/b23tv';
import headRequestFetch from './mediafetch/headRequest';
import biliFavColleFetch from './mediafetch/biliFavColle';
Expand Down Expand Up @@ -100,7 +101,7 @@ export const searchBiliURLs = async ({
if (headRequestResult) {
results.songList = [headRequestResult];
} else {
// bilisearchFetch
// biliSearchFetch
switch (defaultSearch) {
case SearchOptions.ALIST:
results = await alistFetch.regexFetch({
Expand All @@ -111,7 +112,7 @@ export const searchBiliURLs = async ({
});
break;
case SearchOptions.YOUTUBE:
results = await ytbsearchFetch.regexFetch({
results = await ytbSearchFetch.regexFetch({
url: input,
progressEmitter,
fastSearch,
Expand All @@ -125,7 +126,7 @@ export const searchBiliURLs = async ({
);
break;
default:
results = await bilisearchFetch.regexFetch({
results = await biliSearchFetch.regexFetch({
url: input,
progressEmitter,
fastSearch,
Expand Down Expand Up @@ -183,52 +184,53 @@ const reExtractions: ReExtraction<NoxNetwork.NoxRegexFetch>[] = [
fetch: biliAudioColleFetch.regexFetch,
},
{
match: biliseriesFetch.regexSearchMatch,
fetch: biliseriesFetch.regexFetch,
match: biliSeriesFetch.regexSearchMatch,
fetch: biliSeriesFetch.regexFetch,
},
{ match: bilicolleFetch.regexSearchMatch, fetch: bilicolleFetch.regexFetch },
{ match: biliColleFetch.regexSearchMatch, fetch: biliColleFetch.regexFetch },
{
match: bilichannelFetch.regexSearchMatch,
fetch: bilichannelFetch.regexFetch,
match: biliChannelFetch.regexSearchMatch,
fetch: biliChannelFetch.regexFetch,
},
{
match: bilichannelAudioFetch.regexSearchMatch,
fetch: bilichannelAudioFetch.regexFetch,
match: biliChannelAudioFetch.regexSearchMatch,
fetch: biliChannelAudioFetch.regexFetch,
},
{ match: biliaudioFetch.regexSearchMatch, fetch: biliaudioFetch.regexFetch },
{ match: biliAudioFetch.regexSearchMatch, fetch: biliAudioFetch.regexFetch },
{
match: bilifavlistFetch.regexSearchMatch,
fetch: bilifavlistFetch.regexFetch,
match: biliFavlistFetch.regexSearchMatch,
fetch: biliFavlistFetch.regexFetch,
},
{
match: bilifavlistFetch.regexSearchMatch2,
fetch: bilifavlistFetch.regexFetch,
match: biliFavlistFetch.regexSearchMatch2,
fetch: biliFavlistFetch.regexFetch,
},
{ match: steriatkFetch.regexSearchMatch, fetch: steriatkFetch.regexFetch },
{ match: steriatkFetch.regexSearchMatch2, fetch: steriatkFetch.regexFetch },
{
match: ytbmixlistFetch.regexSearchMatch,
fetch: ytbmixlistFetch.regexFetch,
refresh: ytbmixlistFetch.refresh,
match: ytbMixlistFetch.regexSearchMatch,
fetch: ytbMixlistFetch.regexFetch,
refresh: ytbMixlistFetch.refresh,
},
{
match: ytbmixlistFetch.regexSearchMatch2,
fetch: ytbmixlistFetch.regexFetch,
refresh: ytbmixlistFetch.refresh,
match: ytbMixlistFetch.regexSearchMatch2,
fetch: ytbMixlistFetch.regexFetch,
refresh: ytbMixlistFetch.refresh,
},
{
match: ytbplaylistFetch.regexSearchMatch,
fetch: ytbplaylistFetch.regexFetch,
match: ytbPlaylistFetch.regexSearchMatch,
fetch: ytbPlaylistFetch.regexFetch,
},
{ match: ytbvideoFetch.regexSearchMatch, fetch: ytbvideoFetch.regexFetch },
{ match: bilivideoFetch.regexSearchMatch, fetch: bilivideoFetch.regexFetch },
{ match: ytbVideoFetch.regexSearchMatch, fetch: ytbVideoFetch.regexFetch },
{ match: ytbLiveFetch.regexSearchMatch, fetch: ytbLiveFetch.regexFetch },
{ match: biliVideoFetch.regexSearchMatch, fetch: biliVideoFetch.regexFetch },
{
match: biliavideoFetch.regexSearchMatch,
fetch: biliavideoFetch.regexFetch,
match: biliAVideoFetch.regexSearchMatch,
fetch: biliAVideoFetch.regexFetch,
},
{ match: bililiveFetch.regexSearchMatch, fetch: bililiveFetch.regexFetch },
{ match: biliLiveFetch.regexSearchMatch, fetch: biliLiveFetch.regexFetch },
{
match: bilisubliveFetch.regexSearchMatch,
fetch: bilisubliveFetch.regexFetch,
match: biliSubliveFetch.regexSearchMatch,
fetch: biliSubliveFetch.regexFetch,
},
];
21 changes: 21 additions & 0 deletions src/utils/mediafetch/ytbLive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import ytbVideoFetch from '@utils/mediafetch/ytbvideo';
import logger from '../Logger';

const regexFetch = async ({
reExtracted,
}: NoxNetwork.RegexFetchProps): Promise<NoxNetwork.NoxRegexFetch> => {
const audioInfo = await ytbVideoFetch.regexFetch({ reExtracted });
if (audioInfo.songList.length == 0) {
logger.warn(
`[ytblive] fetch failed on ${reExtracted[0]} assuming its a video`
// TODO: resolve streaming url here
);
}
return audioInfo;
};

export default {
//https://www.youtube.com/live/v2gYvMIc_XI
regexSearchMatch: /youtu.*\/live\/([A-Za-z0-9_-]{11})/,
regexFetch,
};
20 changes: 12 additions & 8 deletions src/utils/mediafetch/ytbPlaylist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ const regexFetch = async ({
reExtracted,
favList = [],
}: NoxNetwork.RegexFetchProps): Promise<NoxNetwork.NoxRegexFetch> => {
const results = await fetchYtmPlaylist(
// fetchYTPlaylist(
reExtracted[1],
// progressEmitter,
favList
);
if (results.length === 0) {
try {
const results = await fetchYtmPlaylist(
// fetchYTPlaylist(
reExtracted[1],
// progressEmitter,
favList
);
if (results.length === 0) {
throw new Error(`ytm failed to resolve ${reExtracted[1]}`);
}
return { songList: results };
} catch (e) {
return { songList: await fetchYtbiPlaylist(reExtracted[1], favList) };
}
return { songList: results };
};

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mediafetch/ytbvideo.ytbi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SongTS from '@objects/Song';
import { Source } from '@enums/MediaFetch';
import { logger } from '@utils/Logger';
import ytClient from '@utils/mediafetch/ytbi';
import { isIOS } from '../RNUtils';
import { isIOS } from '@utils/RNUtils';

export const resolveURL = async (song: NoxMedia.Song, iOS = false) => {
logger.debug(`[ytbi.js] fetch YTB playURL promise:${song.bvid}`);
Expand Down
32 changes: 16 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5937,12 +5937,12 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:^22.5.2":
version: 22.5.2
resolution: "@types/node@npm:22.5.2"
"@types/node@npm:^22.5.4":
version: 22.5.4
resolution: "@types/node@npm:22.5.4"
dependencies:
undici-types: "npm:~6.19.2"
checksum: 10c0/624a7fd76229eacc6c158eb3b9afd55b811d7f01976c5f92c630d5b9d47047cc218928c343988484a165ac400e5eb6fe70ea300fc7242deeb0e920c7724290f6
checksum: 10c0/b445daa7eecd761ad4d778b882d6ff7bcc3b4baad2086ea9804db7c5d4a4ab0298b00d7f5315fc640a73b5a1d52bbf9628e09c9fec0cf44dbf9b4df674a8717d
languageName: node
linkType: hard

Expand Down Expand Up @@ -7083,7 +7083,7 @@ __metadata:
"@types/he": "npm:^1.2.3"
"@types/jest": "npm:^29.5.12"
"@types/md5": "npm:^2.3.5"
"@types/node": "npm:^22.5.2"
"@types/node": "npm:^22.5.4"
"@types/react": "npm:~18.3.5"
"@types/react-native": "npm:^0.73.0"
"@types/react-native-background-timer": "npm:^2.0.2"
Expand Down Expand Up @@ -7118,7 +7118,7 @@ __metadata:
eslint-plugin-import: "npm:^2.30.0"
eslint-plugin-node: "npm:^11.1.0"
eslint-plugin-prettier: "npm:^5.2.1"
eslint-plugin-react: "npm:^7.35.1"
eslint-plugin-react: "npm:^7.35.2"
eslint-plugin-react-hooks: "npm:^4.6.2"
event-target-polyfill: "npm:^0.0.4"
expo: "npm:^51.0.32"
Expand All @@ -7140,7 +7140,7 @@ __metadata:
lottie-react-native: "npm:6.7.2"
lru-cache: "npm:7.14.0"
md5: "npm:^2.3.0"
metro: "npm:^0.80.10"
metro: "npm:^0.80.11"
metro-react-native-babel-preset: "npm:0.77.0"
patch-package: "npm:^8.0.0"
postinstall-postinstall: "npm:^2.1.0"
Expand Down Expand Up @@ -7177,7 +7177,7 @@ __metadata:
react-native-track-player: "https://github.com/lovegaoshi/react-native-track-player.git#commit=6665ae0d260acdce719110bcf817fb9d9b22443d"
react-native-url-polyfill: "npm:^2.0.0"
react-native-vector-icons: "npm:^10.1.0"
react-native-video: "npm:^6.4.5"
react-native-video: "npm:^6.5.0"
react-native-webview: "npm:13.12.1"
react-test-renderer: "npm:18.3.1"
reactotron-react-native: "npm:^5.1.8"
Expand Down Expand Up @@ -10064,9 +10064,9 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-react@npm:^7.35.1":
version: 7.35.1
resolution: "eslint-plugin-react@npm:7.35.1"
"eslint-plugin-react@npm:^7.35.2":
version: 7.35.2
resolution: "eslint-plugin-react@npm:7.35.2"
dependencies:
array-includes: "npm:^3.1.8"
array.prototype.findlast: "npm:^1.2.5"
Expand All @@ -10088,7 +10088,7 @@ __metadata:
string.prototype.repeat: "npm:^1.0.0"
peerDependencies:
eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7
checksum: 10c0/faaa2108543675951949685208d105d9c3efa0ac8f4d950851b8f20e065b8bf87fdd7e78abae9b0382090bc22e61c00709388f35bdab2a8b1d283f985d310ed7
checksum: 10c0/5f891f5a77e902a0ca8d10b23d0b800e90a09400187febe5986c5078d6277baa4b974d6acdbba25baae065dbcf12eb9241b5f5782527d0780314c2ee5006a8af
languageName: node
linkType: hard

Expand Down Expand Up @@ -16494,13 +16494,13 @@ __metadata:
languageName: node
linkType: hard

"react-native-video@npm:^6.4.5":
version: 6.4.5
resolution: "react-native-video@npm:6.4.5"
"react-native-video@npm:^6.5.0":
version: 6.5.0
resolution: "react-native-video@npm:6.5.0"
peerDependencies:
react: "*"
react-native: "*"
checksum: 10c0/13d5d000beeb56475f8be807a20a08b54ca70f5bf140c2d8fbee4a556934178b7dc276c74a7fd0ba4258b76c2180731964a06473bf5615ce0bff0910bb76aa3d
checksum: 10c0/55906a7f1eb01001ddb8eff7848c72ad3cf75e893d2b48926e5ff48c2a3e2ef91a0c31ecb1d9889198d2036921feb300f98c12ea162d28c8f8d25e606b6022cf
languageName: node
linkType: hard

Expand Down
Loading