@sdeck/youtube 0.0.0-stage → 1.0.1

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/README.md CHANGED
@@ -1,3 +1,82 @@
1
- # Temporary Holding Version
1
+ # YouTube
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Run your YouTube channel from your deck: go live, talk to chat, hold polls, and see how it is doing.
4
+
5
+ ## Install
6
+
7
+ Open **Plugins** in [sdeck Studio](https://sdeck.one) and install **YouTube**.
8
+
9
+ ## Actions
10
+
11
+ | Action | What it does |
12
+ | ------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
13
+ | **Stream status** | Whether you are live, with viewers and time. On the window also the title. |
14
+ | **Stream health** | How well YouTube receives your video, and what is wrong with it. |
15
+ | **Subscribers**, **Likes**, **Newest video** | Counts, with a bar towards a goal of yours. |
16
+ | **Go live** | Starts a planned stream once your encoder sends video, through the preview if it has one. |
17
+ | **End the stream** | Cannot be undone, so put it on a hold or a double press. |
18
+ | **Mark this moment** | Adds the time to the description, where YouTube makes a chapter of it. It can go some seconds back. |
19
+ | **Change title or description**, **Who can watch** | Of the stream that is live. Undo puts back what was there. |
20
+ | **Send a chat message** | Undo deletes it. |
21
+ | **Start a poll**, **End the poll** | Two to four answers. Ending it gives the winner, and can tell chat. |
22
+ | **Play an ad** | For monetized channels. |
23
+ | **Time out or hide someone**, **Delete a chat message** | For workflows that a chat message starts. |
24
+
25
+ ## Setting up
26
+
27
+ Press **Sign in**, and allow access with the channel you stream from. The sign-in is kept with sdeck's
28
+ secrets. **Sign out** ends it.
29
+
30
+ ### With an app of your own
31
+
32
+ YouTube limits what an app may do in a day, and everyone who signs in through sdeck's app shares one
33
+ limit. An app of your own is free and has 10,000 units a day to itself. Get one if you stream for long or
34
+ use chat triggers:
35
+
36
+ 1. In the [Google Cloud console](https://console.cloud.google.com/apis/library/youtube.googleapis.com),
37
+ create a project and enable the **YouTube Data API v3**.
38
+ 2. Set up the consent screen for **External** users, and press **Publish app**. While an app is only being
39
+ tested, Google ends your sign-in every week.
40
+ 3. Create a client of the type **Desktop app**, and copy its **Client ID** and **Client secret** into the
41
+ plugin's settings.
42
+ 4. Press **Sign in** again. Google warns that it has not verified the app. It is your own: press
43
+ **Advanced**, and go on.
44
+
45
+ ### What uses the limit
46
+
47
+ Nothing is read unless a key, a workflow or a trigger uses it.
48
+
49
+ | What | Units |
50
+ | ----------------------------------------------------- | -------------------------------------------------- |
51
+ | Stream status, likes | 1 a minute while offline, 2 while live |
52
+ | Stream health | 2 a minute |
53
+ | Subscribers; the newest video | 12 to 36 an hour each |
54
+ | Triggers for subscribers and comments | 30 an hour each |
55
+ | Triggers for chat, while live | 5 for each look: 1,800 an hour at every 10 seconds |
56
+ | A message or a poll | 20 |
57
+ | Changing the title or who can watch, marking a moment | 51 |
58
+ | A timeout | 200 |
59
+
60
+ **Seconds between looks at the chat** makes the limit last longer: at 10 it is enough for about 5½ hours,
61
+ at 20 for 11. It starts anew at midnight in California.
62
+
63
+ ## Triggers
64
+
65
+ Going live and ending; new subscribers and comments; Super Chats and Super Stickers, gifts with Jewels,
66
+ new members, milestones and given memberships; the end of a poll; and chat commands, where you choose who
67
+ may use each one.
68
+
69
+ YouTube only tells of subscribers who show their subscriptions to everyone. Going live, subscribers and
70
+ comments are noticed within a few minutes, and chat within the seconds you set.
71
+
72
+ ## Live values
73
+
74
+ `youtube.live`, `viewers`, `uptime`, `title`, `likes`, `views`, `url`, `health`, `healthProblem`,
75
+ `subscribers`, `channelViews`, `videos`, `latestSubscriber`, `videoTitle`, `videoViews`, `videoLikes` and
76
+ `videoComments` (all prefixed with `youtube.`). YouTube rounds subscribers down to three digits.
77
+
78
+ ## Permissions
79
+
80
+ | Permission | Why |
81
+ | ---------- | ------------------- |
82
+ | Network | Talking to YouTube. |
@@ -0,0 +1,4 @@
1
+ /** Titles of the streams that are planned. */
2
+ export declare const broadcasts: import("@sdeck/plugin").Source;
3
+ export declare const controls: import("@sdeck/plugin").Action[];
4
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAuHA,8CAA8C;AAC9C,eAAO,MAAM,UAAU,gCAGrB,CAAC;AA+UH,eAAO,MAAM,QAAQ,kCAYpB,CAAC"}
package/dist/api.d.ts ADDED
@@ -0,0 +1,68 @@
1
+ import { type OAuthSignIn, type OAuthTokens } from "@sdeck/plugin";
2
+ /** Everything the plugin does, including chat. Google has none that allow less and still do it. */
3
+ export declare const SCOPES: string[];
4
+ export interface Endpoints {
5
+ authorize: string;
6
+ /** Has `/token` and `/revoke`. */
7
+ oauth: string;
8
+ api: string;
9
+ }
10
+ export declare const GOOGLE: Endpoints;
11
+ export interface SignIn {
12
+ /** Where to send the user. */
13
+ url: string;
14
+ /** Resolves once they approved and the tokens are saved. */
15
+ done: Promise<void>;
16
+ cancel(): void;
17
+ }
18
+ /** Signing in through sdeck's app. */
19
+ export interface Broker {
20
+ start(): Promise<OAuthSignIn>;
21
+ refresh(refreshToken: string): Promise<OAuthTokens>;
22
+ }
23
+ export interface OwnApp {
24
+ clientId: string;
25
+ clientSecret: string;
26
+ }
27
+ export interface ClientOptions {
28
+ /** The user's own app; without one, sdeck's is used. */
29
+ app(): OwnApp | undefined;
30
+ broker: Broker;
31
+ tokens: {
32
+ get(): string | undefined;
33
+ set(refresh: string | undefined): Promise<void>;
34
+ };
35
+ endpoints?: Endpoints;
36
+ }
37
+ export type Method = "GET" | "POST" | "PUT" | "DELETE";
38
+ export type Json = Record<string, unknown>;
39
+ /** Not signed in: there is nothing to retry until the user signs in. */
40
+ export declare class SignedOut extends Error {
41
+ constructor(message?: string);
42
+ }
43
+ /** YouTube refused a request. */
44
+ export declare class YouTubeError extends Error {
45
+ readonly status: number;
46
+ /** Google's word for it, such as `liveChatEnded`. */
47
+ readonly reason: string;
48
+ constructor(status: number,
49
+ /** Google's word for it, such as `liveChatEnded`. */
50
+ reason: string, message: string);
51
+ }
52
+ /** The app has made all the requests it may make today. It gets more at midnight in California. */
53
+ export declare class QuotaError extends YouTubeError {
54
+ constructor(ownApp: boolean);
55
+ }
56
+ export declare class YouTubeClient {
57
+ #private;
58
+ constructor(options: ClientOptions);
59
+ get signedIn(): boolean;
60
+ /** Starts signing in, and waits for the user to allow it in the browser. */
61
+ signIn(): Promise<SignIn>;
62
+ signOut(): Promise<void>;
63
+ /** Calls the API. Resolves with its answer, which is empty for some requests. */
64
+ request(method: Method, path: string, query?: Record<string, string>, body?: unknown): Promise<Json>;
65
+ /** As {@link request}, for the items of a list. */
66
+ list(path: string, query: Record<string, string>): Promise<Json[]>;
67
+ }
68
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAMA,OAAO,EAAc,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAE/E,mGAAmG;AACnG,eAAO,MAAM,MAAM,UAAwD,CAAC;AAE5E,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,MAAM,EAAE,SAIpB,CAAC;AAEF,MAAM,WAAW,MAAM;IACrB,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,4DAA4D;IAC5D,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,sCAAsC;AACtC,MAAM,WAAW,MAAM;IACrB,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9B,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,MA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ACZ,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EAClC,IAAI,CAAC,EAAE,OAAO,GACb,OAAO,CAAC,IAAI,CAAC,CAgCf;IAED,mDAAmD;IAC7C,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAGvE;CAwFF"}
package/dist/chat.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Reads a live chat, by asking again and again: YouTube's way to be told of new messages is gRPC,
3
+ * closes every ten seconds, and costs as much.
4
+ * https://developers.google.com/youtube/v3/live/docs/liveChatMessages/list
5
+ */
6
+ import { type Json, type YouTubeClient } from "./api.ts";
7
+ import { type ChatType } from "./model.ts";
8
+ export interface ChatEvent {
9
+ type: ChatType;
10
+ item: Json;
11
+ }
12
+ export interface ChatOptions {
13
+ client: YouTubeClient;
14
+ chatId: string;
15
+ /** At least this long between two requests. */
16
+ everyMs: () => number;
17
+ onEvent(event: ChatEvent): void;
18
+ onError(error: Error): void;
19
+ signal: AbortSignal;
20
+ /** The first pause after something went wrong (default 5 seconds). */
21
+ retryMs?: number;
22
+ }
23
+ /** How long to wait once the day's requests are used up. */
24
+ export declare const QUOTA_PAUSE_MS: number;
25
+ export declare const pause: (ms: number, signal: AbortSignal) => Promise<void>;
26
+ /** Tells what happens from now on. Resolves when the chat ends, or on `signal`. */
27
+ export declare function readChat(options: ChatOptions): Promise<void>;
28
+ //# sourceMappingURL=chat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,IAAI,EAAyB,KAAK,aAAa,EAAgB,MAAM,UAAU,CAAC;AAC9F,OAAO,EAAQ,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,OAAO,EAAE,MAAM,MAAM,CAAC;IACtB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAChC,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,WAAW,CAAC;IACpB,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,4DAA4D;AAC5D,eAAO,MAAM,cAAc,QAAc,CAAC;AAE1C,eAAO,MAAM,KAAK,OAAQ,MAAM,UAAU,WAAW,kBAUjD,CAAC;AAEL,mFAAmF;AACnF,wBAAsB,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAkDlE"}
@@ -0,0 +1,2 @@
1
+ export declare const displays: import("@sdeck/plugin").Action[];
2
+ //# sourceMappingURL=displays.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"displays.d.ts","sourceRoot":"","sources":["../src/displays.ts"],"names":[],"mappings":"AA6QA,eAAO,MAAM,QAAQ,kCAA0D,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("@sdeck/plugin").PluginDef;
2
+ export default _default;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":""}