|
@@ -459,7 +459,7 @@ search = async (keyword, next, platform) => {
|
|
|
if (printable(platform)) {
|
|
|
console.log(video);
|
|
|
}
|
|
|
- if (video && video["videoId"]) {
|
|
|
+ if (video && video["videoId"] && video["lengthText"]) {
|
|
|
videos.push({
|
|
|
"type": "videoWithContextRenderer",
|
|
|
"data": {
|
|
@@ -503,27 +503,36 @@ search = async (keyword, next, platform) => {
|
|
|
}
|
|
|
|
|
|
const ytInitialDataResp = JSON.parse(match[1]);
|
|
|
+ if (printable(platform)) {
|
|
|
+ console.log(ytInitialDataResp);
|
|
|
+ }
|
|
|
const videos = [];
|
|
|
- for (const item of ytInitialDataResp["contents"]?.["twoColumnSearchResultsRenderer"]?.["primaryContents"]?.["sectionListRenderer"]?.["contents"]?.[0]?.["itemSectionRenderer"]?.["contents"]) {
|
|
|
- if (item["videoRenderer"]) {
|
|
|
- const video = item["videoRenderer"];
|
|
|
- if (printable(platform)) {
|
|
|
- console.log(video);
|
|
|
- }
|
|
|
- if (video && video["videoId"]) {
|
|
|
- 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 contents = ytInitialDataResp["contents"]?.["twoColumnSearchResultsRenderer"]?.["primaryContents"]?.["sectionListRenderer"]?.["contents"] || []
|
|
|
+ for (const content of contents) {
|
|
|
+ const currentContents = content["itemSectionRenderer"]?.["contents"]
|
|
|
+ if (Array.isArray(currentContents)) {
|
|
|
+ for (const currentContent of currentContents) {
|
|
|
+ if (currentContent["videoRenderer"]) {
|
|
|
+ const video = currentContent["videoRenderer"];
|
|
|
+ if (printable(platform)) {
|
|
|
+ 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"]
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -536,7 +545,7 @@ search = async (keyword, next, platform) => {
|
|
|
.split(",")[0]
|
|
|
.split('"')[2];
|
|
|
}
|
|
|
- next["continuation"] = ytInitialDataResp["contents"]?.["twoColumnSearchResultsRenderer"]?.["primaryContents"]?.["sectionListRenderer"]?.["contents"]?.[1]?.["continuationItemRenderer"]?.["continuationEndpoint"]?.["continuationCommand"]?.["token"]
|
|
|
+ next["continuation"] = contents[contents.length - 1]?.["continuationItemRenderer"]?.["continuationEndpoint"]?.["continuationCommand"]?.["token"]
|
|
|
|
|
|
const ret = {
|
|
|
"code": 200,
|