1

Тема: twitch

Ни кто не занимался получением прямых ссылок на трансляции Twitch?
Например сейчас идет трансляция https://www.twitch.tv/just_ns
Прямая ссылка

https://video-weaver.fra05.hls.ttvnw.net/v1/playlist/CoMFccLjOpi90iuI2Bd7TQX-NqU7BFjE7u72-zbLz_daFq4PVPuy7dVidf0Y6nh3XaL2lEj17rSJdGGpuh_fpjxM0R-S66bZqJbar2TfteAWctKvD9XkOxA-kGSJX9j_2wXljaOPJq-KBs871m9XZ2q_3WPHHUzfdDpJw0zQGSrhaixag-__mQ8PSPx2Zbif-UyEI8CRqtR8GIRA_I8xMAIFtdgBTFlwHJRoblk4Wp0fSEvJI3Mp81z2pG8EnlfaokA-f7R4k_sLdIquQM6nAkRJoHTbN3agGZxTJXR-ek2dL-3nuCNzpcUcxaRkA_yAcsCWnPJhNqglFxfrefHosG0kWQRAXR4sTMI7JjEK4yE7rTyt1D5MQCUYyDep-gELYtdbiZdJn9jGfv-zovoRW2r4ZWq63D1_1sEhy22cXsNrTl1vnJSdm9XyPsqiu7TW-NLdvpmSoAwE1j1P5NZqM7PTtl4VxRFBXdCwPW_JojbWmCXt_sa3aJRQDOr6eK0FlqYdtdJ264URmG8KXK8DYcXN6xQxtk7-K_lr0Or5v6lnZ_hqEaph0I5x-a-pzfBSQ51mWgYOparuWPKPS6DwrMx7n6LrO3fyPETZSqg0KBIJn8sk47KrTl5vneDF44kDqfGMEQPYZhY3Nz1d7m_MWQPiDDk3duOfo6akkWLhLyIGC1LVwh-GJETl8pjoxEdxbgn4rY-2GXLEjKCf2-xCkxZpIkZ7b4doZN9EUWc3p5BqSWEqWvL4ogxUSQLCn9iIxjp2WZ59r7SVdS8uDpx5Z14KCakBq3bcctfXFwdY2dr-m35pTmIYT5MbUHwMwWTab4JQ2qTOY_EAn1WPofoFBrhB0UT7zRoM0Wb2sTnYLt6o-oXcIAEqCWV1LXdlc3QtMjC9Aw.m3u8

Но, что-то пока не вижу, как эта ссылка появляется.

2

Re: twitch

Поиск в Интернете дает такой скрипт (тут нужен какой-то ключ)

<?php
ob_start();
$clientId = ""; //Set your client key

