File tree Expand file tree Collapse file tree 5 files changed +90
-0
lines changed Expand file tree Collapse file tree 5 files changed +90
-0
lines changed Original file line number Diff line number Diff line change 3434 },
3535 "require-dev" : {
3636 "mrmysql/youtube-transcript" : " ^0.0.5" ,
37+ "nyholm/psr7" : " ^1.8" ,
38+ "php-http/discovery" : " ^1.19" ,
3739 "phpstan/phpstan" : " ^2.0" ,
3840 "phpstan/phpstan-strict-rules" : " ^2.0" ,
3941 "phpunit/phpunit" : " ^11.5.13" ,
Original file line number Diff line number Diff line change 1+ {
2+ "playabilityStatus" : {
3+ "status" : " OK"
4+ },
5+ "captions" : {
6+ "playerCaptionsTracklistRenderer" : {
7+ "captionTracks" : [
8+ {
9+ "baseUrl" : " https://www.youtube.com/api/timedtext?v=dQw4w9WgXcQ" ,
10+ "name" : {
11+ "runs" : [
12+ {
13+ "text" : " English"
14+ }
15+ ]
16+ },
17+ "languageCode" : " en" ,
18+ "isTranslatable" : true
19+ }
20+ ],
21+ "translationLanguages" : [
22+ {
23+ "languageName" : {
24+ "runs" : [
25+ {
26+ "text" : " Spanish"
27+ }
28+ ]
29+ },
30+ "languageCode" : " es"
31+ }
32+ ]
33+ }
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <transcript >
3+ <text start =" 0.0" dur =" 2.5" >Hello and welcome to this video</text >
4+ <text start =" 2.5" dur =" 3.0" >Today we will learn about PHP</text >
5+ <text start =" 5.5" dur =" 2.0" >Thank you for watching</text >
6+ </transcript >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < script >
5+ var ytcfg = { "INNERTUBE_API_KEY" : "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8" } ;
6+ </ script >
7+ </ head >
8+ < body >
9+ </ body >
10+ </ html >
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Symfony package.
5+ *
6+ * (c) Fabien Potencier <[email protected] > 7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Symfony \AI \Agent \Tests \Toolbox \Tool ;
13+
14+ use PHPUnit \Framework \TestCase ;
15+ use Symfony \AI \Agent \Toolbox \Tool \YouTubeTranscriber ;
16+ use Symfony \Component \HttpClient \MockHttpClient ;
17+ use Symfony \Component \HttpClient \Response \MockResponse ;
18+
19+ final class YouTubeTranscriberTest extends TestCase
20+ {
21+ public function testInvoke ()
22+ {
23+ $ httpClient = new MockHttpClient ([
24+ MockResponse::fromFile (__DIR__ .'/../../Fixtures/Tool/youtube-video-page.html ' ),
25+ MockResponse::fromFile (__DIR__ .'/../../Fixtures/Tool/youtube-captions.json ' ),
26+ MockResponse::fromFile (__DIR__ .'/../../Fixtures/Tool/youtube-transcript.xml ' ),
27+ ]);
28+
29+ $ transcriber = new YouTubeTranscriber ($ httpClient );
30+
31+ $ result = $ transcriber ('dQw4w9WgXcQ ' );
32+
33+ $ this ->assertStringContainsString ('Hello and welcome to this video ' , $ result );
34+ $ this ->assertStringContainsString ('Today we will learn about PHP ' , $ result );
35+ $ this ->assertStringContainsString ('Thank you for watching ' , $ result );
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments