@framers/agentos-ext-channel-youtube 0.1.0
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/LICENSE +98 -0
- package/dist/YouTubeChannelAdapter.d.ts +30 -0
- package/dist/YouTubeChannelAdapter.d.ts.map +1 -0
- package/dist/YouTubeChannelAdapter.js +148 -0
- package/dist/YouTubeChannelAdapter.js.map +1 -0
- package/dist/YouTubeService.d.ts +115 -0
- package/dist/YouTubeService.d.ts.map +1 -0
- package/dist/YouTubeService.js +383 -0
- package/dist/YouTubeService.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/analytics.d.ts +41 -0
- package/dist/tools/analytics.d.ts.map +1 -0
- package/dist/tools/analytics.js +49 -0
- package/dist/tools/analytics.js.map +1 -0
- package/dist/tools/comment.d.ts +40 -0
- package/dist/tools/comment.d.ts.map +1 -0
- package/dist/tools/comment.js +39 -0
- package/dist/tools/comment.js.map +1 -0
- package/dist/tools/playlist.d.ts +67 -0
- package/dist/tools/playlist.d.ts.map +1 -0
- package/dist/tools/playlist.js +82 -0
- package/dist/tools/playlist.js.map +1 -0
- package/dist/tools/schedule.d.ts +64 -0
- package/dist/tools/schedule.d.ts.map +1 -0
- package/dist/tools/schedule.js +81 -0
- package/dist/tools/schedule.js.map +1 -0
- package/dist/tools/search.d.ts +52 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +54 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/short.d.ts +55 -0
- package/dist/tools/short.d.ts.map +1 -0
- package/dist/tools/short.js +68 -0
- package/dist/tools/short.js.map +1 -0
- package/dist/tools/trending.d.ts +40 -0
- package/dist/tools/trending.d.ts.map +1 -0
- package/dist/tools/trending.js +42 -0
- package/dist/tools/trending.js.map +1 -0
- package/dist/tools/upload.d.ts +65 -0
- package/dist/tools/upload.d.ts.map +1 -0
- package/dist/tools/upload.js +71 -0
- package/dist/tools/upload.js.map +1 -0
- package/manifest.json +34 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License.
|
|
30
|
+
|
|
31
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
32
|
+
|
|
33
|
+
3. Grant of Patent License.
|
|
34
|
+
|
|
35
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
36
|
+
|
|
37
|
+
4. Redistribution.
|
|
38
|
+
|
|
39
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
40
|
+
|
|
41
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
42
|
+
|
|
43
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
44
|
+
|
|
45
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
46
|
+
|
|
47
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
48
|
+
|
|
49
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
50
|
+
|
|
51
|
+
5. Submission of Contributions.
|
|
52
|
+
|
|
53
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
54
|
+
|
|
55
|
+
6. Trademarks.
|
|
56
|
+
|
|
57
|
+
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
58
|
+
|
|
59
|
+
7. Disclaimer of Warranty.
|
|
60
|
+
|
|
61
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
62
|
+
|
|
63
|
+
8. Limitation of Liability.
|
|
64
|
+
|
|
65
|
+
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
66
|
+
|
|
67
|
+
9. Accepting Warranty or Additional Liability.
|
|
68
|
+
|
|
69
|
+
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
70
|
+
|
|
71
|
+
END OF TERMS AND CONDITIONS
|
|
72
|
+
|
|
73
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
74
|
+
|
|
75
|
+
To apply the Apache License to your work, attach the following
|
|
76
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
77
|
+
replaced with your own identifying information. (Don't include
|
|
78
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
79
|
+
comment syntax for the file format. We also recommend that a
|
|
80
|
+
file or class name and description of purpose be included on the
|
|
81
|
+
same "printed page" as the copyright notice for easier
|
|
82
|
+
identification within third-party archives.
|
|
83
|
+
|
|
84
|
+
Copyright (c) 2025 Framers
|
|
85
|
+
|
|
86
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
87
|
+
you may not use this file except in compliance with the License.
|
|
88
|
+
You may obtain a copy of the License at
|
|
89
|
+
|
|
90
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
91
|
+
|
|
92
|
+
Unless required by applicable law or agreed to in writing, software
|
|
93
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
94
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
95
|
+
See the License for the specific language governing permissions and
|
|
96
|
+
limitations under the License.
|
|
97
|
+
|
|
98
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview IChannelAdapter implementation for YouTube.
|
|
3
|
+
*
|
|
4
|
+
* YouTube supports both content publishing (videos, Shorts) and
|
|
5
|
+
* comment-based interaction. The adapter maps conversations to
|
|
6
|
+
* video comment threads and supports outbound video publishing.
|
|
7
|
+
*/
|
|
8
|
+
import type { IChannelAdapter, ChannelPlatform, ChannelCapability, ChannelAuthConfig, ChannelConnectionInfo, ChannelSendResult, MessageContent, ChannelEventHandler, ChannelEventType } from '@framers/agentos';
|
|
9
|
+
import { YouTubeService } from './YouTubeService';
|
|
10
|
+
export declare class YouTubeChannelAdapter implements IChannelAdapter {
|
|
11
|
+
private readonly service;
|
|
12
|
+
readonly platform: ChannelPlatform;
|
|
13
|
+
readonly displayName = "YouTube";
|
|
14
|
+
readonly capabilities: readonly ChannelCapability[];
|
|
15
|
+
private handlers;
|
|
16
|
+
constructor(service: YouTubeService);
|
|
17
|
+
initialize(_auth: ChannelAuthConfig): Promise<void>;
|
|
18
|
+
shutdown(): Promise<void>;
|
|
19
|
+
getConnectionInfo(): ChannelConnectionInfo;
|
|
20
|
+
sendMessage(conversationId: string, content: MessageContent): Promise<ChannelSendResult>;
|
|
21
|
+
sendTypingIndicator(_conversationId: string, _isTyping: boolean): Promise<void>;
|
|
22
|
+
on(handler: ChannelEventHandler, eventTypes?: ChannelEventType[]): () => void;
|
|
23
|
+
getConversationInfo(conversationId: string): Promise<{
|
|
24
|
+
name?: string;
|
|
25
|
+
memberCount?: number;
|
|
26
|
+
isGroup: boolean;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=YouTubeChannelAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YouTubeChannelAdapter.d.ts","sourceRoot":"","sources":["../src/YouTubeChannelAdapter.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,qBAAa,qBAAsB,YAAW,eAAe;IAgB/C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAfpC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAa;IAC/C,QAAQ,CAAC,WAAW,aAAa;IACjC,QAAQ,CAAC,YAAY,EAAE,SAAS,iBAAiB,EAAE,CASxC;IAEX,OAAO,CAAC,QAAQ,CAAkE;gBAErD,OAAO,EAAE,cAAc;IAE9C,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMnD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,iBAAiB,IAAI,qBAAqB;IAMpC,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAoDxF,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrF,EAAE,CAAC,OAAO,EAAE,mBAAmB,EAAE,UAAU,CAAC,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAI;IAOvE,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC;QACzD,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,CAAC;CAmBH"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview IChannelAdapter implementation for YouTube.
|
|
5
|
+
*
|
|
6
|
+
* YouTube supports both content publishing (videos, Shorts) and
|
|
7
|
+
* comment-based interaction. The adapter maps conversations to
|
|
8
|
+
* video comment threads and supports outbound video publishing.
|
|
9
|
+
*/
|
|
10
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
+
}) : function(o, v) {
|
|
24
|
+
o["default"] = v;
|
|
25
|
+
});
|
|
26
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
+
var ownKeys = function(o) {
|
|
28
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
+
var ar = [];
|
|
30
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
+
return ar;
|
|
32
|
+
};
|
|
33
|
+
return ownKeys(o);
|
|
34
|
+
};
|
|
35
|
+
return function (mod) {
|
|
36
|
+
if (mod && mod.__esModule) return mod;
|
|
37
|
+
var result = {};
|
|
38
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
+
__setModuleDefault(result, mod);
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.YouTubeChannelAdapter = void 0;
|
|
45
|
+
class YouTubeChannelAdapter {
|
|
46
|
+
constructor(service) {
|
|
47
|
+
this.service = service;
|
|
48
|
+
this.platform = 'youtube';
|
|
49
|
+
this.displayName = 'YouTube';
|
|
50
|
+
this.capabilities = [
|
|
51
|
+
'video',
|
|
52
|
+
'reels',
|
|
53
|
+
'text',
|
|
54
|
+
'reactions',
|
|
55
|
+
'threads',
|
|
56
|
+
'engagement_metrics',
|
|
57
|
+
'content_discovery',
|
|
58
|
+
'scheduling',
|
|
59
|
+
];
|
|
60
|
+
this.handlers = new Map();
|
|
61
|
+
}
|
|
62
|
+
async initialize(_auth) {
|
|
63
|
+
// YouTube does not have real-time inbound webhooks in the standard
|
|
64
|
+
// Data API v3. Inbound event support would require polling or
|
|
65
|
+
// PubSubHubbub integration.
|
|
66
|
+
}
|
|
67
|
+
async shutdown() {
|
|
68
|
+
this.handlers.clear();
|
|
69
|
+
}
|
|
70
|
+
getConnectionInfo() {
|
|
71
|
+
return {
|
|
72
|
+
status: this.service.isRunning ? 'connected' : 'disconnected',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async sendMessage(conversationId, content) {
|
|
76
|
+
// On YouTube, a "conversation" maps to a video ID.
|
|
77
|
+
// Sending a message means posting a comment on that video.
|
|
78
|
+
const textBlock = content.blocks.find((b) => b.type === 'text');
|
|
79
|
+
const videoBlock = content.blocks.find((b) => b.type === 'video');
|
|
80
|
+
// If a video block is present, this is a video upload rather than a comment
|
|
81
|
+
if (videoBlock && videoBlock.type === 'video') {
|
|
82
|
+
const { Readable } = await Promise.resolve().then(() => __importStar(require('stream')));
|
|
83
|
+
const { default: https } = await Promise.resolve().then(() => __importStar(require('https')));
|
|
84
|
+
// Fetch the video stream from the URL
|
|
85
|
+
const videoStream = await new Promise((resolve, reject) => {
|
|
86
|
+
https.get(videoBlock.url, (res) => resolve(res)).on('error', reject);
|
|
87
|
+
});
|
|
88
|
+
const result = await this.service.uploadVideo({
|
|
89
|
+
title: content.platformOptions?.['title'] ?? videoBlock.caption ?? 'Untitled',
|
|
90
|
+
description: textBlock?.type === 'text' ? textBlock.text : (videoBlock.caption ?? ''),
|
|
91
|
+
tags: content.platformOptions?.['tags'],
|
|
92
|
+
categoryId: content.platformOptions?.['categoryId'],
|
|
93
|
+
privacyStatus: content.platformOptions?.['privacyStatus'],
|
|
94
|
+
videoStream,
|
|
95
|
+
mimeType: videoBlock.mimeType,
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
messageId: result.id,
|
|
99
|
+
timestamp: result.publishedAt ?? new Date().toISOString(),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
// Otherwise, post a comment on the video
|
|
103
|
+
if (!conversationId) {
|
|
104
|
+
throw new Error('Video ID (conversationId) is required for posting comments');
|
|
105
|
+
}
|
|
106
|
+
const text = textBlock?.type === 'text' ? textBlock.text : '';
|
|
107
|
+
if (!text) {
|
|
108
|
+
throw new Error('Text content is required for posting a comment');
|
|
109
|
+
}
|
|
110
|
+
const parentCommentId = content.replyToMessageId;
|
|
111
|
+
const result = await this.service.postComment(conversationId, text, parentCommentId);
|
|
112
|
+
return {
|
|
113
|
+
messageId: result.id,
|
|
114
|
+
timestamp: result.publishedAt ?? new Date().toISOString(),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
async sendTypingIndicator(_conversationId, _isTyping) {
|
|
118
|
+
// YouTube does not support typing indicators — no-op
|
|
119
|
+
}
|
|
120
|
+
on(handler, eventTypes) {
|
|
121
|
+
this.handlers.set(handler, eventTypes);
|
|
122
|
+
return () => {
|
|
123
|
+
this.handlers.delete(handler);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
async getConversationInfo(conversationId) {
|
|
127
|
+
// conversationId is a video ID on YouTube
|
|
128
|
+
try {
|
|
129
|
+
const video = await this.service.getVideoStatistics(conversationId);
|
|
130
|
+
return {
|
|
131
|
+
name: video.title,
|
|
132
|
+
isGroup: true, // YouTube videos are public conversations
|
|
133
|
+
metadata: {
|
|
134
|
+
channelTitle: video.channelTitle,
|
|
135
|
+
viewCount: video.viewCount,
|
|
136
|
+
likeCount: video.likeCount,
|
|
137
|
+
commentCount: video.commentCount,
|
|
138
|
+
duration: video.duration,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return { isGroup: true };
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.YouTubeChannelAdapter = YouTubeChannelAdapter;
|
|
148
|
+
//# sourceMappingURL=YouTubeChannelAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YouTubeChannelAdapter.js","sourceRoot":"","sources":["../src/YouTubeChannelAdapter.ts"],"names":[],"mappings":";AAAA,cAAc;AACd;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeH,MAAa,qBAAqB;IAgBhC,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;QAf3C,aAAQ,GAAoB,SAAS,CAAC;QACtC,gBAAW,GAAG,SAAS,CAAC;QACxB,iBAAY,GAAiC;YACpD,OAAO;YACP,OAAO;YACP,MAAM;YACN,WAAW;YACX,SAAS;YACT,oBAAoB;YACpB,mBAAmB;YACnB,YAAY;SACJ,CAAC;QAEH,aAAQ,GAAG,IAAI,GAAG,EAAuD,CAAC;IAE3B,CAAC;IAExD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AAW,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SAC1D,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,eAAuB,EAAE,SAAkB;QACnE,qDAAqD;IACvD,CAAC;IAED,EAAE,CAAC,OAA4B,EAAE,UAA+B;QAC9D,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACvC,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,cAAsB;QAM9C,0CAA0C;QAC1C,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;YACpE,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,KAAK;gBACjB,OAAO,EAAE,IAAI,EAAE,0CAA0C;gBACzD,QAAQ,EAAE;oBACR,YAAY,EAAE,KAAK,CAAC,YAAY;oBAChC,SAAS,EAAE,KAAK,CAAC,SAAS;oBAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;oBAC1B,YAAY,EAAE,KAAK,CAAC,YAAY;oBAChC,QAAQ,EAAE,KAAK,CAAC,QAAQ;iBACzB;aACF,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;CACF;AAzHD,sDAyHC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview YouTube Data API v3 service layer.
|
|
3
|
+
*
|
|
4
|
+
* Wraps googleapis for video upload, Shorts, comments, search,
|
|
5
|
+
* trending, analytics, playlists, and scheduling.
|
|
6
|
+
*/
|
|
7
|
+
import { Readable } from 'stream';
|
|
8
|
+
export interface YouTubeConfig {
|
|
9
|
+
apiKey: string;
|
|
10
|
+
oauth?: {
|
|
11
|
+
clientId: string;
|
|
12
|
+
clientSecret: string;
|
|
13
|
+
refreshToken: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface VideoUploadOptions {
|
|
17
|
+
title: string;
|
|
18
|
+
description: string;
|
|
19
|
+
tags?: string[];
|
|
20
|
+
categoryId?: string;
|
|
21
|
+
privacyStatus?: 'public' | 'private' | 'unlisted';
|
|
22
|
+
videoStream: Readable;
|
|
23
|
+
mimeType?: string;
|
|
24
|
+
isShort?: boolean;
|
|
25
|
+
publishAt?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface VideoResult {
|
|
28
|
+
id: string;
|
|
29
|
+
title: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
channelId?: string;
|
|
32
|
+
channelTitle?: string;
|
|
33
|
+
publishedAt?: string;
|
|
34
|
+
thumbnailUrl?: string;
|
|
35
|
+
duration?: string;
|
|
36
|
+
viewCount?: number;
|
|
37
|
+
likeCount?: number;
|
|
38
|
+
commentCount?: number;
|
|
39
|
+
tags?: string[];
|
|
40
|
+
}
|
|
41
|
+
export interface CommentResult {
|
|
42
|
+
id: string;
|
|
43
|
+
videoId: string;
|
|
44
|
+
text: string;
|
|
45
|
+
authorDisplayName?: string;
|
|
46
|
+
authorChannelId?: string;
|
|
47
|
+
publishedAt?: string;
|
|
48
|
+
likeCount?: number;
|
|
49
|
+
replyCount?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface SearchResult {
|
|
52
|
+
id: string;
|
|
53
|
+
type: 'video' | 'channel' | 'playlist';
|
|
54
|
+
title: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
channelTitle?: string;
|
|
57
|
+
publishedAt?: string;
|
|
58
|
+
thumbnailUrl?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface PlaylistResult {
|
|
61
|
+
id: string;
|
|
62
|
+
title: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
itemCount?: number;
|
|
65
|
+
privacyStatus?: string;
|
|
66
|
+
publishedAt?: string;
|
|
67
|
+
thumbnailUrl?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface ChannelAnalytics {
|
|
70
|
+
viewCount: number;
|
|
71
|
+
subscriberCount: number;
|
|
72
|
+
videoCount: number;
|
|
73
|
+
likeCount?: number;
|
|
74
|
+
}
|
|
75
|
+
export declare class YouTubeService {
|
|
76
|
+
private youtube;
|
|
77
|
+
private youtubeAuth;
|
|
78
|
+
private running;
|
|
79
|
+
private readonly config;
|
|
80
|
+
constructor(config: YouTubeConfig);
|
|
81
|
+
initialize(): Promise<void>;
|
|
82
|
+
shutdown(): Promise<void>;
|
|
83
|
+
get isRunning(): boolean;
|
|
84
|
+
uploadVideo(options: VideoUploadOptions): Promise<VideoResult>;
|
|
85
|
+
postComment(videoId: string, text: string, parentCommentId?: string): Promise<CommentResult>;
|
|
86
|
+
getComments(videoId: string, maxResults?: number): Promise<CommentResult[]>;
|
|
87
|
+
search(query: string, options?: {
|
|
88
|
+
type?: 'video' | 'channel' | 'playlist';
|
|
89
|
+
maxResults?: number;
|
|
90
|
+
order?: string;
|
|
91
|
+
regionCode?: string;
|
|
92
|
+
}): Promise<SearchResult[]>;
|
|
93
|
+
getTrending(regionCode?: string, categoryId?: string, maxResults?: number): Promise<VideoResult[]>;
|
|
94
|
+
getVideoStatistics(videoId: string): Promise<VideoResult>;
|
|
95
|
+
getChannelStatistics(channelId?: string): Promise<ChannelAnalytics>;
|
|
96
|
+
createPlaylist(title: string, description?: string, privacyStatus?: 'public' | 'private' | 'unlisted'): Promise<PlaylistResult>;
|
|
97
|
+
addToPlaylist(playlistId: string, videoId: string): Promise<void>;
|
|
98
|
+
getPlaylistItems(playlistId: string, maxResults?: number): Promise<VideoResult[]>;
|
|
99
|
+
getPlaylists(channelId?: string, maxResults?: number): Promise<PlaylistResult[]>;
|
|
100
|
+
deletePlaylist(playlistId: string): Promise<void>;
|
|
101
|
+
getMyChannel(): Promise<{
|
|
102
|
+
id: string;
|
|
103
|
+
title: string;
|
|
104
|
+
description?: string;
|
|
105
|
+
subscriberCount: number;
|
|
106
|
+
videoCount: number;
|
|
107
|
+
viewCount: number;
|
|
108
|
+
customUrl?: string;
|
|
109
|
+
thumbnailUrl?: string;
|
|
110
|
+
}>;
|
|
111
|
+
private requirePublicClient;
|
|
112
|
+
private requireAuthClient;
|
|
113
|
+
private mapVideoResult;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=YouTubeService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YouTubeService.d.ts","sourceRoot":"","sources":["../src/YouTubeService.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAMlC,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;IAClD,WAAW,EAAE,QAAQ,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,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