// cURL function
function Curl($url, $header){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
    curl_setopt($ch, CURLOPT_TIMEOUT, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    $response = curl_exec($ch);
    curl_close ($ch);
    return $response;
}

// Check for get parameter 'channel' to exist and to be valid
if (isset($_GET['channel']) && preg_match("/^[a-zA-Z0-9_]{4,25}$/u", $_GET['channel'])){
    // Lets request to twitch tv the access token
    $response = Curl("https://api.twitch.tv/api/channels/" . $_GET['channel'] . "/access_token/",
                [
                    "Client-ID: $clientId",
                    "Host: api.twitch.tv",
                    "User-Agent: Mozilla/5.0 (Windows NT 6.3; rv:43.0) Gecko/20100101 Firefox/43.0 Seamonkey/2.40",
                    "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
                ]
            );
    // If the reply contains token
    if(strstr($response, "token")){
        $json = json_decode($response, true); // Decode the JSON array
        header('Location: http://usher.twitch.tv/api/channel/hls/' . $_GET['channel'] . '.m3u8?player=twitchweb&token=' . rawurlencode($json['token']) . '&sig=' . $json['sig']);
    }else{
        // Print error
        echo "Couldn't get the token";
    }
}else{
    // Print error
    echo "Channel name not provided or invalid";
}
?>

3

Re: twitch

Посмотри это не оно?

https://twitchtokengenerator.com/

4

Re: twitch

Да это позволяет получить ключ, но, как я понимаю, он нужен, чтобы на своем канале вещать. Для просмотра чужих должно быть что-то по проще, ведь в браузере мы смотрим без всяких ключей,  но пока я не вижу, как прямая ссылка извлекается.

5

Re: twitch

Вот еще посмотри https://untwitch.com/?url=https%3A%2F%2 … %2Fskrolya может поможет

6

Re: twitch

foks5050 пишет:

Вот еще посмотри https://untwitch.com/?url=https%3A%2F%2 … %2Fskrolya может поможет

Там post запрос, где

referer: https://untwitch.com/?url=https%3A%2F%2Fwww.twitch.tv%2Fskrolya

указывает, что надо получить. В результате генерирует страницу с прямыми ссылками в разных форматах

<div class="col-12 col-md-8">
                                <h5>Available clip download formats</h5><a class="btn btn-primary btn-lg mb-1" href="https://video-weaver.mia05.hls.ttvnw.net/v1/playlist/CqIE-dE05GC7kaQpcb-wWN-QCC8lxlF0Abrk7hbqkg0IeJc3xJ0DvELyGWzqMFHOAL-ohobde6KYurLA2vlEkN6wSGE_NZwdOMKGqiaBtjoGogKTChQ9pe96pV0OvNQd2-GIcOh4XjVFvdhBgpSAUOwACwMVftEdosW_6Bxh_l5TOdw9LggfGNZRuxbbGRl-3Q-3tCtfP1wiBHU76_0jGf4gBdi0mAtSJiwiphAvTkbF-Mf1qRt9K6FhRu24wqkehCiPaFpen8j7bpgOVCqVf7Uw8lcU9Cdoptv6O_ewIkgawkFhydVsp3OyCnIlRZBsu9S_oL1_5tcW1OdHXImXQ2q0maq36qgt8meFwdICJqwRma0t6VJG6-E2BfK1G9IYU8EhWK24Ad41XKCnvmTvGRLcSYeybQ46wLAfl5-u6ZYEayvvGM0ZbHkIXglfM05CJMmS27ugW9rOXiI7yx3WRs5gLkq9Dt50lXAVGvGM9OU1X_O9JhnplN-ll70z7xwxbTRJ65QbAbgnJqcjTz2_wRkayJ-t8ZfwPe8NF32uVi7uaCv2M4NiCeNHXjR4kAgcSAk6vdvLMEPYbQFVG42XlRr5CZHaKqszv5cw_tt791tP2fdzKKuhGzpDyIJE51FPZDiVBTAEVRGQOWiIvocP3KdnyaAhBtZYHDcZaxtzEx8NbtOc0OR8Gk3eeoel1FilIEeRCw4t1JrQhBmu7poGxAzG67sNGgzvXPaGoUIsLzUops4gASoJZXUtd2VzdC0yMMED.m3u8">audio_only - audio only ~ 0.0 kB</a> <a class="btn btn-primary btn-lg mb-1" href="https://video-weaver.mia05.hls.ttvnw.net/v1/playlist/CqIE4eepsxc3KKJ3-eq8ROSNHjDlw2239HnZqzwbScNCWiGRc2bqWfLd5w_CHJmpd-Rzo9OL_0UxDzF0J-HFQuigUipUIaKah3o-JUS7wR3RIucCKNIhlFKZfEAOwyFrK5VNe7Y6E0QyNKAGcQKiGESZjuWRo9ANMN6VqSstu08t_nE7wysRHIXn9jPS0pROO4vy4di1gcwz9_5bL_ldmbK5S-AoNO3X-Ws4SWT1Z56XQQPxI0L6qf1ViZi-tXdxvCtAE9WqJ_ezGp1dK3Gh-eDGAIJ9C3FzwirNv2tMOWBX6MOOC8bj1sTr5aWWnbdOy0LzYgG10MJMgTtKdV6CEiylWbTtegxLfqkW7vEmQn22E3rMvnBUjZbzw9F6mHvkicBEJqD-eyG-E98v6E5rOGtp9bZ9FpUM285QUqDJSj4I3eakExHQQRPs2zZ1vpvM_v2qS-bEey1XQGB0z6azFMK2ozRBn5GuF7juZtX9YBv6yhR1ySmT9rPiqGwtmCyHWErETSpGSbIc8eviDJNjDuh1nYAWqcKqeW0ul5SiNJPEk5r-1f3anUfGPARl_WKRobdSoaXsgC_unUXwblkSBD6VEToFRCoHu9ffjeWhuCHfaEbCvGlVqxsCjTXRCVnzSkr0vxxKZl6QSW8OkR9Llioa__cgyLQR0-RcTWdrnIDjrlx5H_NXDCH0knI8AMIGj5w9iOZUMNr8vUxLM2Fp9XJ4IJHgGgw3seMOxgDwvyfTNyIgASoJZXUtd2VzdC0yMMED.m3u8">720p60__source_ - 1280x720 ~ 0.0 kB</a> <a class="btn btn-primary btn-lg mb-1" href="https://video-weaver.mia05.hls.ttvnw.net/v1/playlist/CqAEhmEWZTjwSsqEgZUimNtweNHifMhvx3KZ1GOWzvKgo75d9ISaqhHS3Evf78ze5ylozbscExEioXXALL5-rZplhZRA1BfhzbWF8lqE9JN6DtK35ZwGAGBWVddrX3iZ2M67GvTvzoD41T8BMvNzHcjBsut0GOLOaYDLb8Ua2zE5Zfu-PIYzKxZee7YgQx_Ew65X9wWbtel8iglzcwg6Zj_l1xcrbN5mjop_xyRWEsfqUIjah6Wat0FagJutgKX_IPQW1qIacGVu21rwucWWP5QU1bd-R1mi_gKRiiZEnKxniVErq7dOCtV7czwSL5fED8Ujm09JPbLb-RoswkqlKAbEnVnRi3ArQMhgzChmwRVFtbPm6u8e_HjyfgYw-bIZeGMJYQoMWspzVRdAVxZeMIc2kZTdyB2AUSgwSFqRJgcq7mJOOViPcWNyHNimG7ByLqq8isLvyCBNYqQocib3dykyOFKvZX1FtjH-TjQ72YARpDZaV3_2OEmmQRQDu6nOcDYOAZ_NiqgAO98AbTRiXaRgPDJmgZA65YllGjzEYjjCtloirrNbeVurW3ATxpxhMysjSY83WgmokgUDRcZbJmiEVzsfPxOWuC4PYCWkXS3OGmFL2ifjfiPUoka0Nm2uptTML-v4pDSkAngcTZkkYNtYceT6b2VTtm90l5Sa0DqTIkWMwvrOrjBA1ltTaqnS2KgRM7fUx9WXaj6TeWsfabqaKRoM8Jn-P4lpxTmYUPypIAEqCWV1LXdlc3QtMjDBAw.m3u8">720p60 - 1280x720 ~ 0.0 kB</a> <a class="btn btn-primary btn-lg mb-1" href="https://video-weaver.mia05.hls.ttvnw.net/v1/playlist/CqAEXKkS3ThUm9gFGPSNltN9q-tO00c9uWQyXIvz3pKo6ObrlIUVZ4wHnTB-fLeLEDoUzzQJbqKoL-iuewLhCtcqn7FIuNdguozVdOsz55dJ0ldAQE1MZmVALdL47RgipykgLp1kf9oogI5fqXsiwRQ-eCgxPzQ191Nlk9xiHQBWZNlBw98stGKcAxw8nr7Fb6UqclPomMJ7FmaGPgHLVpHjKi-iiS6NTnz2d9I7MoLCYMbbLNa-I2GuFiy3XghtxecTJyVo0ZO-bNe-HEMag-oBAw7L2tt1VT0sI4L7kSXeRM9lz6Fhnkn2uw3SpoD0lkB8d2QCbsFMYzPozgSB1pd84hcqdZuSi5KaOvjTx72p3wflNU5fdvRQn8Hst2BsCXbanFAN6fAWvwL4gjzVNNQTA1SErVTLQSkaiU55ikanrvibsYHmnKoWBkkM0t9DdlSdltvb8NOj3LvkgCufsxToxRdK07vjnvLQ0H7su_OWihP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nkab5YY0ddW_8xoMwdBcS4JzPKDmOsrPIAEqCWV1LXdlc3QtMjDBAw.m3u8">480p - 852x480 ~ 0.0 kB</a> <a class="btn btn-primary btn-lg mb-1" href="https://video-weaver.mia05.hls.ttvnw.net/v1/playlist/CqAETHiOBi9Jz0KgSEva6GzDFLAAwVhuWJfV3Er1VTnia--GePzPzQ9jqpA3-ANPSmUHaXNhaK7JpFCb55XBceWR2A2BUvgPDJ2zpHGPhwxvhedl28w5Lkm2XhJGMdwKJfRFX8n1RfwhZLu-o1Vh03t8CQF6AOPWi8DACz0g7BuFvPbj9bTA3ilqYJOwwlXIGpW7mH72w97Wmurm8uQaZV9xKH_Y8OJmZtz1Z3I0rzwlaiSwuKh-bX4oRjMSPDuL1l49-lC3pWoFhO-ayNc5jJ-L7Fb6qdKPkyfVT37s07EKFLn6sU6Ih1hVhJnDzxffjCF3iXsKSEc-VWPNdf0FpIVY8Uz1Y3iOWPDk_pwX9akspCcI36Zs04nvrKjqegBtnnkq_WmdM9Pdpt8obif-NiVbBZx8-g7ZWfvYKhRr56_tV0RbwaMN9cAVzHwnOOrO079of00AUj87UL6tOEKruGQ-431hZ3RZFZB7BR0q3OmFA3nAH3bkH4SOPPjA_DKkQHbzQQOoKCfq2TuB-v842AidobLNiKutRxGENhOcoYLxwUgyT3zDS91b5844jll9ZnAkJ-45MLqEeyiq0BM8BBjo54_AP5IxyamTA0V0PGvg2Y3zVhgtpyVdatEfnG8zPwVxPo0ui7hWJUKUZO9zghXODG_TT7DEb8MgUAIh07RwiKOMCRt-NWzKCauspPcvzvIK-0BMW1mAJol2ZpzagiJwWBoM4z0DPB0_2kHN9UtxIAEqCWV1LXdlc3QtMjDBAw.m3u8">360p - 640x360 ~ 0.0 kB</a> <a class="btn btn-primary btn-lg mb-1" href="https://video-weaver.mia05.hls.ttvnw.net/v1/playlist/CqAEPIJuYLVbhVgv5o9-jw2qEwnJsicOYJ3osmIHLX_udEC6p2HbyTi5IR942q-eLfsUM1gdsjeCMqrMiwKrtpetrA39RtZz8ePSk8RNtRq6jpq1tHuB3yhp8-q4_06_QMVM1NhQvq2n6a4iWqfT-WnXtBSzivB_p8GueQ1Iou8wkq-zWyXfPDG_gM2WUoU3Lwx8u40fhBpS8X7hiL81C-fanWXpASerzRHEISPoFswgxj9EW3pq6vli6OSfQ6F726d9G0AGE7VTitQWyFkr4oWj_l9eiBz1Rv809dTIMs95Vx7kAAI16OiSNGwsoYlbc5XjxgE51aiWez2-J3hQkBlviLsR9pzA6wx2UlGVsqSZjQlM5mi_HIH_X52Y4C4omF7ldzlJcj6c9nmXT3vuMxf-bF2Fb93sqxtDWU_AKSsGcle79avqmyac1km0YnekzeOyoi_5kUnyGZKn3zqUkAcvf1npBz1w-zT4yXXABFSUE5FdCWzzlG-jq3VjCBgr1NwMcFg8Kqc-ht8ds7QhBA3iIN7tOdyfNuhmSqBLNAABTFcEMGcC1NdJdHdAOQXObcxy7jG6Il7sNi7Ko7uuQR4wM2qsvFf-uG8Ya30xT8a5UkMgjiRWd1n6lJ2h1_YpuoCU1vvzfoKEZpufEn0n4en-AsFW6-t1HpjjphqlYB_CWDzZcfNTs_x6NhePe_4bT863jwPfRBeNCpdFlARms_cZeRoMGBUgj0MikwD3XEEXIAEqCWV1LXdlc3QtMjDBAw.m3u8">160p - 284x160 ~ 0.0 kB</a> 
                                <br><button id="mp3button" class="btn btn-outline-success opacity50">convert clip to mp3</button><form id="form3" method="POST" action="/" class="d-inline opacity50">
                                        <input id="dlURL" name="url" type="hidden" value="https://www.twitch.tv/kamui"><input id="newinfo" name="newinfo" type="hidden" value="1650268315">
                                        <div><div class="grecaptcha-badge" data-style="none" style="width: 256px; height: 60px; position: fixed; visibility: hidden;"><div class="grecaptcha-logo"><iframe title="reCAPTCHA" src="https://www.google.com/recaptcha/api2/anchor?ar=1&amp;k=6Lem16sZAAAAALBFSPRbts6QawPUTh7pZgaoXXQn&amp;co=aHR0cHM6Ly91bnR3aXRjaC5jb206NDQz&amp;hl=ru&amp;v=6pQzWaE1NP-gB4FrqRViKjM-&amp;size=invisible&amp;sa=submit&amp;cb=3vydwt61227e" width="256" height="60" role="presentation" name="a-xixwaygli7bs" frameborder="0" scrolling="no" sandbox="allow-forms allow-popups allow-same-origin allow-scripts allow-top-navigation allow-modals allow-popups-to-escape-sandbox"></iframe></div><div class="grecaptcha-error"></div><textarea id="g-recaptcha-response-1" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px; resize: none; display: none;"></textarea></div><iframe style="display: none;"></iframe></div><button class="btn btn-outline-secondary g-recaptcha" data-sitekey="6Lem16sZAAAAALBFSPRbts6QawPUTh7pZgaoXXQn" data-callback="onSubmit3" data-action="submit" type="submit">refresh video info</button>
                                    </form><button id="newbutton" class="btn btn-outline-secondary opacity50" title="download another twitch clip">download new clip</button><div id="dlmp3div" class="d-none mt-1"><script>var vidURL= 'https://www.twitch.tv/kamui';</script></div><br><br><p class="small">** If info is wrong, duration or title are incorrect, please, consider refreshing video info. Doing so, please, remember: if video has been removed
                                from twitch, refreshing its info will not improve things, but will probably disable video download in its current state. With removed videos we can only 
                                rely on data received earlier and remembered for as long as we can keep it in memory... But if video has never been untwitched prior to being removed or 
                                hidden, - we cannot help untwitch it now.</p>
                           </div>

Как эти ссылки получаются, мы не видим. На практике можно использовать, но хотелось бы напрямую, самому получать прямые ссылки, а не с использованием чужого ресурса.