Skip to content

Commit

Permalink
core: add build config and fix http image.
Browse files Browse the repository at this point in the history
  • Loading branch information
hu-qi committed Mar 22, 2024
1 parent aeac9b4 commit cc0ff32
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 93 deletions.
38 changes: 28 additions & 10 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ react {
/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
*/
def enableProguardInReleaseBuilds = false
def enableProguardInReleaseBuilds = true

/**
* The preferred build flavor of JavaScriptCore (JSC)
Expand Down Expand Up @@ -83,25 +83,43 @@ android {
versionName "1.0"
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
// debug {
// storeFile file('debug.keystore')
// storePassword 'android'
// keyAlias 'androiddebugkey'
// keyPassword 'android'
// }

release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
// debug {
// signingConfig signingConfigs.debug
// }
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}

splits {
abi {
reset()
enable true
universalApk true
include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
}
}

dependencies {
Expand Down
5 changes: 5 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ newArchEnabled=false
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true

MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=listen1
MYAPP_RELEASE_KEY_PASSWORD=listen1
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"build": "cd android && ./gradlew assembleRelease",
"build:aab": "npx react-native build-android --mode=release",
"lint": "eslint .",
"start": "react-native start",
"test": "jest",
"react-devtools": "react-devtools",
"debug": "npx react-native start --experimental-debugger"
"debug": "npx react-native start --experimental-debugger",
"clean:android": "cd android && ./gradlew clean && rm -rf app/build",
"clean:ios": "cd ios && pod deintegrate && pod clean && rm -rf ~/Library/Developer/Xcode/DerivedData/"
},
"dependencies": {
"@appcube/react-native-scrollable-tab-view": "^1.1.1",
Expand Down
54 changes: 27 additions & 27 deletions src/api/provider/kugou.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function requestAPI(url, data) {
return await fetch(url, {
method: 'get',
headers: {
referer: 'http://m.kugou.com',
referer: 'https://m.kugou.com',
'content-type': 'application/x-www-form-urlencoded',
'user-agent':
'Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; BLA-AL00 Build/HUAWEIBLA-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/8.9 Mobile Safari/537.36',
Expand Down Expand Up @@ -81,7 +81,7 @@ function getSmallImageUrl(url) {
return `${url}?param=140y140`;
}
function showPlaylist(offset) {
const url = `http://m.kugou.com/plist/index?json=true&page=${offset}`;
const url = `https://m.kugou.com/plist/index?json=true&page=${offset}`;
return fetch(url)
.then(response => {
return response.json();
Expand All @@ -92,7 +92,7 @@ function showPlaylist(offset) {
title: item.specialname,
id: `kgplaylist_${item.specialid}`,
source_url:
'http://www.kugou.com/yy/special/single/{size}.html'.replace(
'https://www.kugou.com/yy/special/single/{size}.html'.replace(
'{size}',
item.specialid,
),
Expand Down Expand Up @@ -168,7 +168,7 @@ function convert(allowAll) {
album: songInfo.al.name,
album_id: `nealbum_${songInfo.al.id}`,
source: 'netease',
source_url: `http://music.163.com/#/song?id=${songInfo.id}`,
source_url: `https://music.163.com/#/song?id=${songInfo.id}`,
img_url: getSmallImageUrl(songInfo.al.picUrl),
url: `netrack_${songInfo.id}`,
disabled: allowAll ? false : !isPlayable(songInfo),
Expand All @@ -191,7 +191,7 @@ function getPlaylist(playlistId) {
}

async function kg_artist(listId) {
let target_url = `http://mobilecdnbj.kugou.com/api/v3/singer/info?singerid=${listId}`;
let target_url = `https://mobilecdnbj.kugou.com/api/v3/singer/info?singerid=${listId}`;
const info = await fetch(target_url)
.then(response => {
return response.json();
Expand All @@ -203,13 +203,13 @@ async function kg_artist(listId) {
cover_img_url: data.data.imgurl.replace('{size}', '400'),
title: data.data.singername,
id: `kgartist_${listId}`,
source_url: 'http://www.kugou.com/singer/{id}.html'.replace(
source_url: 'https://www.kugou.com/singer/{id}.html'.replace(
'{id}',
listId,
),
};
});
target_url = `http://mobilecdnbj.kugou.com/api/v3/singer/song?singerid=${listId}&page=1&pagesize=30`;
target_url = `https://mobilecdnbj.kugou.com/api/v3/singer/song?singerid=${listId}&page=1&pagesize=30`;

const tracks = await fetch(target_url)
.then(response => {
Expand All @@ -230,7 +230,7 @@ async function kg_render_artist_result_item(item, info) {
album: '',
album_id: `kgalbum_${item.album_id}`,
source: 'kugou',
source_url: `http://www.kugou.com/song/#hash=${item.hash}&album_id=${item.album_id}`,
source_url: `https://www.kugou.com/song/#hash=${item.hash}&album_id=${item.album_id}`,
img_url: '',
url: `kgtrack_${item.hash}`,
lyric_url: item.hash,
Expand All @@ -240,10 +240,10 @@ async function kg_render_artist_result_item(item, info) {
track.artist = one[0].trim();
// Fix album name and img
const target_url = `${
'http://www.kugou.com/yy/index.php?' + 'r=play/getdata&hash='
'https://www.kugou.com/yy/index.php?' + 'r=play/getdata&hash='
}${item.hash}`;
await fetch(
`http://mobilecdnbj.kugou.com/api/v3/album/info?albumid=${item.album_id}`,
`https://mobilecdnbj.kugou.com/api/v3/album/info?albumid=${item.album_id}`,
)
.then(response => {
return response.json();
Expand Down Expand Up @@ -272,7 +272,7 @@ async function kg_render_artist_result_item(item, info) {
async function kg_album(listId) {
// eslint-disable-line no-unused-vars
let target_url = `${
'http://mobilecdnbj.kugou.com/api/v3/album/info?' + 'albumid='
'https://mobilecdnbj.kugou.com/api/v3/album/info?' + 'albumid='
}${listId}`;

const info = await fetch(target_url)
Expand All @@ -287,14 +287,14 @@ async function kg_album(listId) {
cover_img_url: data.data.imgurl.replace('{size}', '400'),
title: data.data.albumname,
id: `kgalbum_${data.data.albumid}`,
source_url: 'http://www.kugou.com/album/{id}.html'.replace(
source_url: 'https://www.kugou.com/album/{id}.html'.replace(
'{id}',
data.data.albumid,
),
};
});
target_url = `${
'http://mobilecdnbj.kugou.com/api/v3/album/song?' + 'albumid='
'https://mobilecdnbj.kugou.com/api/v3/album/song?' + 'albumid='
}${listId}&page=1&pagesize=-1`;
const tracks = await fetch(target_url).then(res => {
let res_data = res.data;
Expand All @@ -307,7 +307,7 @@ async function kg_album(listId) {
}

async function kg_get_playlist(listId) {
// const target_url = `http://m.kugou.com/plist/list/${listId}?json=true`;
// const target_url = `https://m.kugou.com/plist/list/${listId}?json=true`;
const target_url = `https://www.kugou.com/yy/special/single/${listId}.html`;
const res_data = await axios.get(target_url, {
headers: {
Expand All @@ -330,7 +330,7 @@ async function kg_get_playlist(listId) {
cover_img_url: specialInfo.image ? specialInfo.image : '',
title: specialInfo.name,
id: `kgplaylist_${specialInfo.id}`,
source_url: 'http://www.kugou.com/yy/special/single/{size}.html'.replace(
source_url: 'https://www.kugou.com/yy/special/single/{size}.html'.replace(
'{size}',
specialInfo.id,
),
Expand All @@ -349,7 +349,7 @@ async function kg_get_playlist(listId) {
}

async function kg_render_playlist_result_item(item) {
let target_url = `http://m.kugou.com/app/i/getSongInfo.php?cmd=playInfo&hash=${item.hash}`;
let target_url = `https://m.kugou.com/app/i/getSongInfo.php?cmd=playInfo&hash=${item.hash}`;

const track = {
id: `kgtrack_${item.hash}`,
Expand All @@ -359,14 +359,14 @@ async function kg_render_playlist_result_item(item) {
album: '',
album_id: `kgalbum_${item.album_id}`,
source: 'kugou',
source_url: `http://www.kugou.com/song/#hash=${item.hash}&album_id=${item.album_id}`,
source_url: `https://www.kugou.com/song/#hash=${item.hash}&album_id=${item.album_id}`,
img_url: '',
url: `xmtrack_${item.hash}`,
lyric_url: item.hash,
};
// Fix song info

await fetch(target_url, {headers: {referer: 'http://www.kugou.com/'}})
await fetch(target_url, {headers: {referer: 'https://www.kugou.com/'}})
.then(response => {
return response.json();
})
Expand All @@ -384,7 +384,7 @@ async function kg_render_playlist_result_item(item) {
}
// Fix album
});
target_url = `http://mobilecdnbj.kugou.com/api/v3/album/info?albumid=${item.album_id}`;
target_url = `https://mobilecdnbj.kugou.com/api/v3/album/info?albumid=${item.album_id}`;
fetch(target_url)
.then(response => {
return response.json();
Expand Down Expand Up @@ -416,14 +416,14 @@ async function kg_render_album_result_item(item, info, album_id) {
album: info.title,
album_id: `kgalbum_${album_id}`,
source: 'kugou',
source_url: `http://www.kugou.com/song/#hash=${item.hash}&album_id=${album_id}`,
source_url: `https://www.kugou.com/song/#hash=${item.hash}&album_id=${album_id}`,
img_url: '',
url: `xmtrack_${item.hash}`,
lyric_url: item.hash,
};
// Fix other data
const target_url = `${
'http://m.kugou.com/app/i/getSongInfo.php?' + 'cmd=playInfo&hash='
'https://m.kugou.com/app/i/getSongInfo.php?' + 'cmd=playInfo&hash='
}${item.hash}`;
await fetch(target_url)
.then(response => {
Expand All @@ -440,11 +440,11 @@ async function kg_render_album_result_item(item, info, album_id) {

async function bootstrapTrack(trackId) {
const song_id = trackId.slice('kgtrack_'.length);
let target_url = `http://m.kugou.com/app/i/getSongInfo.php?cmd=playInfo&hash=${song_id}`;
let target_url = `https://m.kugou.com/app/i/getSongInfo.php?cmd=playInfo&hash=${song_id}`;

return fetch(target_url, {
headers: {
referer: 'http://m.kugou.com',
referer: 'https://m.kugou.com',
'content-type': 'application/x-www-form-urlencoded',
},
})
Expand All @@ -455,7 +455,7 @@ async function bootstrapTrack(trackId) {
}

async function search(keyword, curpage) {
const target_url = `http://songsearch.kugou.com/song_search_v2?keyword=${keyword}&page=${curpage}`;
const target_url = `https://songsearch.kugou.com/song_search_v2?keyword=${keyword}&page=${curpage}`;
return requestAPI(target_url).then(({data}) => {
const tracks = data.lists.map(t => kg_render_search_result_item(t));
return {
Expand All @@ -468,9 +468,9 @@ async function search(keyword, curpage) {
function kg_render_search_result_item(item) {
const track = kg_convert_song(item);
// Add singer img
const url = `http://www.kugou.com/yy/index.php?r=play/getdata&hash=${track.lyric_url}`;
const url = `https://www.kugou.com/yy/index.php?r=play/getdata&hash=${track.lyric_url}`;
requestAPI(url).then(data => {
console.log(data)
// console.log(data)
if(data.data && data.data.img) {
track.img_url = data.data.img;
}
Expand All @@ -488,7 +488,7 @@ function kg_convert_song(song) {
album: song.AlbumName,
album_id: `kgalbum_${song.AlbumID}`,
source: 'kugou',
source_url: `http://www.kugou.com/song/#hash=${song.FileHash}&album_id=${song.AlbumID}`,
source_url: `https://www.kugou.com/song/#hash=${song.FileHash}&album_id=${song.AlbumID}`,
img_url: song.Image ? song.Image.replace('{size}', '400') : '',
url: `kgtrack_${song.FileHash}`,
lyric_url: song.FileHash,
Expand Down
20 changes: 10 additions & 10 deletions src/api/provider/kuwo.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function requestAPI(url, data, refreshToken = false) {
},
})
.then((response) => {
console.log('response', response);
// console.log('response', response);
return response.json();
})
.then((response) => {
Expand All @@ -61,7 +61,7 @@ function getSmallImageUrl(url) {
return `${url}?param=140y140`;
}
function showPlaylist(offset) {
const url = `http://www.kuwo.cn/www/categoryNew/getPlayListInfoUnderCategory?type=taglist&digest=10000&id=37&start=${
const url = `https://www.kuwo.cn/www/categoryNew/getPlayListInfoUnderCategory?type=taglist&digest=10000&id=37&start=${
offset * 30
}&count=30`;

Expand All @@ -77,7 +77,7 @@ function showPlaylist(offset) {
cover_img_url: item.img,
title: item.name,
id: `kwplaylist_${item.id}`,
source_url: `http://www.kuwo.cn/playlist/index?pid=${item.id}`,
source_url: `https://www.kuwo.cn/playlist/index?pid=${item.id}`,
}));
return { result, hasNextPage: true };
})
Expand Down Expand Up @@ -150,7 +150,7 @@ function convert(allowAll) {
album: songInfo.al.name,
album_id: `nealbum_${songInfo.al.id}`,
source: 'netease',
source_url: `http://music.163.com/#/song?id=${songInfo.id}`,
source_url: `https://music.163.com/#/song?id=${songInfo.id}`,
img_url: getSmallImageUrl(songInfo.al.picUrl),
url: `netrack_${songInfo.id}`,
disabled: allowAll ? false : !isPlayable(songInfo),
Expand All @@ -173,7 +173,7 @@ function getPlaylist(playlistId) {
}

async function kw_get_playlist(playlistId) {
const target_url = `http://nplserver.kuwo.cn/pl.svc?op=getlistinfo&pn=0&rn=200&encode=utf-8&keyset=pl2012&pcmp4=1&pid=${playlistId}&vipver=MUSIC_9.0.2.0_W1&newver=1`;
const target_url = `https://nplserver.kuwo.cn/pl.svc?op=getlistinfo&pn=0&rn=200&encode=utf-8&keyset=pl2012&pcmp4=1&pid=${playlistId}&vipver=MUSIC_9.0.2.0_W1&newver=1`;

return await fetch(target_url)
.then((response) => {
Expand All @@ -184,7 +184,7 @@ async function kw_get_playlist(playlistId) {
cover_img_url: data.pic,
title: data.title,
id: `kwplaylist_${data.id}`,
source_url: `http://www.kuwo.cn/playlist/index?pid=${data.id}`,
source_url: `https://www.kuwo.cn/playlist/index?pid=${data.id}`,
};

const tracks = data.musiclist.map((t) =>
Expand All @@ -207,12 +207,12 @@ function kw_render_playlist_result_item(item) {
album: html_decode(item.album),
album_id: `kwalbum_${item.albumid}`,
source: 'kuwo',
source_url: `http://www.kuwo.cn/yinyue/${item.id}`,
source_url: `https://www.kuwo.cn/yinyue/${item.id}`,
img_url: '',
url: `xmtrack_${item.id}`,
lyric_url: item.id,
};
const target_url = `http://artistpicserver.kuwo.cn/pic.web?type=rid_pic&pictype=url&size=240&rid=${item.id}`;
const target_url = `https://artistpicserver.kuwo.cn/pic.web?type=rid_pic&pictype=url&size=240&rid=${item.id}`;
fetch(target_url)
.then((response) => {
return response.text();
Expand All @@ -227,7 +227,7 @@ function bootstrapTrack(trackId) {
const songId = trackId.slice('kwtrack_'.length);

const target_url = `${
'http://antiserver.kuwo.cn/anti.s?' +
'https://antiserver.kuwo.cn/anti.s?' +
'type=convert_url&format=mp3&response=url&rid='
}${songId}`;

Expand Down Expand Up @@ -286,7 +286,7 @@ async function search(keyword, curpage) {
album: html_decode(item.ALBUM),
album_id: `kwalbum_${item.ALBUMID}`,
source: 'kuwo',
source_url: `http://www.kuwo.cn/yinyue/${musicrid}`,
source_url: `https://www.kuwo.cn/yinyue/${musicrid}`,
img_url: item.web_artistpic_short? `https://img1.kuwo.cn/star/starheads/${item.web_artistpic_short}` : `https://img2.kuwo.cn/star/albumcover/${item.web_albumpic_short}`,
url: `xmtrack_${musicrid}`,
lyric_url: musicrid,
Expand Down
Loading

0 comments on commit cc0ff32

Please sign in to comment.