|
@@ -425,3 +425,50 @@ search = async (keyword, next, requestId, platform) => {
|
|
|
return ret;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+recommend = async (requestId, platform) => {
|
|
|
+ try {
|
|
|
+ const body = {
|
|
|
+ "context": {
|
|
|
+ "client": {
|
|
|
+ "clientName": "WEB", "clientVersion": "2.20240304.00.00"
|
|
|
+ }
|
|
|
+ }, "browseId": "VLPL4fGSI1pDJn69On1f-8NAvX_CYlx7QyZc"
|
|
|
+ }
|
|
|
+ let res = await request('POST', `https://www.youtube.com/youtubei/v1/browse?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8`, JSON.stringify(body), {}, requestId, platform);
|
|
|
+ const {data, _} = res;
|
|
|
+ res = JSON.parse(data);
|
|
|
+ const videos = [];
|
|
|
+ for (const item of res["contents"]["twoColumnBrowseResultsRenderer"]["tabs"][0]["tabRenderer"]["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"]["0"]["playlistVideoListRenderer"]["contents"]) {
|
|
|
+ const video = item["playlistVideoRenderer"];
|
|
|
+ console.log(video);
|
|
|
+ if (video && video["videoId"] && video["lengthText"]) {
|
|
|
+ videos.push({
|
|
|
+ "type": "videoWithContextRenderer", "data": {
|
|
|
+ "videoId": video["videoId"],
|
|
|
+ "title": video["title"]?.["runs"]?.[0]?.["text"],
|
|
|
+ "thumbnails": video["thumbnail"]?.["thumbnails"],
|
|
|
+ "channelName": video["longBylineText"]?.["runs"]?.[0]?.["text"],
|
|
|
+ "publishedTimeText": video["publishedTimeText"]?.["simpleText"],
|
|
|
+ "viewCountText": video["viewCountText"]?.["simpleText"],
|
|
|
+ "shortViewCountText": video["shortViewCountText"]?.["simpleText"],
|
|
|
+ "lengthText": video["lengthText"]?.["simpleText"]
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const ret = {
|
|
|
+ "code": 200, "msg": "", "requestId": requestId, "data": {
|
|
|
+ "data": videos,
|
|
|
+ }, "id": "MusicRecommendResultViewModel_recommend_result"
|
|
|
+ }
|
|
|
+ console.log(`recommend result: ${JSON.stringify(ret)}`);
|
|
|
+ return ret;
|
|
|
+ } catch (e) {
|
|
|
+ const ret = {
|
|
|
+ "code": -1, "msg": e.toString(), "requestId": requestId,
|
|
|
+ }
|
|
|
+ console.log(`recommend result error: ${JSON.stringify(ret)}`);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+}
|