@@ -62,7 +62,7 @@ export default {
6262 return sig ;
6363 } ,
6464
65- requestZing : async ( { path, qs, willHashParam } ) => {
65+ requestZing : async ( { path, qs, willHashParam, host = URL_API } ) => {
6666 let param = new URLSearchParams ( qs ) . toString ( ) ;
6767 let sig = await Utils . hashParam ( path , param , willHashParam ) ;
6868
@@ -73,7 +73,7 @@ export default {
7373 sig,
7474 } ;
7575
76- return URL_API + path + "?" + new URLSearchParams ( params ) . toString ( ) ;
76+ return host + path + "?" + new URLSearchParams ( params ) . toString ( ) ;
7777 } ,
7878 } ;
7979
@@ -134,6 +134,19 @@ export default {
134134 willHashParam : false ,
135135 } ) ;
136136 } ,
137+ async downloadSong ( id ) {
138+ return await Utils . requestZing ( {
139+ host : "https://download.zingmp3.vn" ,
140+ path : "/api/v2/download/post/song" ,
141+ qs : { id } ,
142+ } ) ;
143+ } ,
144+ async getLyric ( id ) {
145+ return await Utils . requestZing ( {
146+ path : "/api/v2/lyric/get/lyric" ,
147+ qs : { id } ,
148+ } ) ;
149+ } ,
137150 //#endregion
138151
139152 //#region other APIs
@@ -202,44 +215,33 @@ export default {
202215 qs : { page } ,
203216 } ) ;
204217 } ,
205- // async getUserListSong({
206- // type = "library",
207- // page = 1,
208- // count = 50,
209- // sectionId = "mFavSong",
210- // } = {}) {
211- // return await Utils.requestZing({
212- // path: "/api/v2/user/song/get/list",
213- // qs: { type, page, count, sectionId },
214- // // willHashParam: false,
215- // });
216- // },
217- // async getSectionPlaylist(id) {
218- // return await Utils.requestZing({
219- // path: "/api/v2/playlist/getSectionBottom",
220- // qs: { id },
221- // });
222- // },
223- // async getLastPlaying() {
224- // return await Utils.requestZing({
225- // path: "/api/v2/user/lasplaying/get/lasplaying",
226- // });
227- // },
218+ async getLastPlaying ( ) {
219+ return await Utils . requestZing ( {
220+ path : "/api/v2/user/lasplaying/get/lasplaying" ,
221+ } ) ;
222+ } ,
228223 //#endregion
229224 } ;
230225
231226 ( async function ( ) {
232- // window.open(await ZingMp3.search("game thủ liên minh"));
233- // window.open(await ZingMp3.getLastPlaying());
234227 // window.open(await ZingMp3.getHome());
235- // window.open(await ZingMp3.getChartHome());
236- // window.open(await ZingMp3.getInfoMusic("ZWFE8OUO"));
237- // window.open(await ZingMp3.getStreaming("Z6WZD78I"));
228+ // window.open(await ZingMp3.getLyric("ZZDEZ8UC"));
229+ // window.open(await ZingMp3.getInfoMusic("ZZDEZ8UC"));
230+ // window.open(await ZingMp3.getStreaming("ZZDEZ8UC"));
231+ // window.open(await ZingMp3.search("game thủ liên minh"));
232+ // window.open(await ZingMp3.getUserMusicOverview());
233+ // window.open(await ZingMp3.getDetailPlaylist("Z6CZOIWU"));
234+ // window.open(await ZingMp3.getDetailArtist("ICM"));
235+
236+ // window.open(await ZingMp3.getChartHome()); // => die
237+ // window.open(await ZingMp3.getLastPlaying()); // => not working?
238+ // window.open(await ZingMp3.downloadSong("Z7ZCD9BD")); // => some songs be blocked on pc
239+ // return;
238240
239241 const tab = await getCurrentTab ( ) ;
240- let url = prompt ( "Nhap link bai hat : " , tab . url ) ;
242+ let url = prompt ( "Nhập link hoặc id bài hát : " , tab . url ) ;
241243 if ( url ) {
242- let songid = ZingMp3 . getSongIdFromURL ( url ) ;
244+ let songid = url . length > 10 ? ZingMp3 . getSongIdFromURL ( url ) : url ;
243245 if ( songid ) {
244246 try {
245247 const streamUrl = await ZingMp3 . getStreaming ( songid ) ;
0 commit comments