61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
<?php
|
|
|
|
require_once '../vendor/autoload.php';
|
|
|
|
use App\Torrentio\Result\ResultFactory;
|
|
|
|
$realDebridKey = "";
|
|
$tasks = [];
|
|
$results = [];
|
|
$start = microtime(true);
|
|
for ($i = 1; $i <= 20; $i++) {
|
|
$tasks[] = \Async\spawn(function () use ($i, &$results, &$realDebridKey) {
|
|
$baseUrl = "https://torrentio.strem.fun/providers%253Dyts%252Ceztv%252Crarbg%252C1337x%252Cthepiratebay%252Ckickasstorrents%252Ctorrentgalaxy%252Cmagnetdl%252Chorriblesubs%252Cnyaasi%7Csort%253Dqualitysize%7Cqualityfilter%253D480p%252Cscr%252Ccam%7Crealdebrid={$realDebridKey}/stream/movie/tt0412142:1:$i.json";
|
|
$options = \json_decode(file_get_contents($baseUrl), true);
|
|
|
|
foreach ($options['streams'] as $stream) {
|
|
if (!str_starts_with($stream['url'], "https")) {
|
|
continue;
|
|
}
|
|
|
|
if (
|
|
array_key_exists('behaviorHints', $stream) &&
|
|
array_key_exists('bingeGroup', $stream['behaviorHints'])
|
|
) {
|
|
$bingeGroup = $stream['behaviorHints']['bingeGroup'];
|
|
} else {
|
|
$bingeGroup = '-';
|
|
}
|
|
|
|
$result = ResultFactory::map(
|
|
$stream['url'],
|
|
$stream['title'],
|
|
$bingeGroup
|
|
);
|
|
|
|
$results[] = $result;
|
|
}
|
|
});
|
|
}
|
|
\Async\awaitAll($tasks);
|
|
$end = microtime(true) - $start;
|
|
dd($end, $results);
|
|
|
|
//
|
|
//
|
|
//// Spawn multiple concurrent coroutines
|
|
//Async\spawn(function() {
|
|
// echo "Starting coroutine 1\n";
|
|
// sleep(2); // Non-blocking in async context
|
|
// echo "Coroutine 1 completed\n";
|
|
//});
|
|
//
|
|
//Async\spawn(function() {
|
|
// echo "Starting coroutine 2\n";
|
|
// sleep(1); // Non-blocking in async context
|
|
// echo "Coroutine 2 completed\n";
|
|
//});
|
|
//
|
|
//echo "All coroutines started\n";
|
|
|