Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,29 @@ beforeEach(() => {
});

describe("startYoutubeProfileScraping", () => {
it("defaults to the legacy snapshot (maxResults: 1, Shorts excluded) when posts is omitted", async () => {
it("defaults to the legacy snapshot (maxResults: 1, Shorts and streams excluded) when posts is omitted", async () => {
const r = await startYoutubeProfileScraping("@mycowtf");
expect(apifyClient.actor).toHaveBeenCalledWith("streamers/youtube-scraper");
expect(start).toHaveBeenCalledWith(
expect.objectContaining({
startUrls: [{ url: "https://www.youtube.com/@mycowtf" }],
maxResults: 1,
maxResultsShorts: 0,
maxResultStreams: 0,
}),
{ webhooks: expect.any(Array) },
);
expect(r).toEqual({ runId: "run-1", datasetId: "ds-1" });
});

it("passes posts through as maxResults AND maxResultsShorts (Shorts included)", async () => {
it("passes posts through as maxResults, maxResultsShorts AND maxResultStreams (Shorts + streams included)", async () => {
await startYoutubeProfileScraping("mycowtf", 20);
expect(start).toHaveBeenCalledWith(
expect.objectContaining({
startUrls: [{ url: "https://www.youtube.com/@mycowtf" }],
maxResults: 20,
maxResultsShorts: 20,
maxResultStreams: 20,
}),
{ webhooks: expect.any(Array) },
);
Expand Down
2 changes: 1 addition & 1 deletion lib/apify/youtube/startYoutubeProfileScraping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ const startYoutubeProfileScraping = async (
const input = {
...DEFAULT_INPUT,
startUrls: [{ url: targetUrl }],
// The legacy snapshot excludes Shorts; a requested posts depth includes them.
maxResults: posts ?? DEFAULT_INPUT.maxResults,
maxResultsShorts: posts ?? DEFAULT_INPUT.maxResultsShorts,
maxResultStreams: posts ?? DEFAULT_INPUT.maxResultStreams,
};

const run = await apifyClient
Expand Down
Loading