Dividing the problem into three steps, it can be said that Voce needs to use only the following PHP functions:
Step 1: Getting the . m3u using file_get_contents
Step 2: Capturing content using preg_match
Step 3: Saving the information in . txt using file_put_contents
The code below exemplifies how they can be used:
<?php
// $conteudo = file_get_contents("http://servidor.com:8000/get.php?username=NOME&password=SENHA&type=m3u_plus");
$conteudo = '#EXTINF:-1 tvg-id="" tvg-name="Bruce Lee - A Fúria do Dragão (1972)" tvg-logo="https://i2.wp.com/asiamundi.com.br/wp-content/uploads/2015/02/A-F%C3%BAria-do-Drag%C3%A3o-1972.jpg?fit=674%2C1000&ssl=1" group-title="Ação & Aventura",Bruce Lee - A Fúria do Dragão (1972) http://xsrv.me:8080/movie/claudio/claudio/64869.mp4';
preg_match('/tvg-name="(.*?)"/', $conteudo, $resultadosDoNome);
preg_match('/tvg-logo="(.*?)"/', $conteudo, $resultadosDaImagem);
preg_match('/\s(http:|https:)+[^\s]+[\w]/', $conteudo, $resultadosDaUrl);
$nomeDoArquivo = 'informacoes.txt';
$conteudoDoArquivo = "Imagem = " . $resultadosDaImagem[1] . PHP_EOL
. "Nome = " . $resultadosDoNome[1] . PHP_EOL
. "URL = " . trim($resultadosDaUrl[0]) . PHP_EOL
. "Categoria = 0" . PHP_EOL
. "Legenda = 0" . PHP_EOL
. "Qualidade = 0" . PHP_EOL
. "Infor = 0" . PHP_EOL
. "Infor2 = 0";
file_put_contents($nomeDoArquivo, $conteudoDoArquivo);
This code would generate a file called "informacoes.txt" with the following content:
Imagem = https://i2.wp.com/asiamundi.com.br/wp-content/uploads/2015/02/A-F%C3%BAria-do-Drag%C3%A3o-1972.jpg?fit=674%2C1000&ssl=1
Nome = Bruce Lee - A Fúria do Dragão (1972)
URL = http://xsrv.me:8080/movie/claudio/claudio/64869.mp4
Categoria = 0
Legenda = 0
Qualidade = 0
Infor = 0
Infor2 = 0
And to check if the regular expressions are correctly capturing the text you want, Voce can use the Regexr.
I did it here and it worked super well, but it only returned me a value. How and what I do for it return me various values. ?
– Victor Ken
Do you want to write information from different movies in the same file? If yes, just have the list of all URL’s. m3u and go, item by item, doing these steps above, using https://www.php.net/manual/en/function.file-get-contents.php instead of using a static string. Here’s the documentation on how to browse a list using For: https://www.php.net/manual/en/control-structures.for.php
– Felladrin