Skip to content

Instantly share code, notes, and snippets.

@lucasgautheron
Created January 3, 2019 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasgautheron/4a55e21fb0d7dcb05e076889599a740b to your computer and use it in GitHub Desktop.
Save lucasgautheron/4a55e21fb0d7dcb05e076889599a740b to your computer and use it in GitHub Desktop.
<?php
require 'params.php';
$presets = list_presets();
if (!empty($_POST['script']) && !empty($_POST['url'])) {
$url = $_POST['url'];
$id = basename(youtube_url_to_id($url));
$url = escapeshellarg($url);
file_put_contents("data/{$id}_script.txt", $_POST['script']);
exec('python3 -m aeneas.tools.execute_task ' . $url . ' data/' . $id . '_script.txt "task_language=fr|is_text_type=plain|os_task_file_format=srt" data/' . $id . '_script.srt -y');
//echo "python captions.py --videoid='$id' --name='auto' --file='data/{$id}_script.txt' --language='fr-FR' --action='action'";
header('Content-type: text/srt');
header('Content-Disposition: attachment; filename="' . $id . '_script.srt"');
readfile("data/{$id}_script.srt");
die();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="dist/css/bootstrap-colorpicker.min.css" rel="stylesheet">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="dist/js/bootstrap-colorpicker.js"></script>
</head>
<body>
<div class="container">
<h2>Script -> .srt</h2>
<div>
<form action="alignment.php" method="POST">
<p><input type="text" name="url" value="https://www.youtube.com/?v=" size="40" /> URL de la vidéo YouTube</p>
<p>Script (1 ligne par panneau)</p>
<p>
<textarea name="script" cols="80" rows="20">
</textarea>
</p>
<input type="submit" value="Générer un fichier .srt" />
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment