@ziplayer/plugin 0.1.33 → 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/YTSRPlugin.ts CHANGED
@@ -1,583 +1,596 @@
1
- import { BasePlugin, Track, SearchResult } from "ziplayer";
2
- import YouTube, { Video, Playlist, Channel } from "youtube-sr";
3
-
4
- /**
5
- * Plugin YTSR để tìm kiếm nâng cao trên YouTube mà không cần tạo stream.
6
- *
7
- * Plugin này cung cấp các tính năng tìm kiếm nâng cao cho YouTube bao gồm:
8
- * - Tìm kiếm video với nhiều tùy chọn lọc
9
- * - Tìm kiếm playlist và channel
10
- * - Hỗ trợ các loại tìm kiếm khác nhau (video, playlist, channel)
11
- * - Không tạo stream, chỉ trả về metadata
12
- *
13
- * @example
14
- * const ytsrPlugin = new YTSRPlugin();
15
- *
16
- * // Tìm kiếm video
17
- * const videoResult = await ytsrPlugin.search("Never Gonna Give You Up", "user123");
18
- *
19
- * // Tìm kiếm playlist
20
- * const playlistResult = await ytsrPlugin.searchPlaylist("chill music playlist", "user123");
21
- *
22
- * // Tìm kiếm channel
23
- * const channelResult = await ytsrPlugin.searchChannel("PewDiePie", "user123");
24
- *
25
- * @since 1.0.0
26
- */
27
- export class YTSRPlugin extends BasePlugin {
28
- name = "ytsr";
29
- version = "1.0.0";
30
-
31
- /**
32
- * Tạo một instance mới của YTSRPlugin.
33
- *
34
- * Plugin này không cần khởi tạo bất kỳ client nào vì sử dụng youtube-sr
35
- * để tìm kiếm thông tin từ YouTube.
36
- *
37
- * @example
38
- * const plugin = new YTSRPlugin();
39
- * // Plugin sẵn sàng sử dụng ngay lập tức
40
- */
41
- constructor() {
42
- super();
43
- }
44
-
45
- /**
46
- * Xác định xem plugin có thể xử lý query này không.
47
- *
48
- * @param query - Query tìm kiếm hoặc URL để kiểm tra
49
- * @returns `true` nếu plugin có thể xử lý query, `false` nếu không
50
- *
51
- * @example
52
- * plugin.canHandle("Never Gonna Give You Up"); // true
53
- * plugin.canHandle("https://www.youtube.com/watch?v=dQw4w9WgXcQ"); // true
54
- * plugin.canHandle("spotify:track:123"); // false
55
- */
56
- canHandle(query: string): boolean {
57
- const q = (query || "").trim().toLowerCase();
58
-
59
- // Tránh xử lý các pattern rõ ràng cho các extractor khác
60
- if (q.startsWith("tts:") || q.startsWith("say ")) return false;
61
- if (q.startsWith("spotify:") || q.includes("open.spotify.com")) return false;
62
- if (q.includes("soundcloud")) return false;
63
-
64
- // Xử lý URL YouTube
65
- if (q.startsWith("http://") || q.startsWith("https://")) {
66
- try {
67
- const parsed = new URL(query);
68
- const allowedHosts = ["youtube.com", "www.youtube.com", "music.youtube.com", "youtu.be", "www.youtu.be"];
69
- return allowedHosts.includes(parsed.hostname.toLowerCase());
70
- } catch (e) {
71
- return false;
72
- }
73
- }
74
-
75
- // Xử tất cả text khác như tìm kiếm YouTube
76
- return true;
77
- }
78
-
79
- /**
80
- * Xác thực xem URL có phải là URL YouTube hợp lệ không.
81
- *
82
- * @param url - URL để xác thực
83
- * @returns `true` nếu URL hợp lệ, `false` nếu không
84
- *
85
- * @example
86
- * plugin.validate("https://www.youtube.com/watch?v=dQw4w9WgXcQ"); // true
87
- * plugin.validate("https://youtu.be/dQw4w9WgXcQ"); // true
88
- * plugin.validate("https://spotify.com/track/123"); // false
89
- */
90
- validate(url: string): boolean {
91
- try {
92
- const parsed = new URL(url);
93
- const allowedHosts = ["youtube.com", "www.youtube.com", "music.youtube.com", "youtu.be", "www.youtu.be", "m.youtube.com"];
94
- return allowedHosts.includes(parsed.hostname.toLowerCase());
95
- } catch (e) {
96
- return false;
97
- }
98
- }
99
-
100
- /**
101
- * Tìm kiếm video trên YouTube với các tùy chọn nâng cao.
102
- *
103
- * @param query - Query tìm kiếm
104
- * @param requestedBy - ID của user yêu cầu tìm kiếm
105
- * @param options - Tùy chọn tìm kiếm nâng cao
106
- * @param options.limit - Số lượng kết quả tối đa (mặc định: 10)
107
- * @param options.type - Loại tìm kiếm: "video", "playlist", "channel", "all" (mặc định: "video")
108
- * @param options.duration - Lọc theo thời lượng: "short", "medium", "long", "all" (mặc định: "all")
109
- * @param options.sortBy - Sắp xếp theo: "relevance", "uploadDate", "viewCount", "rating" (mặc định: "relevance")
110
- * @param options.uploadDate - Lọc theo ngày upload: "hour", "today", "week", "month", "year", "all" (mặc định: "all")
111
- * @returns SearchResult chứa các track được tìm thấy
112
- *
113
- * @example
114
- * // Tìm kiếm video bản
115
- * const result = await plugin.search("Never Gonna Give You Up", "user123");
116
- *
117
- * // Tìm kiếm với tùy chọn nâng cao
118
- * const advancedResult = await plugin.search("chill music", "user123", {
119
- * limit: 5,
120
- * duration: "medium",
121
- * sortBy: "viewCount",
122
- * uploadDate: "month"
123
- * });
124
- */
125
- async search(
126
- query: string,
127
- requestedBy: string,
128
- options: {
129
- limit?: number;
130
- type?: "video" | "playlist" | "channel" | "all";
131
- duration?: "short" | "medium" | "long" | "all";
132
- sortBy?: "relevance" | "uploadDate" | "viewCount" | "rating";
133
- uploadDate?: "hour" | "today" | "week" | "month" | "year" | "all";
134
- } = {},
135
- ): Promise<SearchResult> {
136
- const { limit = 10, type = "video", duration = "all", sortBy = "relevance", uploadDate = "all" } = options;
137
-
138
- try {
139
- // Nếu là URL YouTube, xử lý như video đơn lẻ hoặc playlist Mix
140
- if (this.validate(query)) {
141
- const listId = this.extractListId(query);
142
- if (listId && this.isMixListId(listId)) {
143
- // Xử playlist Mix (RD)
144
- return await this.handleMixPlaylistInternal(query, requestedBy, limit);
145
- }
146
-
147
- const videoId = this.extractVideoId(query);
148
- if (videoId) {
149
- const video = await this.getVideoByIdInternal(videoId);
150
- if (video) {
151
- return {
152
- tracks: [this.buildTrackFromVideo(video, requestedBy)],
153
- };
154
- }
155
- }
156
- }
157
-
158
- // Tìm kiếm với youtube-sr
159
- const searchOptions: any = {
160
- limit,
161
- type: type === "all" ? "all" : type,
162
- safeSearch: false,
163
- };
164
-
165
- // Thêm các filter nâng cao
166
- if (duration !== "all") {
167
- searchOptions.duration = duration;
168
- }
169
- if (sortBy !== "relevance") {
170
- searchOptions.sortBy = sortBy;
171
- }
172
- if (uploadDate !== "all") {
173
- searchOptions.uploadDate = uploadDate;
174
- }
175
-
176
- const results = await YouTube.search(query, searchOptions);
177
-
178
- const tracks: Track[] = [];
179
-
180
- // Xử lý kết quả dựa trên loại tìm kiếm
181
- if (type === "video" || type === "all") {
182
- const videos = results.filter((item: any): item is Video => item instanceof Video);
183
- tracks.push(...videos.slice(0, limit).map((video: Video) => this.buildTrackFromVideo(video, requestedBy)));
184
- }
185
-
186
- if (type === "playlist" || type === "all") {
187
- const playlists = results.filter((item: any): item is Playlist => item instanceof Playlist);
188
- // Chuyển đổi playlist thành tracks
189
- playlists.slice(0, Math.floor(limit / 2)).forEach((playlist: any) => {
190
- tracks.push(this.buildTrackFromPlaylist(playlist, requestedBy));
191
- });
192
- }
193
-
194
- if (type === "channel" || type === "all") {
195
- const channels = results.filter((item: any): item is Channel => item instanceof Channel);
196
- // Chuyển đổi channel thành tracks (lấy video mới nhất)
197
- channels.slice(0, Math.floor(limit / 3)).forEach((channel: any) => {
198
- tracks.push(this.buildTrackFromChannel(channel, requestedBy));
199
- });
200
- }
201
-
202
- return { tracks: tracks.slice(0, limit) };
203
- } catch (error: any) {
204
- throw new Error(`YTSR search failed: ${error?.message || error}`);
205
- }
206
- }
207
-
208
- /**
209
- * Tìm kiếm playlist trên YouTube.
210
- *
211
- * @param query - Query tìm kiếm playlist
212
- * @param requestedBy - ID của user yêu cầu tìm kiếm
213
- * @param limit - Số lượng playlist tối đa (mặc định: 5)
214
- * @returns SearchResult chứa các playlist được tìm thấy
215
- *
216
- * @example
217
- * const playlists = await plugin.searchPlaylist("chill music playlist", "user123", 3);
218
- * console.log(`Tìm thấy ${playlists.tracks.length} playlist`);
219
- */
220
- async searchPlaylist(query: string, requestedBy: string, limit: number = 5): Promise<SearchResult> {
221
- return this.search(query, requestedBy, { type: "playlist", limit });
222
- }
223
-
224
- /**
225
- * Tìm kiếm channel trên YouTube.
226
- *
227
- * @param query - Query tìm kiếm channel
228
- * @param requestedBy - ID của user yêu cầu tìm kiếm
229
- * @param limit - Số lượng channel tối đa (mặc định: 5)
230
- * @returns SearchResult chứa các channel được tìm thấy
231
- *
232
- * @example
233
- * const channels = await plugin.searchChannel("PewDiePie", "user123", 3);
234
- * console.log(`Tìm thấy ${channels.tracks.length} channel`);
235
- */
236
- async searchChannel(query: string, requestedBy: string, limit: number = 5): Promise<SearchResult> {
237
- return this.search(query, requestedBy, { type: "channel", limit });
238
- }
239
-
240
- /**
241
- * Tìm kiếm video theo ID cụ thể.
242
- *
243
- * @param videoId - ID của video YouTube
244
- * @param requestedBy - ID của user yêu cầu
245
- * @returns Track object của video
246
- *
247
- * @example
248
- * const video = await plugin.getVideoById("dQw4w9WgXcQ", "user123");
249
- * console.log(video.title);
250
- */
251
- async getVideoById(videoId: string, requestedBy: string): Promise<Track | null> {
252
- try {
253
- const video = await this.getVideoByIdInternal(videoId);
254
- return video ? this.buildTrackFromVideo(video, requestedBy) : null;
255
- } catch (error: any) {
256
- throw new Error(`Failed to get video by ID: ${error?.message || error}`);
257
- }
258
- }
259
-
260
- /**
261
- * Lấy thông tin chi tiết của video từ ID.
262
- *
263
- * @param videoId - ID của video YouTube
264
- * @returns Video object hoặc null nếu không tìm thấy
265
- */
266
- private async getVideoByIdInternal(videoId: string): Promise<Video | null> {
267
- try {
268
- const results = await YouTube.search(`https://www.youtube.com/watch?v=${videoId}`, { limit: 1, type: "video" });
269
- const video = results.find((item: any): item is Video => item instanceof Video);
270
- return video || null;
271
- } catch {
272
- return null;
273
- }
274
- }
275
-
276
- /**
277
- * Xây dựng Track object từ Video object của youtube-sr.
278
- *
279
- * @param video - Video object từ youtube-sr
280
- * @param requestedBy - ID của user yêu cầu
281
- * @returns Track object
282
- */
283
- private buildTrackFromVideo(video: Video, requestedBy: string): Track {
284
- // Xử lý duration một cách an toàn
285
- let duration = 0;
286
- if (video.duration) {
287
- if (typeof video.duration === "number") {
288
- duration = video.duration;
289
- } else if (typeof video.duration === "object" && video.duration !== null) {
290
- // Nếu duration object, thử lấy seconds
291
- duration = (video.duration as any)?.seconds || (video.duration as any)?.totalSeconds || 0;
292
- }
293
- }
294
-
295
- // youtube-sr trả về duration theo milliseconds, chuyển thành seconds
296
- if (duration > 0) {
297
- // Nếu duration lớn hơn 1000, có thể là milliseconds
298
- if (duration > 1000) {
299
- duration = Math.floor(duration / 1000);
300
- }
301
- }
302
-
303
- return {
304
- id: video.id,
305
- title: video.title,
306
- url: video.url,
307
- duration: Math.max(0, duration), // Đảm bảo duration không âm
308
- thumbnail: video.thumbnail?.url || (video as any).thumbnails?.[0]?.url,
309
- requestedBy,
310
- source: this.name,
311
- metadata: {
312
- author: video.channel?.name,
313
- views: video.views,
314
- description: video.description,
315
- publishedAt: video.uploadedAt,
316
- channelUrl: video.channel?.url,
317
- channelId: video.channel?.id,
318
- },
319
- } as Track;
320
- }
321
-
322
- /**
323
- * Xây dựng Track object từ Playlist object của youtube-sr.
324
- *
325
- * @param playlist - Playlist object từ youtube-sr
326
- * @param requestedBy - ID của user yêu cầu
327
- * @returns Track object
328
- */
329
- private buildTrackFromPlaylist(playlist: Playlist, requestedBy: string): Track {
330
- return {
331
- id: playlist.id,
332
- title: playlist.title,
333
- url: playlist.url,
334
- duration: 0, // Playlist không có duration cố định
335
- thumbnail: playlist.thumbnail?.url || (playlist as any).thumbnails?.[0]?.url,
336
- requestedBy,
337
- source: this.name,
338
- metadata: {
339
- author: playlist.channel?.name,
340
- views: playlist.views,
341
- description: (playlist as any).description,
342
- publishedAt: (playlist as any).uploadedAt,
343
- channelUrl: playlist.channel?.url,
344
- channelId: playlist.channel?.id,
345
- videoCount: playlist.videoCount,
346
- type: "playlist",
347
- },
348
- } as Track;
349
- }
350
-
351
- /**
352
- * Xây dựng Track object từ Channel object của youtube-sr.
353
- *
354
- * @param channel - Channel object từ youtube-sr
355
- * @param requestedBy - ID của user yêu cầu
356
- * @returns Track object
357
- */
358
- private buildTrackFromChannel(channel: Channel, requestedBy: string): Track {
359
- return {
360
- id: channel.id,
361
- title: channel.name,
362
- url: channel.url,
363
- duration: 0, // Channel không có duration
364
- thumbnail: (channel as any).thumbnail?.url || (channel as any).thumbnails?.[0]?.url,
365
- requestedBy,
366
- source: this.name,
367
- metadata: {
368
- author: channel.name,
369
- views: channel.subscribers,
370
- description: (channel as any).description,
371
- publishedAt: (channel as any).joinedAt,
372
- channelUrl: channel.url,
373
- channelId: channel.id,
374
- subscriberCount: channel.subscribers,
375
- type: "channel",
376
- },
377
- } as Track;
378
- }
379
-
380
- /**
381
- * Xử lý playlist Mix (RD) của YouTube (internal).
382
- *
383
- * @param url - URL của playlist Mix
384
- * @param requestedBy - ID của user yêu cầu
385
- * @param limit - Số lượng track tối đa
386
- * @returns SearchResult chứa các track từ Mix
387
- */
388
- private async handleMixPlaylistInternal(url: string, requestedBy: string, limit: number): Promise<SearchResult> {
389
- try {
390
- const videoId = this.extractVideoId(url);
391
- if (!videoId) {
392
- throw new Error("Không thể trích xuất video ID từ URL Mix");
393
- }
394
-
395
- // Lấy thông tin video gốc
396
- const anchorVideo = await this.getVideoByIdInternal(videoId);
397
- if (!anchorVideo) {
398
- throw new Error("Không thể lấy thông tin video gốc");
399
- }
400
-
401
- // Tìm kiếm các video liên quan để tạo Mix
402
- const searchQuery = `${anchorVideo.title} ${anchorVideo.channel?.name || ""}`;
403
- const searchResult = await this.search(searchQuery, requestedBy, {
404
- limit: limit + 5, // Lấy thêm để có thể lọc
405
- type: "video",
406
- });
407
-
408
- // Lọc sắp xếp kết quả để tạo Mix
409
- const mixTracks = searchResult.tracks
410
- .filter((track) => track.id !== videoId) // Loại bỏ video gốc
411
- .slice(0, limit);
412
-
413
- // Thêm video gốc vào đầu Mix
414
- const anchorTrack = this.buildTrackFromVideo(anchorVideo, requestedBy);
415
- mixTracks.unshift(anchorTrack);
416
-
417
- return {
418
- tracks: mixTracks.slice(0, limit),
419
- playlist: {
420
- name: `YouTube Mix - ${anchorVideo.title}`,
421
- url: url,
422
- thumbnail: anchorVideo.thumbnail?.url || (anchorVideo as any).thumbnails?.[0]?.url,
423
- },
424
- };
425
- } catch (error: any) {
426
- throw new Error(`Failed to handle Mix playlist: ${error?.message || error}`);
427
- }
428
- }
429
-
430
- /**
431
- * Kiểm tra xem listId có phải là Mix playlist không.
432
- *
433
- * @param listId - ID của playlist
434
- * @returns true nếu là Mix playlist
435
- */
436
- private isMixListId(listId: string): boolean {
437
- // YouTube Mix playlists thường bắt đầu với 'RD'
438
- return typeof listId === "string" && listId.toUpperCase().startsWith("RD");
439
- }
440
-
441
- /**
442
- * Trích xuất playlist ID từ URL YouTube.
443
- *
444
- * @param input - URL chứa playlist ID
445
- * @returns Playlist ID hoặc null nếu không tìm thấy
446
- */
447
- private extractListId(input: string): string | null {
448
- try {
449
- const u = new URL(input);
450
- return u.searchParams.get("list");
451
- } catch {
452
- return null;
453
- }
454
- }
455
-
456
- /**
457
- * Trích xuất video ID từ URL YouTube.
458
- *
459
- * @param input - URL hoặc string chứa video ID
460
- * @returns Video ID hoặc null nếu không tìm thấy
461
- */
462
- private extractVideoId(input: string): string | null {
463
- try {
464
- const u = new URL(input);
465
- const allowedShortHosts = ["youtu.be"];
466
- const allowedLongHosts = ["youtube.com", "www.youtube.com", "music.youtube.com", "m.youtube.com"];
467
-
468
- if (allowedShortHosts.includes(u.hostname)) {
469
- return u.pathname.split("/").filter(Boolean)[0] || null;
470
- }
471
-
472
- if (allowedLongHosts.includes(u.hostname)) {
473
- // watch?v=, shorts/, embed/
474
- if (u.searchParams.get("v")) return u.searchParams.get("v");
475
- const path = u.pathname;
476
- if (path.startsWith("/shorts/")) return path.replace("/shorts/", "");
477
- if (path.startsWith("/embed/")) return path.replace("/embed/", "");
478
- }
479
-
480
- return null;
481
- } catch {
482
- return null;
483
- }
484
- }
485
-
486
- /**
487
- * Plugin này không hỗ trợ tạo stream, chỉ dành cho tìm kiếm metadata.
488
- *
489
- * @param track - Track object
490
- * @throws Error plugin này không hỗ trợ streaming
491
- */
492
- async getStream(track: Track): Promise<any> {
493
- throw new Error("YTSRPlugin không hỗ trợ streaming. Plugin này chỉ dành cho tìm kiếm metadata.");
494
- }
495
-
496
- /**
497
- * Xử lý playlist Mix (RD) của YouTube.
498
- *
499
- * @param mixUrl - URL của playlist Mix YouTube
500
- * @param requestedBy - ID của user yêu cầu
501
- * @param limit - Số lượng track tối đa (mặc định: 10)
502
- * @returns SearchResult chứa các track từ Mix playlist
503
- *
504
- * @example
505
- * const mixResult = await plugin.handleMixPlaylist(
506
- * "https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=RDMWGnHCaqxdU&start_radio=1",
507
- * "user123",
508
- * 15
509
- * );
510
- * console.log(`Mix playlist: ${mixResult.playlist?.name}`);
511
- * console.log(`Tìm thấy ${mixResult.tracks.length} track trong Mix`);
512
- */
513
- async handleMixPlaylist(mixUrl: string, requestedBy: string, limit: number = 10): Promise<SearchResult> {
514
- return this.handleMixPlaylistInternal(mixUrl, requestedBy, limit);
515
- }
516
-
517
- /**
518
- * Lấy các video liên quan cho một video YouTube cụ thể.
519
- *
520
- * @param trackURL - URL của video YouTube để lấy video liên quan
521
- * @param opts - Tùy chọn cho việc lọc và giới hạn kết quả
522
- * @param opts.limit - Số lượng video liên quan tối đa (mặc định: 5)
523
- * @param opts.offset - Số lượng video bỏ qua từ đầu (mặc định: 0)
524
- * @param opts.history - Mảng các track để loại trừ khỏi kết quả
525
- * @returns Mảng các Track object liên quan
526
- *
527
- * @example
528
- * const related = await plugin.getRelatedTracks(
529
- * "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
530
- * { limit: 3, history: [currentTrack] }
531
- * );
532
- * console.log(`Tìm thấy ${related.length} video liên quan`);
533
- */
534
- async getRelatedTracks(trackURL: string, opts: { limit?: number; offset?: number; history?: Track[] } = {}): Promise<Track[]> {
535
- const { limit = 5, offset = 0, history = [] } = opts;
536
-
537
- try {
538
- const videoId = this.extractVideoId(trackURL);
539
- if (!videoId) {
540
- throw new Error("Không thể trích xuất video ID từ URL");
541
- }
542
-
543
- // Tìm kiếm video liên quan bằng cách tìm kiếm với title của video hiện tại
544
- const currentVideo = await this.getVideoByIdInternal(videoId);
545
- if (!currentVideo) {
546
- throw new Error("Không thể lấy thông tin video hiện tại");
547
- }
548
-
549
- // Tìm kiếm các video liên quan dựa trên title và channel
550
- const searchQuery = `${currentVideo.title} ${currentVideo.channel?.name || ""}`;
551
- const searchResult = await this.search(searchQuery, "auto", {
552
- limit: limit + offset + history.length,
553
- type: "video",
554
- });
555
-
556
- // Lọc ra video hiện tại các video trong history
557
- const filteredTracks = searchResult.tracks.filter((track) => {
558
- // Loại bỏ video hiện tại
559
- if (track.id === videoId) return false;
560
-
561
- // Loại bỏ các video trong history
562
- if (history.some((h) => h.id === track.id || h.url === track.url)) return false;
563
-
564
- return true;
565
- });
566
-
567
- // Áp dụng offset và limit
568
- return filteredTracks.slice(offset, offset + limit);
569
- } catch (error: any) {
570
- throw new Error(`Failed to get related tracks: ${error?.message || error}`);
571
- }
572
- }
573
-
574
- /**
575
- * Plugin này không hỗ trợ fallback stream.
576
- *
577
- * @param track - Track object
578
- * @throws Error vì plugin này không hỗ trợ streaming
579
- */
580
- async getFallback(track: Track): Promise<any> {
581
- throw new Error("YTSRPlugin không hỗ trợ fallback streaming. Plugin này chỉ dành cho tìm kiếm metadata.");
582
- }
583
- }
1
+ import { BasePlugin, Track, SearchResult } from "ziplayer";
2
+ import YouTube, { Video, Playlist, Channel } from "youtube-sr";
3
+
4
+ /**
5
+ * Plugin YTSR để tìm kiếm nâng cao trên YouTube mà không cần tạo stream.
6
+ *
7
+ * Plugin này cung cấp các tính năng tìm kiếm nâng cao cho YouTube bao gồm:
8
+ * - Tìm kiếm video với nhiều tùy chọn lọc
9
+ * - Tìm kiếm playlist và channel
10
+ * - Hỗ trợ các loại tìm kiếm khác nhau (video, playlist, channel)
11
+ * - Không tạo stream, chỉ trả về metadata
12
+ *
13
+ * @example
14
+ * const ytsrPlugin = new YTSRPlugin();
15
+ *
16
+ * // Tìm kiếm video
17
+ * const videoResult = await ytsrPlugin.search("Never Gonna Give You Up", "user123");
18
+ *
19
+ * // Tìm kiếm playlist
20
+ * const playlistResult = await ytsrPlugin.searchPlaylist("chill music playlist", "user123");
21
+ *
22
+ * // Tìm kiếm channel
23
+ * const channelResult = await ytsrPlugin.searchChannel("PewDiePie", "user123");
24
+ *
25
+ * @since 1.0.0
26
+ */
27
+ export class YTSRPlugin extends BasePlugin {
28
+ name = "ytsr";
29
+ version = "1.0.0";
30
+
31
+ /**
32
+ * Tạo một instance mới của YTSRPlugin.
33
+ *
34
+ * Plugin này không cần khởi tạo bất kỳ client nào vì sử dụng youtube-sr
35
+ * để tìm kiếm thông tin từ YouTube.
36
+ *
37
+ * @example
38
+ * const plugin = new YTSRPlugin();
39
+ * // Plugin sẵn sàng sử dụng ngay lập tức
40
+ */
41
+ constructor() {
42
+ super();
43
+ }
44
+
45
+ /**
46
+ * Xác định xem plugin có thể xử lý query này không.
47
+ *
48
+ * @param query - Query tìm kiếm hoặc URL để kiểm tra
49
+ * @returns `true` nếu plugin có thể xử lý query, `false` nếu không
50
+ *
51
+ * @example
52
+ * plugin.canHandle("Never Gonna Give You Up"); // true
53
+ * plugin.canHandle("https://www.youtube.com/watch?v=dQw4w9WgXcQ"); // true
54
+ * plugin.canHandle("spotify:track:123"); // false
55
+ */
56
+ canHandle(query: string): boolean {
57
+ const q = (query || "").trim().toLowerCase();
58
+
59
+ // Tránh xử lý các pattern rõ ràng cho các extractor khác
60
+ if (q.startsWith("tts:") || q.startsWith("say ")) return false;
61
+ if (q.startsWith("spotify:")) return false;
62
+ // If the query is a URL, check its hostname for Spotify domains
63
+ if (q.startsWith("http://") || q.startsWith("https://")) {
64
+ try {
65
+ const parsed = new URL(query);
66
+ const spotifyHosts = ["open.spotify.com", "play.spotify.com", "www.spotify.com"];
67
+ if (spotifyHosts.includes(parsed.hostname.toLowerCase())) return false;
68
+ } catch (e) {
69
+ /* ignore */
70
+ }
71
+ } else if (q.includes("open.spotify.com")) {
72
+ // fallback for non-URL text queries
73
+ return false;
74
+ }
75
+ if (q.includes("soundcloud")) return false;
76
+
77
+ // Xử lý URL YouTube
78
+ if (q.startsWith("http://") || q.startsWith("https://")) {
79
+ try {
80
+ const parsed = new URL(query);
81
+ const allowedHosts = ["youtube.com", "www.youtube.com", "music.youtube.com", "youtu.be", "www.youtu.be"];
82
+ return allowedHosts.includes(parsed.hostname.toLowerCase());
83
+ } catch (e) {
84
+ return false;
85
+ }
86
+ }
87
+
88
+ // Xử tất cả text khác như tìm kiếm YouTube
89
+ return true;
90
+ }
91
+
92
+ /**
93
+ * Xác thực xem URL phải URL YouTube hợp lệ không.
94
+ *
95
+ * @param url - URL để xác thực
96
+ * @returns `true` nếu URL hợp lệ, `false` nếu không
97
+ *
98
+ * @example
99
+ * plugin.validate("https://www.youtube.com/watch?v=dQw4w9WgXcQ"); // true
100
+ * plugin.validate("https://youtu.be/dQw4w9WgXcQ"); // true
101
+ * plugin.validate("https://spotify.com/track/123"); // false
102
+ */
103
+ validate(url: string): boolean {
104
+ try {
105
+ const parsed = new URL(url);
106
+ const allowedHosts = ["youtube.com", "www.youtube.com", "music.youtube.com", "youtu.be", "www.youtu.be", "m.youtube.com"];
107
+ return allowedHosts.includes(parsed.hostname.toLowerCase());
108
+ } catch (e) {
109
+ return false;
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Tìm kiếm video trên YouTube với các tùy chọn nâng cao.
115
+ *
116
+ * @param query - Query tìm kiếm
117
+ * @param requestedBy - ID của user yêu cầu tìm kiếm
118
+ * @param options - Tùy chọn tìm kiếm nâng cao
119
+ * @param options.limit - Số lượng kết quả tối đa (mặc định: 10)
120
+ * @param options.type - Loại tìm kiếm: "video", "playlist", "channel", "all" (mặc định: "video")
121
+ * @param options.duration - Lọc theo thời lượng: "short", "medium", "long", "all" (mặc định: "all")
122
+ * @param options.sortBy - Sắp xếp theo: "relevance", "uploadDate", "viewCount", "rating" (mặc định: "relevance")
123
+ * @param options.uploadDate - Lọc theo ngày upload: "hour", "today", "week", "month", "year", "all" (mặc định: "all")
124
+ * @returns SearchResult chứa các track được tìm thấy
125
+ *
126
+ * @example
127
+ * // Tìm kiếm video cơ bản
128
+ * const result = await plugin.search("Never Gonna Give You Up", "user123");
129
+ *
130
+ * // Tìm kiếm với tùy chọn nâng cao
131
+ * const advancedResult = await plugin.search("chill music", "user123", {
132
+ * limit: 5,
133
+ * duration: "medium",
134
+ * sortBy: "viewCount",
135
+ * uploadDate: "month"
136
+ * });
137
+ */
138
+ async search(
139
+ query: string,
140
+ requestedBy: string,
141
+ options: {
142
+ limit?: number;
143
+ type?: "video" | "playlist" | "channel" | "all";
144
+ duration?: "short" | "medium" | "long" | "all";
145
+ sortBy?: "relevance" | "uploadDate" | "viewCount" | "rating";
146
+ uploadDate?: "hour" | "today" | "week" | "month" | "year" | "all";
147
+ } = {},
148
+ ): Promise<SearchResult> {
149
+ const { limit = 10, type = "video", duration = "all", sortBy = "relevance", uploadDate = "all" } = options;
150
+
151
+ try {
152
+ // Nếu là URL YouTube, xử lý như video đơn lẻ hoặc playlist Mix
153
+ if (this.validate(query)) {
154
+ const listId = this.extractListId(query);
155
+ if (listId && this.isMixListId(listId)) {
156
+ // Xử lý playlist Mix (RD)
157
+ return await this.handleMixPlaylistInternal(query, requestedBy, limit);
158
+ }
159
+
160
+ const videoId = this.extractVideoId(query);
161
+ if (videoId) {
162
+ const video = await this.getVideoByIdInternal(videoId);
163
+ if (video) {
164
+ return {
165
+ tracks: [this.buildTrackFromVideo(video, requestedBy)],
166
+ };
167
+ }
168
+ }
169
+ }
170
+
171
+ // Tìm kiếm với youtube-sr
172
+ const searchOptions: any = {
173
+ limit,
174
+ type: type === "all" ? "all" : type,
175
+ safeSearch: false,
176
+ };
177
+
178
+ // Thêm các filter nâng cao
179
+ if (duration !== "all") {
180
+ searchOptions.duration = duration;
181
+ }
182
+ if (sortBy !== "relevance") {
183
+ searchOptions.sortBy = sortBy;
184
+ }
185
+ if (uploadDate !== "all") {
186
+ searchOptions.uploadDate = uploadDate;
187
+ }
188
+
189
+ const results = await YouTube.search(query, searchOptions);
190
+
191
+ const tracks: Track[] = [];
192
+
193
+ // Xử lý kết quả dựa trên loại tìm kiếm
194
+ if (type === "video" || type === "all") {
195
+ const videos = results.filter((item: any): item is Video => item instanceof Video);
196
+ tracks.push(...videos.slice(0, limit).map((video: Video) => this.buildTrackFromVideo(video, requestedBy)));
197
+ }
198
+
199
+ if (type === "playlist" || type === "all") {
200
+ const playlists = results.filter((item: any): item is Playlist => item instanceof Playlist);
201
+ // Chuyển đổi playlist thành tracks
202
+ playlists.slice(0, Math.floor(limit / 2)).forEach((playlist: any) => {
203
+ tracks.push(this.buildTrackFromPlaylist(playlist, requestedBy));
204
+ });
205
+ }
206
+
207
+ if (type === "channel" || type === "all") {
208
+ const channels = results.filter((item: any): item is Channel => item instanceof Channel);
209
+ // Chuyển đổi channel thành tracks (lấy video mới nhất)
210
+ channels.slice(0, Math.floor(limit / 3)).forEach((channel: any) => {
211
+ tracks.push(this.buildTrackFromChannel(channel, requestedBy));
212
+ });
213
+ }
214
+
215
+ return { tracks: tracks.slice(0, limit) };
216
+ } catch (error: any) {
217
+ throw new Error(`YTSR search failed: ${error?.message || error}`);
218
+ }
219
+ }
220
+
221
+ /**
222
+ * Tìm kiếm playlist trên YouTube.
223
+ *
224
+ * @param query - Query tìm kiếm playlist
225
+ * @param requestedBy - ID của user yêu cầu tìm kiếm
226
+ * @param limit - Số lượng playlist tối đa (mặc định: 5)
227
+ * @returns SearchResult chứa các playlist được tìm thấy
228
+ *
229
+ * @example
230
+ * const playlists = await plugin.searchPlaylist("chill music playlist", "user123", 3);
231
+ * console.log(`Tìm thấy ${playlists.tracks.length} playlist`);
232
+ */
233
+ async searchPlaylist(query: string, requestedBy: string, limit: number = 5): Promise<SearchResult> {
234
+ return this.search(query, requestedBy, { type: "playlist", limit });
235
+ }
236
+
237
+ /**
238
+ * Tìm kiếm channel trên YouTube.
239
+ *
240
+ * @param query - Query tìm kiếm channel
241
+ * @param requestedBy - ID của user yêu cầu tìm kiếm
242
+ * @param limit - Số lượng channel tối đa (mặc định: 5)
243
+ * @returns SearchResult chứa các channel được tìm thấy
244
+ *
245
+ * @example
246
+ * const channels = await plugin.searchChannel("PewDiePie", "user123", 3);
247
+ * console.log(`Tìm thấy ${channels.tracks.length} channel`);
248
+ */
249
+ async searchChannel(query: string, requestedBy: string, limit: number = 5): Promise<SearchResult> {
250
+ return this.search(query, requestedBy, { type: "channel", limit });
251
+ }
252
+
253
+ /**
254
+ * Tìm kiếm video theo ID cụ thể.
255
+ *
256
+ * @param videoId - ID của video YouTube
257
+ * @param requestedBy - ID của user yêu cầu
258
+ * @returns Track object của video
259
+ *
260
+ * @example
261
+ * const video = await plugin.getVideoById("dQw4w9WgXcQ", "user123");
262
+ * console.log(video.title);
263
+ */
264
+ async getVideoById(videoId: string, requestedBy: string): Promise<Track | null> {
265
+ try {
266
+ const video = await this.getVideoByIdInternal(videoId);
267
+ return video ? this.buildTrackFromVideo(video, requestedBy) : null;
268
+ } catch (error: any) {
269
+ throw new Error(`Failed to get video by ID: ${error?.message || error}`);
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Lấy thông tin chi tiết của video từ ID.
275
+ *
276
+ * @param videoId - ID của video YouTube
277
+ * @returns Video object hoặc null nếu không tìm thấy
278
+ */
279
+ private async getVideoByIdInternal(videoId: string): Promise<Video | null> {
280
+ try {
281
+ const results = await YouTube.search(`https://www.youtube.com/watch?v=${videoId}`, { limit: 1, type: "video" });
282
+ const video = results.find((item: any): item is Video => item instanceof Video);
283
+ return video || null;
284
+ } catch {
285
+ return null;
286
+ }
287
+ }
288
+
289
+ /**
290
+ * Xây dựng Track object từ Video object của youtube-sr.
291
+ *
292
+ * @param video - Video object từ youtube-sr
293
+ * @param requestedBy - ID của user yêu cầu
294
+ * @returns Track object
295
+ */
296
+ private buildTrackFromVideo(video: Video, requestedBy: string): Track {
297
+ // Xử duration một cách an toàn
298
+ let duration = 0;
299
+ if (video.duration) {
300
+ if (typeof video.duration === "number") {
301
+ duration = video.duration;
302
+ } else if (typeof video.duration === "object" && video.duration !== null) {
303
+ // Nếu duration là object, thử lấy seconds
304
+ duration = (video.duration as any)?.seconds || (video.duration as any)?.totalSeconds || 0;
305
+ }
306
+ }
307
+
308
+ // youtube-sr trả về duration theo milliseconds, chuyển thành seconds
309
+ if (duration > 0) {
310
+ // Nếu duration lớn hơn 1000, có thể là milliseconds
311
+ if (duration > 1000) {
312
+ duration = Math.floor(duration / 1000);
313
+ }
314
+ }
315
+
316
+ return {
317
+ id: video.id,
318
+ title: video.title,
319
+ url: video.url,
320
+ duration: Math.max(0, duration), // Đảm bảo duration không âm
321
+ thumbnail: video.thumbnail?.url || (video as any).thumbnails?.[0]?.url,
322
+ requestedBy,
323
+ source: this.name,
324
+ metadata: {
325
+ author: video.channel?.name,
326
+ views: video.views,
327
+ description: video.description,
328
+ publishedAt: video.uploadedAt,
329
+ channelUrl: video.channel?.url,
330
+ channelId: video.channel?.id,
331
+ },
332
+ } as Track;
333
+ }
334
+
335
+ /**
336
+ * Xây dựng Track object từ Playlist object của youtube-sr.
337
+ *
338
+ * @param playlist - Playlist object từ youtube-sr
339
+ * @param requestedBy - ID của user yêu cầu
340
+ * @returns Track object
341
+ */
342
+ private buildTrackFromPlaylist(playlist: Playlist, requestedBy: string): Track {
343
+ return {
344
+ id: playlist.id,
345
+ title: playlist.title,
346
+ url: playlist.url,
347
+ duration: 0, // Playlist không có duration cố định
348
+ thumbnail: playlist.thumbnail?.url || (playlist as any).thumbnails?.[0]?.url,
349
+ requestedBy,
350
+ source: this.name,
351
+ metadata: {
352
+ author: playlist.channel?.name,
353
+ views: playlist.views,
354
+ description: (playlist as any).description,
355
+ publishedAt: (playlist as any).uploadedAt,
356
+ channelUrl: playlist.channel?.url,
357
+ channelId: playlist.channel?.id,
358
+ videoCount: playlist.videoCount,
359
+ type: "playlist",
360
+ },
361
+ } as Track;
362
+ }
363
+
364
+ /**
365
+ * Xây dựng Track object từ Channel object của youtube-sr.
366
+ *
367
+ * @param channel - Channel object từ youtube-sr
368
+ * @param requestedBy - ID của user yêu cầu
369
+ * @returns Track object
370
+ */
371
+ private buildTrackFromChannel(channel: Channel, requestedBy: string): Track {
372
+ return {
373
+ id: channel.id,
374
+ title: channel.name,
375
+ url: channel.url,
376
+ duration: 0, // Channel không có duration
377
+ thumbnail: (channel as any).thumbnail?.url || (channel as any).thumbnails?.[0]?.url,
378
+ requestedBy,
379
+ source: this.name,
380
+ metadata: {
381
+ author: channel.name,
382
+ views: channel.subscribers,
383
+ description: (channel as any).description,
384
+ publishedAt: (channel as any).joinedAt,
385
+ channelUrl: channel.url,
386
+ channelId: channel.id,
387
+ subscriberCount: channel.subscribers,
388
+ type: "channel",
389
+ },
390
+ } as Track;
391
+ }
392
+
393
+ /**
394
+ * Xử lý playlist Mix (RD) của YouTube (internal).
395
+ *
396
+ * @param url - URL của playlist Mix
397
+ * @param requestedBy - ID của user yêu cầu
398
+ * @param limit - Số lượng track tối đa
399
+ * @returns SearchResult chứa các track từ Mix
400
+ */
401
+ private async handleMixPlaylistInternal(url: string, requestedBy: string, limit: number): Promise<SearchResult> {
402
+ try {
403
+ const videoId = this.extractVideoId(url);
404
+ if (!videoId) {
405
+ throw new Error("Không thể trích xuất video ID từ URL Mix");
406
+ }
407
+
408
+ // Lấy thông tin video gốc
409
+ const anchorVideo = await this.getVideoByIdInternal(videoId);
410
+ if (!anchorVideo) {
411
+ throw new Error("Không thể lấy thông tin video gốc");
412
+ }
413
+
414
+ // Tìm kiếm các video liên quan để tạo Mix
415
+ const searchQuery = `${anchorVideo.title} ${anchorVideo.channel?.name || ""}`;
416
+ const searchResult = await this.search(searchQuery, requestedBy, {
417
+ limit: limit + 5, // Lấy thêm để có thể lọc
418
+ type: "video",
419
+ });
420
+
421
+ // Lọc và sắp xếp kết quả để tạo Mix
422
+ const mixTracks = searchResult.tracks
423
+ .filter((track) => track.id !== videoId) // Loại bỏ video gốc
424
+ .slice(0, limit);
425
+
426
+ // Thêm video gốc vào đầu Mix
427
+ const anchorTrack = this.buildTrackFromVideo(anchorVideo, requestedBy);
428
+ mixTracks.unshift(anchorTrack);
429
+
430
+ return {
431
+ tracks: mixTracks.slice(0, limit),
432
+ playlist: {
433
+ name: `YouTube Mix - ${anchorVideo.title}`,
434
+ url: url,
435
+ thumbnail: anchorVideo.thumbnail?.url || (anchorVideo as any).thumbnails?.[0]?.url,
436
+ },
437
+ };
438
+ } catch (error: any) {
439
+ throw new Error(`Failed to handle Mix playlist: ${error?.message || error}`);
440
+ }
441
+ }
442
+
443
+ /**
444
+ * Kiểm tra xem listId phải là Mix playlist không.
445
+ *
446
+ * @param listId - ID của playlist
447
+ * @returns true nếu Mix playlist
448
+ */
449
+ private isMixListId(listId: string): boolean {
450
+ // YouTube Mix playlists thường bắt đầu với 'RD'
451
+ return typeof listId === "string" && listId.toUpperCase().startsWith("RD");
452
+ }
453
+
454
+ /**
455
+ * Trích xuất playlist ID từ URL YouTube.
456
+ *
457
+ * @param input - URL chứa playlist ID
458
+ * @returns Playlist ID hoặc null nếu không tìm thấy
459
+ */
460
+ private extractListId(input: string): string | null {
461
+ try {
462
+ const u = new URL(input);
463
+ return u.searchParams.get("list");
464
+ } catch {
465
+ return null;
466
+ }
467
+ }
468
+
469
+ /**
470
+ * Trích xuất video ID từ URL YouTube.
471
+ *
472
+ * @param input - URL hoặc string chứa video ID
473
+ * @returns Video ID hoặc null nếu không tìm thấy
474
+ */
475
+ private extractVideoId(input: string): string | null {
476
+ try {
477
+ const u = new URL(input);
478
+ const allowedShortHosts = ["youtu.be"];
479
+ const allowedLongHosts = ["youtube.com", "www.youtube.com", "music.youtube.com", "m.youtube.com"];
480
+
481
+ if (allowedShortHosts.includes(u.hostname)) {
482
+ return u.pathname.split("/").filter(Boolean)[0] || null;
483
+ }
484
+
485
+ if (allowedLongHosts.includes(u.hostname)) {
486
+ // watch?v=, shorts/, embed/
487
+ if (u.searchParams.get("v")) return u.searchParams.get("v");
488
+ const path = u.pathname;
489
+ if (path.startsWith("/shorts/")) return path.replace("/shorts/", "");
490
+ if (path.startsWith("/embed/")) return path.replace("/embed/", "");
491
+ }
492
+
493
+ return null;
494
+ } catch {
495
+ return null;
496
+ }
497
+ }
498
+
499
+ /**
500
+ * Plugin này không hỗ trợ tạo stream, chỉ dành cho tìm kiếm metadata.
501
+ *
502
+ * @param track - Track object
503
+ * @throws Error vì plugin này không hỗ trợ streaming
504
+ */
505
+ async getStream(track: Track): Promise<any> {
506
+ throw new Error("YTSRPlugin không hỗ trợ streaming. Plugin này chỉ dành cho tìm kiếm metadata.");
507
+ }
508
+
509
+ /**
510
+ * Xử playlist Mix (RD) của YouTube.
511
+ *
512
+ * @param mixUrl - URL của playlist Mix YouTube
513
+ * @param requestedBy - ID của user yêu cầu
514
+ * @param limit - Số lượng track tối đa (mặc định: 10)
515
+ * @returns SearchResult chứa các track từ Mix playlist
516
+ *
517
+ * @example
518
+ * const mixResult = await plugin.handleMixPlaylist(
519
+ * "https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=RDMWGnHCaqxdU&start_radio=1",
520
+ * "user123",
521
+ * 15
522
+ * );
523
+ * console.log(`Mix playlist: ${mixResult.playlist?.name}`);
524
+ * console.log(`Tìm thấy ${mixResult.tracks.length} track trong Mix`);
525
+ */
526
+ async handleMixPlaylist(mixUrl: string, requestedBy: string, limit: number = 10): Promise<SearchResult> {
527
+ return this.handleMixPlaylistInternal(mixUrl, requestedBy, limit);
528
+ }
529
+
530
+ /**
531
+ * Lấy các video liên quan cho một video YouTube cụ thể.
532
+ *
533
+ * @param trackURL - URL của video YouTube để lấy video liên quan
534
+ * @param opts - Tùy chọn cho việc lọc giới hạn kết quả
535
+ * @param opts.limit - Số lượng video liên quan tối đa (mặc định: 5)
536
+ * @param opts.offset - Số lượng video bỏ qua từ đầu (mặc định: 0)
537
+ * @param opts.history - Mảng các track để loại trừ khỏi kết quả
538
+ * @returns Mảng các Track object liên quan
539
+ *
540
+ * @example
541
+ * const related = await plugin.getRelatedTracks(
542
+ * "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
543
+ * { limit: 3, history: [currentTrack] }
544
+ * );
545
+ * console.log(`Tìm thấy ${related.length} video liên quan`);
546
+ */
547
+ async getRelatedTracks(trackURL: string, opts: { limit?: number; offset?: number; history?: Track[] } = {}): Promise<Track[]> {
548
+ const { limit = 5, offset = 0, history = [] } = opts;
549
+
550
+ try {
551
+ const videoId = this.extractVideoId(trackURL);
552
+ if (!videoId) {
553
+ throw new Error("Không thể trích xuất video ID từ URL");
554
+ }
555
+
556
+ // Tìm kiếm video liên quan bằng cách tìm kiếm với title của video hiện tại
557
+ const currentVideo = await this.getVideoByIdInternal(videoId);
558
+ if (!currentVideo) {
559
+ throw new Error("Không thể lấy thông tin video hiện tại");
560
+ }
561
+
562
+ // Tìm kiếm các video liên quan dựa trên title channel
563
+ const searchQuery = `${currentVideo.title} ${currentVideo.channel?.name || ""}`;
564
+ const searchResult = await this.search(searchQuery, "auto", {
565
+ limit: limit + offset + history.length,
566
+ type: "video",
567
+ });
568
+
569
+ // Lọc ra video hiện tại và các video trong history
570
+ const filteredTracks = searchResult.tracks.filter((track) => {
571
+ // Loại bỏ video hiện tại
572
+ if (track.id === videoId) return false;
573
+
574
+ // Loại bỏ các video trong history
575
+ if (history.some((h) => h.id === track.id || h.url === track.url)) return false;
576
+
577
+ return true;
578
+ });
579
+
580
+ // Áp dụng offset và limit
581
+ return filteredTracks.slice(offset, offset + limit);
582
+ } catch (error: any) {
583
+ throw new Error(`Failed to get related tracks: ${error?.message || error}`);
584
+ }
585
+ }
586
+
587
+ /**
588
+ * Plugin này không hỗ trợ fallback stream.
589
+ *
590
+ * @param track - Track object
591
+ * @throws Error vì plugin này không hỗ trợ streaming
592
+ */
593
+ async getFallback(track: Track): Promise<any> {
594
+ throw new Error("YTSRPlugin không hỗ trợ fallback streaming. Plugin này chỉ dành cho tìm kiếm metadata.");
595
+ }
596
+ }