Skip to content

Commit

Permalink
Allow skip netease API
Browse files Browse the repository at this point in the history
  • Loading branch information
mantou132 committed Jul 28, 2023
1 parent 9e476ae commit bb43c30
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/page/config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"API_HOST": "https://music.xianqiao.wang/neteaseapiv2",
"LOGGED_MARK_SELECTOR": "header [data-testid=user-widget-link]",
"LYRICS_CONTAINER_SELECTOR": ".Root__nav-bar > div",
"PAGE_PIP_STYLE": "position: relative; width: 100%; height: auto;",
"LYRICS_CONTAINER_SELECTOR": "nav[aria-label=Main] > div:last-of-type",
"PAGE_PIP_STYLE": "position: relative; width: 100%; height: auto; border-radius: inherit;",
"ALBUM_COVER_SELECTOR": "[role=contentinfo] > div:nth-child(1) img",
"ALBUM_COVER_LARGE_REGEXP_REPLACE": ["00004851(?=\\w{24}$)", "0000b273"],
"TRACK_INFO_SELECTOR": "[role=contentinfo] > div:nth-child(2)",
Expand Down
19 changes: 14 additions & 5 deletions src/page/lyrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { sify, tify } from 'chinese-conv';
import { isProd } from '../common/consts';

import config from './config';
import { optionsPromise } from './options';
import { request } from './request';
import { captureException } from './utils';

Expand Down Expand Up @@ -149,11 +150,19 @@ async function fetchSongList(s: string, fetchOptions?: RequestInit): Promise<Son
type: '1',
limit: '100',
});
const { result }: SearchSongsResult = await request(
`${API_HOST}/search?${searchQuery}`,
fetchOptions,
);
return result?.songs || [];
const options = await optionsPromise;
const fetchPromise = request(`${API_HOST}/search?${searchQuery}`, fetchOptions);
if (!options['use-unreviewed-lyrics']) {
const { result }: SearchSongsResult = await fetchPromise;
return result?.songs || [];
}
try {
const { result }: SearchSongsResult = await fetchPromise;
return result?.songs || [];
} catch (err) {
console.error(err);
return [];
}
}

interface MatchingLyricsOptions {
Expand Down

0 comments on commit bb43c30

Please sign in to comment.