-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change libs to not use Freetube components anymore. Closes #79
- Loading branch information
1 parent
7b2e0fa
commit 3dc7564
Showing
50 changed files
with
957 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const ytdl = require('ytdl-core'); | ||
import ytdl from 'ytdl-core'; | ||
|
||
let query = process.argv[2]; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
const ytch = require('yt-channel-info') | ||
import { Innertube } from 'youtubei.js'; | ||
|
||
let channelId = process.argv[2]; | ||
const payload = { | ||
channelId: channelId, | ||
} | ||
const youtube = await Innertube.create({ | ||
lang: 'en', | ||
location: 'US', | ||
}); | ||
|
||
ytch.getChannelInfo(payload).then(d => console.log(JSON.stringify(d, null, 2)), e => console.error(JSON.stringify(e, null, 2))); | ||
const channelId = process.argv[2]; | ||
const channel = await youtube.getChannel(channelId) | ||
|
||
console.log(JSON.stringify(channel, null, 2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,33 @@ | ||
const ytch = require('yt-channel-info') | ||
import { Innertube, YTNodes } from 'youtubei.js'; | ||
|
||
let channelId = process.argv[2]; | ||
let sortBy = process.argv[3]; | ||
let continuation = process.argv[4]; | ||
const yt = await Innertube.create({ | ||
lang: 'en', | ||
location: 'US', | ||
}); | ||
|
||
if (continuation) { | ||
const payload = { | ||
continuation: continuation, | ||
} | ||
ytch.getChannelVideosMore(payload).then(d => console.log(JSON.stringify(d, null, 2)), e => console.error(JSON.stringify(e, null, 2))); | ||
const channelId = process.argv[2]; | ||
const continuation = JSON.parse(process.argv[3]) | ||
|
||
let videos = null | ||
let continuationData = null | ||
if (Object.keys(continuation).length) { | ||
const response = await yt.actions.execute(continuation.endpoint.metadata.api_url, { | ||
...continuation.endpoint.payload, | ||
parse: true | ||
}); | ||
|
||
videos = response.on_response_received_actions_memo.getType(YTNodes.Video) | ||
continuationData = response.on_response_received_actions_memo.getType(YTNodes.ContinuationItem).at(0) | ||
} else { | ||
const payload = { | ||
channelId: channelId, | ||
sortBy: sortBy, | ||
} | ||
ytch.getChannelVideos(payload).then(d => console.log(JSON.stringify(d, null, 2)), e => console.error(JSON.stringify(e, null, 2))); | ||
const channel = await yt.getChannel(channelId) | ||
const channelVideos = await channel.getVideos() | ||
continuationData = channelVideos.memo.getType(YTNodes.ContinuationItem).at(0) | ||
videos = channelVideos.memo.getType(YTNodes.Video) | ||
} | ||
|
||
const result = { | ||
items: videos, | ||
continuation: continuationData | ||
} | ||
|
||
console.log(JSON.stringify(result, null, 2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
const ytcm = require("@freetube/yt-comment-scraper"); | ||
import { Innertube, YTNodes } from 'youtubei.js'; | ||
|
||
let query = process.argv[2]; | ||
let replyToken = process.argv[3]; | ||
const yt = await Innertube.create({ | ||
lang: 'en', | ||
location: 'US', | ||
}); | ||
|
||
const payload = { | ||
videoId: query, | ||
replyToken: replyToken, | ||
const continuation = JSON.parse(process.argv[2]); | ||
|
||
const response = await yt.actions.execute(continuation.endpoint.metadata.api_url, { | ||
...continuation.endpoint.payload, | ||
parse: true | ||
}); | ||
|
||
|
||
let comments = [] | ||
let continuationData = null | ||
response.on_response_received_endpoints[0].contents.forEach(element => { | ||
if (element.type === "Comment") { | ||
comments.push(element) | ||
} else if (element.type === "ContinuationItem") { | ||
continuationData = element | ||
} | ||
}) | ||
|
||
|
||
const result = { | ||
items: comments, | ||
continuation: continuationData | ||
} | ||
|
||
ytcm.getCommentReplies(payload).then(d => console.log(JSON.stringify(d, null, 2)), e => console.error(JSON.stringify(e, null, 2))); | ||
console.log(JSON.stringify(result, null, 2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
const ytcm = require("@freetube/yt-comment-scraper"); | ||
import { Innertube, YTNodes } from 'youtubei.js'; | ||
|
||
let query = process.argv[2]; | ||
let continuation = process.argv[3]; | ||
const yt = await Innertube.create({ | ||
lang: 'en', | ||
location: 'US', | ||
}); | ||
|
||
const payload = { | ||
videoId: query, | ||
sortByNewest: false, | ||
continuation: continuation, | ||
const channelId = process.argv[2]; | ||
const continuation = JSON.parse(process.argv[3]) | ||
|
||
let comments = null | ||
let continuationData = null | ||
if (Object.keys(continuation).length) { | ||
const response = await yt.actions.execute(continuation.endpoint.metadata.api_url, { | ||
...continuation.endpoint.payload, | ||
parse: true | ||
}); | ||
|
||
comments = [] | ||
response.on_response_received_endpoints[0].contents.forEach(element => { | ||
if (element.type === "CommentThread") { | ||
comments.push(element) | ||
} else if (element.type === "ContinuationItem") { | ||
continuationData = element | ||
} | ||
}) | ||
} else { | ||
const commentsData = await yt.getComments(channelId); | ||
|
||
continuationData = commentsData.page.on_response_received_endpoints.at(1).contents.firstOfType(YTNodes.ContinuationItem); | ||
comments = commentsData.contents; | ||
} | ||
|
||
const result = { | ||
items: comments, | ||
continuation: continuationData | ||
} | ||
|
||
ytcm.getComments(payload).then(d => console.log(JSON.stringify(d, null, 2)), e => console.error(JSON.stringify(e, null, 2))); | ||
console.log(JSON.stringify(result, null, 2)) |
Oops, something went wrong.