Skip to content

Commit

Permalink
🐛 Fix runtime errors (#2982)
Browse files Browse the repository at this point in the history
  • Loading branch information
moisout authored Oct 6, 2024
1 parent 8979b7a commit 44606cf
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 40 deletions.
60 changes: 26 additions & 34 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"server": "dist/server"
},
"dependencies": {
"@fastify/cookie": "10.0.1",
"@fastify/cookie": "9.4.0",
"@fastify/helmet": "12.0.1",
"@fastify/multipart": "9.0.1",
"@fastify/multipart": "8.3.0",
"@fastify/static": "7.0.4",
"@fastify/swagger": "9.1.0",
"@nestjs/bull": "10.2.1",
Expand Down
10 changes: 8 additions & 2 deletions server/src/core/comments/comments.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { VTCommentsResponseDto } from 'server/mapper/converter/comments/vt-comme
import { toVTCommentsResponseDto } from 'server/mapper/converter/comments/vt-comments.converter';

import { YTNodes } from 'youtubei.js';
import { GetCommentsSectionParams } from 'youtubei.js/dist/protos/generated/misc/params.js';
import { u8ToBase64 } from 'youtubei.js/dist/src/utils/Utils';
@Injectable()
export class CommentsService {
async getComments(
Expand All @@ -32,6 +30,14 @@ export class CommentsService {
parse: true
};
} else {
const GetCommentsSectionParams = await import(
'youtubei.js/dist/protos/generated/misc/params.js'
).then(el => el.GetCommentsSectionParams);

const u8ToBase64 = await import('youtubei.js/dist/src/utils/Utils.js').then(
el => el.u8ToBase64
);

const writer = GetCommentsSectionParams.encode({
ctx: {
videoId
Expand Down
14 changes: 12 additions & 2 deletions server/src/core/search/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { innertubeClient } from 'server/common/innertube/innertube';
import { toVTSearchResultDto } from 'server/mapper/converter/search/vt-search-result.converter';
import { VTSearchDto } from 'server/mapper/dto/search/vt-search.dto';
import { Endpoints, Parser, YTNodes } from 'youtubei.js';
import { SearchFilter, SearchFilter_Filters_Duration, SearchFilter_Filters_SearchType, SearchFilter_Filters_UploadDate, SearchFilter_SortBy } from 'youtubei.js/dist/protos/generated/misc/params';
import { u8ToBase64 } from 'youtubei.js/dist/src/utils/Utils';
import type { SearchFilter } from 'youtubei.js/dist/protos/generated/misc/params';
import { SearchFiltersDto } from './dto/search-filters.dto';
import { SearchQueryDto } from './dto/search-query.dto';

Expand Down Expand Up @@ -32,6 +31,13 @@ export class SearchService {
let searchFilters;
if (searchQuery.filters) {
const filters = searchQuery.filters;
const {
SearchFilter_SortBy,
SearchFilter_Filters_UploadDate,
SearchFilter_Filters_SearchType,
SearchFilter_Filters_Duration,
SearchFilter
} = await import('youtubei.js/dist/protos/generated/misc/params');
const search_filter: SearchFilter = {};

search_filter.filters = {};
Expand Down Expand Up @@ -104,6 +110,10 @@ export class SearchService {
}
}

const u8ToBase64 = await import('youtubei.js/dist/src/utils/Utils.js').then(
el => el.u8ToBase64
);

searchFilters = encodeURIComponent(u8ToBase64(SearchFilter.encode(search_filter).finish()));
}

Expand Down

0 comments on commit 44606cf

Please sign in to comment.