diff --git a/doc/specs/examples/tv-getBestOngoingGamesOfTvChannel.json b/doc/specs/examples/tv-getBestOngoingGamesOfTvChannel.json new file mode 100644 index 00000000..af113b71 --- /dev/null +++ b/doc/specs/examples/tv-getBestOngoingGamesOfTvChannel.json @@ -0,0 +1,47 @@ +{ + "id": "7hqSgANR", + "rated": true, + "variant": "standard", + "speed": "bullet", + "perf": "bullet", + "createdAt": 1746239199251, + "lastMoveAt": 1746239280267, + "status": "started", + "source": "pool", + "players": { + "white": { + "user": { + "name": "AlfilOscuro2", + "flair": "nature.penguin", + "id": "alfiloscuro2" + }, + "rating": 2991 + }, + "black": { + "user": { + "name": "German_Bazeev", + "title": "FM", + "id": "german_bazeev" + }, + "rating": 2939 + } + }, + "opening": { + "eco": "A41", + "name": "Queen's Pawn Game", + "ply": 2 + }, + "moves": "d4 d6 Bf4 g6 Nc3 Bg7 e4 c6 Nf3 b5 Bd3 b4 Ne2 Bg4 Qd2 Bxf3 gxf3 a5 a3 bxa3 Rxa3 Nf6 Bg5 O-O h4 h5 f4 d5 e5 Ne4 Qe3 Nxg5 fxg5 e6 f4 Nd7 O-O Qb6 Rfa1 c5 dxc5 Nxc5 Qf2 Rfb8 b3 Bf8 R3a2 Qc7 Qf3 Nd7 Kg2 Bc5 c4 dxc4 Bxc4 Bb6 Rc1 Qd8 Rac2 Qe7 Nc3 Rd8 Ne4 Kg7 Rd1 Nc5", + "clocks": [ + 6000, 6000, 5948, 6000, 5814, 5950, 5723, 5892, 5614, 5820, 5541, 5757, 5442, 5625, 5376, 5513, 5345, 5357, 5285, + 5229, 5285, 5178, 5191, 5064, 5138, 4897, 5071, 4620, 4961, 4540, 4885, 4408, 4831, 4408, 4724, 4334, 4647, 4137, + 4553, 3903, 4367, 3903, 4165, 3804, 3982, 3708, 3822, 3493, 3689, 3374, 3623, 3374, 3152, 3227, 3148, 3103, 3085, + 2799, 3085, 2687, 3033, 2606, 2968, 2564, 2870, 2477 + ], + "pgn": "[Event \"Rated bullet game\"]\n[Site \"https://lichess.org/7hqSgANR\"]\n[Date \"2025.05.03\"]\n[White \"AlfilOscuro2\"]\n[Black \"German_Bazeev\"]\n[Result \"*\"]\n[GameId \"7hqSgANR\"]\n[UTCDate \"2025.05.03\"]\n[UTCTime \"02:26:39\"]\n[WhiteElo \"2991\"]\n[BlackElo \"2939\"]\n[BlackTitle \"FM\"]\n[Variant \"Standard\"]\n[TimeControl \"60+0\"]\n[ECO \"A41\"]\n[Opening \"Queen's Pawn Game\"]\n[Termination \"Unterminated\"]\n\n1. d4 { [%clk 0:01:00] } 1... d6 { [%clk 0:01:00] } 2. Bf4 { [%clk 0:00:59] } 2... g6 { [%clk 0:01:00] } 3. Nc3 { [%clk 0:00:58] } 3... Bg7 { [%clk 0:01:00] } 4. e4 { [%clk 0:00:57] } 4... c6 { [%clk 0:00:59] } 5. Nf3 { [%clk 0:00:56] } 5... b5 { [%clk 0:00:58] } 6. Bd3 { [%clk 0:00:55] } 6... b4 { [%clk 0:00:58] } 7. Ne2 { [%clk 0:00:54] } 7... Bg4 { [%clk 0:00:56] } 8. Qd2 { [%clk 0:00:54] } 8... Bxf3 { [%clk 0:00:55] } 9. gxf3 { [%clk 0:00:53] } 9... a5 { [%clk 0:00:54] } 10. a3 { [%clk 0:00:53] } 10... bxa3 { [%clk 0:00:52] } 11. Rxa3 { [%clk 0:00:53] } 11... Nf6 { [%clk 0:00:52] } 12. Bg5 { [%clk 0:00:52] } 12... O-O { [%clk 0:00:51] } 13. h4 { [%clk 0:00:51] } 13... h5 { [%clk 0:00:49] } 14. f4 { [%clk 0:00:51] } 14... d5 { [%clk 0:00:46] } 15. e5 { [%clk 0:00:50] } 15... Ne4 { [%clk 0:00:45] } 16. Qe3 { [%clk 0:00:49] } 16... Nxg5 { [%clk 0:00:44] } 17. fxg5 { [%clk 0:00:48] } 17... e6 { [%clk 0:00:44] } 18. f4 { [%clk 0:00:47] } 18... Nd7 { [%clk 0:00:43] } 19. O-O { [%clk 0:00:46] } 19... Qb6 { [%clk 0:00:41] } 20. Rfa1 { [%clk 0:00:46] } 20... c5 { [%clk 0:00:39] } 21. dxc5 { [%clk 0:00:44] } 21... Nxc5 { [%clk 0:00:39] } 22. Qf2 { [%clk 0:00:42] } 22... Rfb8 { [%clk 0:00:38] } 23. b3 { [%clk 0:00:40] } 23... Bf8 { [%clk 0:00:37] } 24. R3a2 { [%clk 0:00:38] } 24... Qc7 { [%clk 0:00:35] } 25. Qf3 { [%clk 0:00:37] } 25... Nd7 { [%clk 0:00:34] } 26. Kg2 { [%clk 0:00:36] } 26... Bc5 { [%clk 0:00:34] } 27. c4 { [%clk 0:00:32] } 27... dxc4 { [%clk 0:00:32] } 28. Bxc4 { [%clk 0:00:31] } 28... Bb6 { [%clk 0:00:31] } 29. Rc1 { [%clk 0:00:31] } 29... Qd8 { [%clk 0:00:28] } 30. Rac2 { [%clk 0:00:31] } 30... Qe7 { [%clk 0:00:27] } 31. Nc3 { [%clk 0:00:30] } 31... Rd8 { [%clk 0:00:26] } 32. Ne4 { [%clk 0:00:30] } 32... Kg7 { [%clk 0:00:26] } 33. Rd1 { [%clk 0:00:29] } 33... Nc5 { [%clk 0:00:25] } *\n\n\n", + "clock": { + "initial": 60, + "increment": 0, + "totalTime": 60 + } +} diff --git a/doc/specs/examples/tv-getBestOngoingGamesOfTvChannel.pgn.yaml b/doc/specs/examples/tv-getBestOngoingGamesOfTvChannel.pgn.yaml new file mode 100644 index 00000000..cd7e7a73 --- /dev/null +++ b/doc/specs/examples/tv-getBestOngoingGamesOfTvChannel.pgn.yaml @@ -0,0 +1,57 @@ +value: | + [Event "Rated bullet game"] + [Site "https://lichess.org/FRgSNyPs"] + [Date "2025.05.03"] + [White "imthatmf"] + [Black "James-Stiven"] + [Result "*"] + [GameId "FRgSNyPs"] + [UTCDate "2025.05.03"] + [UTCTime "02:27:53"] + [WhiteElo "2769"] + [BlackElo "2563"] + [Variant "Standard"] + [TimeControl "60+0"] + [ECO "A01"] + [Termination "Unterminated"] + + 1. b3 b6 2. Bb2 Bb7 3. Nf3 c5 4. d4 Nc6 5. d5 Nb8 6. c4 d6 7. e4 * + + + [Event "Rated bullet game"] + [Site "https://lichess.org/lSKZeraZ"] + [Date "2025.05.03"] + [White "kon77"] + [Black "McBeast"] + [Result "*"] + [GameId "lSKZeraZ"] + [UTCDate "2025.05.03"] + [UTCTime "02:27:40"] + [WhiteElo "2598"] + [BlackElo "2669"] + [BlackTitle "NM"] + [Variant "Standard"] + [TimeControl "60+0"] + [ECO "C42"] + [Termination "Unterminated"] + + 1. e4 e5 2. Nf3 Nf6 3. Bc4 Nxe4 4. Nxe5 d5 5. Be2 Bd6 6. d4 O-O 7. O-O Nd7 8. Nc3 Nxc3 9. bxc3 Nxe5 10. dxe5 Bxe5 11. Rb1 * + + + [Event "Rated bullet game"] + [Site "https://lichess.org/vQTKVHoE"] + [Date "2025.05.03"] + [White "MeurtrierMurilloXV"] + [Black "Eltablifero50"] + [Result "*"] + [GameId "vQTKVHoE"] + [UTCDate "2025.05.03"] + [UTCTime "02:27:19"] + [WhiteElo "2637"] + [BlackElo "2687"] + [Variant "Standard"] + [TimeControl "60+0"] + [ECO "D02"] + [Termination "Unterminated"] + + 1. Nf3 d5 2. d4 Nf6 3. g3 e6 4. Bg2 Be7 5. Kf1 O-O 6. c4 dxc4 7. Nbd2 b5 8. a4 c6 9. axb5 cxb5 10. Ne5 Nd5 11. e4 Nf6 12. b3 Qxd4 13. Ba3 Bxa3 * diff --git a/doc/specs/examples/tv-getCurrentTvGames.json b/doc/specs/examples/tv-getCurrentTvGames.json new file mode 100644 index 00000000..835f4d89 --- /dev/null +++ b/doc/specs/examples/tv-getCurrentTvGames.json @@ -0,0 +1,159 @@ +{ + "chess960": { + "user": { + "name": "ADDRESP", + "flair": "nature.crab", + "id": "addresp" + }, + "rating": 2217, + "gameId": "vR3yQVOA", + "color": "black" + }, + "best": { + "user": { + "name": "Olexiy_Bilych", + "title": "IM", + "flair": "activity.trophy", + "id": "olexiy_bilych" + }, + "rating": 2782, + "gameId": "xYfwLFIi", + "color": "black" + }, + "antichess": { + "user": { + "name": "bwmtone", + "flair": "activity.tennis", + "patron": true, + "id": "bwmtone" + }, + "rating": 2245, + "gameId": "wwVmRFKS", + "color": "black" + }, + "computer": { + "user": { + "name": "mathpablo", + "id": "mathpablo" + }, + "rating": 1949, + "gameId": "uAGDSlyB", + "color": "white" + }, + "bullet": { + "user": { + "name": "JurgenSanchez97", + "title": "NM", + "id": "jurgensanchez97" + }, + "rating": 2878, + "gameId": "HilOlgQm", + "color": "black" + }, + "horde": { + "user": { + "name": "ASKCHESS", + "id": "askchess" + }, + "rating": 2150, + "gameId": "ZPnpt4PD", + "color": "black" + }, + "atomic": { + "user": { + "name": "AeFanMu12345", + "flair": "smileys.ghost", + "id": "aefanmu12345" + }, + "rating": 1898, + "gameId": "J9obVj6r", + "color": "black" + }, + "bot": { + "user": { + "name": "MayhemPI_cluster", + "title": "BOT", + "id": "mayhempi_cluster" + }, + "rating": 3213, + "gameId": "TJ0vdQL7", + "color": "white" + }, + "racingKings": { + "user": { + "name": "stillinflipflops", + "id": "stillinflipflops" + }, + "rating": 2301, + "gameId": "enHMb9X9", + "color": "white" + }, + "ultraBullet": { + "user": { + "name": "asteroid44", + "id": "asteroid44" + }, + "rating": 1730, + "gameId": "W5khY2w7", + "color": "black" + }, + "blitz": { + "user": { + "name": "Olexiy_Bilych", + "title": "IM", + "flair": "activity.trophy", + "id": "olexiy_bilych" + }, + "rating": 2782, + "gameId": "xYfwLFIi", + "color": "black" + }, + "kingOfTheHill": { + "user": { + "name": "MaxwellsSilvrHammer", + "flair": "nature.snail", + "id": "maxwellssilvrhammer" + }, + "rating": 2213, + "gameId": "jXDBqUjs", + "color": "white" + }, + "crazyhouse": { + "user": { + "name": "VRDeveloper", + "flair": "smileys.robot", + "id": "vrdeveloper" + }, + "rating": 2263, + "gameId": "VlDXktTm", + "color": "black" + }, + "threeCheck": { + "user": { + "name": "clippencough", + "id": "clippencough" + }, + "rating": 1951, + "gameId": "aElB1lrQ", + "color": "black" + }, + "classical": { + "user": { + "name": "Tsagaanuul0121", + "id": "tsagaanuul0121" + }, + "rating": 1966, + "gameId": "YjEOekEz", + "color": "black" + }, + "rapid": { + "user": { + "name": "FoxyMate1776", + "flair": "activity.chess-pawn", + "id": "foxymate1776" + }, + "rating": 2465, + "gameId": "v050nHBP", + "color": "black" + } +} diff --git a/doc/specs/examples/tv-streamCurrentTvGame-move.json.yaml b/doc/specs/examples/tv-streamCurrentTvGame-move.json.yaml new file mode 100644 index 00000000..0d768cd6 --- /dev/null +++ b/doc/specs/examples/tv-streamCurrentTvGame-move.json.yaml @@ -0,0 +1,5 @@ +value: + { + "t": "fen", + "d": { "fen": "q4r2/5ppk/b3p3/Q1b1P3/8/3n1N2/1P1N1PPP/2B2RK1 w - - 4 26", "lm": "e7c5", "wc": 119, "bc": 119 }, + } diff --git a/doc/specs/examples/tv-streamCurrentTvGame-newGame.json.yaml b/doc/specs/examples/tv-streamCurrentTvGame-newGame.json.yaml new file mode 100644 index 00000000..6285b3fd --- /dev/null +++ b/doc/specs/examples/tv-streamCurrentTvGame-newGame.json.yaml @@ -0,0 +1,32 @@ +value: + { + "t": "featured", + "d": + { + "id": "xYfwLFIi", + "orientation": "black", + "players": + [ + { + "color": "white", + "user": + { + "name": "chargemax23", + "title": "IM", + "flair": "objects.battery", + "patron": true, + "id": "chargemax23", + }, + "rating": 2719, + "seconds": 169, + }, + { + "color": "black", + "user": { "name": "Olexiy_Bilych", "title": "IM", "flair": "activity.trophy", "id": "olexiy_bilych" }, + "rating": 2782, + "seconds": 169, + }, + ], + "fen": "q4r2/4bppk/b3p3/Q3P3/8/3n1N2/1P1N1PPP/2B2RK1 b - - 3 25", + }, + } diff --git a/doc/specs/schemas/GameJson.yaml b/doc/specs/schemas/GameJson.yaml index c8919f9d..45dda615 100644 --- a/doc/specs/schemas/GameJson.yaml +++ b/doc/specs/schemas/GameJson.yaml @@ -95,27 +95,3 @@ required: - lastMoveAt - status - players -example: - { - "id": "q7ZvsdUF", - "rated": true, - "variant": "standard", - "speed": "blitz", - "perf": "blitz", - "createdAt": 1514505150384, - "lastMoveAt": 1514505592843, - "status": "draw", - "players": - { - "white": - { - "user": { "name": "Lance5500", "title": "LM", "patron": true, "id": "lance5500" }, - "rating": 2389, - "ratingDiff": 4, - }, - "black": { "user": { "name": "TryingHard87", "id": "tryinghard87" }, "rating": 2498, "ratingDiff": -4 }, - }, - "opening": { "eco": "D31", "name": "Semi-Slav Defense: Marshall Gambit", "ply": 7 }, - "moves": "d4 d5 c4 c6 Nc3 e6 e4 Nd7 exd5 cxd5 cxd5 exd5 Nxd5 Nb6 Bb5+ Bd7 Qe2+ Ne7 Nxb6 Qxb6 Bxd7+ Kxd7 Nf3 Qa6 Ne5+ Ke8 Qf3 f6 Nd3 Qc6 Qe2 Kf7 O-O Kg8 Bd2 Re8 Rac1 Nf5 Be3 Qe6 Rfe1 g6 b3 Bd6 Qd2 Kf7 Bf4 Qd7 Bxd6 Nxd6 Nc5 Rxe1+ Rxe1 Qc6 f3 Re8 Rxe8 Nxe8 Kf2 Nc7 Qb4 b6 Qc4+ Nd5 Nd3 Qe6 Nb4 Ne7 Qxe6+ Kxe6 Ke3 Kd6 g3 h6 Kd3 h5 Nc2 Kd5 a3 Nc6 Ne3+ Kd6 h4 Nd8 g4 Ne6 Ke4 Ng7 Nc4+ Ke6 d5+ Kd7 a4 g5 gxh5 Nxh5 hxg5 fxg5 Kf5 Nf4 Ne3 Nh3 Kg4 Ng1 Nc4 Kc7 Nd2 Kd6 Kxg5 Kxd5 f4 Nh3+ Kg4 Nf2+ Kf3 Nd3 Ke3 Nc5 Kf3 Ke6 Ke3 Kf5 Kd4 Ne6+ Kc4", - "clock": { "initial": 300, "increment": 3, "totalTime": 420 }, - } diff --git a/doc/specs/schemas/TvFeed.yaml b/doc/specs/schemas/TvFeed.yaml index 4b6698c2..85bf514c 100644 --- a/doc/specs/schemas/TvFeed.yaml +++ b/doc/specs/schemas/TvFeed.yaml @@ -36,17 +36,7 @@ properties: - "white" - "black" user: - type: object - properties: - name: - type: string - id: - type: string - title: - type: string - required: - - id - - name + $ref: "./LightUser.yaml" rating: type: integer seconds: diff --git a/doc/specs/schemas/TvGame.yaml b/doc/specs/schemas/TvGame.yaml index 9f744ccc..b2cae984 100644 --- a/doc/specs/schemas/TvGame.yaml +++ b/doc/specs/schemas/TvGame.yaml @@ -2,12 +2,7 @@ type: object properties: user: - allOf: - - $ref: "./LightUser.yaml" - - type: object - properties: - flair: - $ref: "./Flair.yaml" + $ref: "./LightUser.yaml" rating: type: number gameId: diff --git a/doc/specs/tags/tv/api-tv-channel-feed.yaml b/doc/specs/tags/tv/api-tv-channel-feed.yaml index e94ccfd3..16e7ed0d 100644 --- a/doc/specs/tags/tv/api-tv-channel-feed.yaml +++ b/doc/specs/tags/tv/api-tv-channel-feed.yaml @@ -23,7 +23,7 @@ get: schema: $ref: "../../schemas/TvFeed.yaml" examples: - first line: - $ref: "../../examples/tvFeedFirst.yaml" - subsequent lines: - $ref: "../../examples/tvFeedFen.yaml" + new featured game: + $ref: "../../examples/tv-streamCurrentTvGame-newGame.json.yaml" + move: + $ref: "../../examples/tv-streamCurrentTvGame-move.json.yaml" diff --git a/doc/specs/tags/tv/api-tv-channel.yaml b/doc/specs/tags/tv/api-tv-channel.yaml index 0dab975f..556cbc08 100644 --- a/doc/specs/tags/tv/api-tv-channel.yaml +++ b/doc/specs/tags/tv/api-tv-channel.yaml @@ -64,6 +64,11 @@ get: application/x-chess-pgn: schema: $ref: "../../schemas/GamePgn.yaml" + examples: + pgn: + $ref: "../../examples/tv-getBestOngoingGamesOfTvChannel.pgn.yaml" application/x-ndjson: schema: $ref: "../../schemas/GameJson.yaml" + example: + $ref: "../../examples/tv-getBestOngoingGamesOfTvChannel.json" diff --git a/doc/specs/tags/tv/api-tv-channels.yaml b/doc/specs/tags/tv/api-tv-channels.yaml index 48d316b6..958efb93 100644 --- a/doc/specs/tags/tv/api-tv-channels.yaml +++ b/doc/specs/tags/tv/api-tv-channels.yaml @@ -71,118 +71,5 @@ get: best: $ref: "../../schemas/TvGame.yaml" - example: - { - "bot": - { - "user": { "id": "leelachess", "name": "LeelaChess", "title": "BOT" }, - "rating": 2660, - "gameId": "Zznv9MIl", - "color": "black", - }, - "blitz": - { - "user": { "id": "lekkerkortook", "name": "LekkerKortOok" }, - "rating": 2603, - "gameId": "hTJ4v7Mp", - "color": "black", - }, - "racingKings": - { - "user": { "id": "chesslo21", "name": "chesslo21" }, - "rating": 2123, - "gameId": "lgCDl5Of", - "color": "white", - }, - "ultraBullet": - { - "user": { "id": "farmville", "name": "Farmville" }, - "rating": 2338, - "gameId": "NEY6OQ32", - "color": "white", - }, - "bullet": - { - "user": { "id": "nurmibrah", "name": "nurmiBrah" }, - "rating": 2499, - "gameId": "5LgyE516", - "color": "black", - }, - "classical": - { - "user": { "id": "holden_m_j_thomas", "name": "Holden_M_J_Thomas" }, - "rating": 1806, - "gameId": "k3oLby6N", - "color": "white", - }, - "threeCheck": - { - "user": { "id": "pepellou", "name": "pepellou", "patron": true }, - "rating": 1978, - "gameId": "Og5RCvmu", - "color": "black", - }, - "antichess": - { - "user": { "id": "maria-bakkar", "name": "maria-bakkar" }, - "rating": 2103, - "gameId": "toCr41yx", - "color": "black", - }, - "computer": - { - "user": { "id": "oh_my_goat_im_so_bat", "name": "oh_my_goat_Im_so_bat" }, - "rating": 2314, - "gameId": "TkI4qZxu", - "color": "black", - }, - "horde": - { - "user": { "id": "habitualchess", "name": "HabitualChess" }, - "rating": 1803, - "gameId": "oMofN63H", - "color": "white", - }, - "rapid": - { - "user": { "id": "denpayd", "name": "DenpaYD" }, - "rating": 2289, - "gameId": "IcWOl8ee", - "color": "white", - }, - "atomic": - { - "user": { "id": "meetyourdemise", "name": "MeetYourDemise" }, - "rating": 2210, - "gameId": "tvMxtCMN", - "color": "white", - }, - "crazyhouse": - { - "user": { "id": "mathace", "name": "mathace" }, - "rating": 2397, - "gameId": "i3gTZlUb", - "color": "black", - }, - "chess960": - { - "user": { "id": "voja_7", "name": "voja_7" }, - "rating": 1782, - "gameId": "lrXLcedu", - "color": "white", - }, - "kingOfTheHill": - { - "user": { "id": "nadime", "name": "Nadime" }, - "rating": 1500, - "gameId": "DsQn8aEV", - "color": "white", - }, - "best": - { - "user": { "id": "lekkerkortook", "name": "LekkerKortOok" }, - "rating": 2603, - "gameId": "hTJ4v7Mp", - "color": "black", - }, - } + example: + $ref: "../../examples/tv-getCurrentTvGames.json" diff --git a/doc/specs/tags/tv/api-tv-feed.yaml b/doc/specs/tags/tv/api-tv-feed.yaml index 610ebd2f..efe6ef5f 100644 --- a/doc/specs/tags/tv/api-tv-feed.yaml +++ b/doc/specs/tags/tv/api-tv-feed.yaml @@ -15,7 +15,7 @@ get: schema: $ref: "../../schemas/TvFeed.yaml" examples: - first line: - $ref: "../../examples/tvFeedFirst.yaml" - subsequent lines: - $ref: "../../examples/tvFeedFen.yaml" + new featured game: + $ref: "../../examples/tv-streamCurrentTvGame-newGame.json.yaml" + move: + $ref: "../../examples/tv-streamCurrentTvGame-move.json.yaml" diff --git a/scripts/update-examples/tv.ts b/scripts/update-examples/tv.ts new file mode 100644 index 00000000..8e87e889 --- /dev/null +++ b/scripts/update-examples/tv.ts @@ -0,0 +1,81 @@ +import { example, prodClient, readNdJson, readTextStream } from "./config"; + +example("tv", "getCurrentTvGames", await prodClient().GET("/api/tv/channels")); + +(async () => { + const abortController = new AbortController(); + const signal = abortController.signal; + await prodClient() + .GET("/api/tv/feed", { + parseAs: "stream", + signal, + }) + .then((response) => + readNdJson(response.response, (line: any) => { + if (line.t === "featured") { + example("tv", "streamCurrentTvGame-newGame", line, "json", true); + } else if (line.t === "fen") { + example("tv", "streamCurrentTvGame-move", line, "json", true); + abortController.abort(); + } + }), + ); +})(); + +(async () => { + const pgnLines: string[] = []; + await prodClient() + .GET("/api/tv/{channel}", { + params: { + path: { + channel: "bullet", + }, + }, + headers: { + Accept: "application/x-chess-pgn", + }, + parseAs: "stream", + }) + .then((response) => { + readTextStream(response.response, (text: string) => { + pgnLines.push(text); + if ( + pgnLines.at(-1)?.startsWith("1.") && + pgnLines.filter((line) => line.startsWith("1.")).length === 3 + ) { + example( + "tv", + "getBestOngoingGamesOfTvChannel", + pgnLines.join("\n"), + "pgn", + ); + } + }); + }); +})(); + +(async () => { + await prodClient() + .GET("/api/tv/{channel}", { + params: { + path: { + channel: "bullet", + }, + query: { + nb: 1, + pgnInJson: true, + clocks: true, + opening: true, + }, + }, + headers: { + Accept: "application/x-ndjson", + }, + parseAs: "stream", + }) + .then((response) => { + readNdJson(response.response, (line: any) => { + example("tv", "getBestOngoingGamesOfTvChannel", line); + }); + }); +})();