1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-06 03:50:04 +02:00
Daniel Neto 2024-12-16 10:09:52 -03:00
parent 5028204f33
commit 8a78d50550
6 changed files with 125 additions and 116 deletions

View file

@ -17,120 +17,11 @@ $audioFile = 'assets/testMP3.mp3';
$spritFile = 'assets/thumbsSprit.jpg';
$subtitleSRT = 'assets/subtitle.srt';
$subtitleVTT = 'assets/subtitle.vtt';
$totalVideos = 50;
$totalPlaylists = 60;
$totalVideos = 400;
$totalPlaylists = 3;
$totalVideosPerPlaylist = 30;
$totalCategories = 10;
$totalSubCategories = 5;
/*
for ($i = 0; $i < $totalCategories; $i++) {
$date = date('Y/m/d H:i:s');
$catTitle = "$i Auto Category $date";
$catCleanTitle = "{$i}-Auto-Category-".date('YmdHis');
$cat = new Category(0);
$cat->setName($catTitle);
$cat->setClean_name($catCleanTitle);
$parentId = $cat->save(true);
echo "pupulating [$totalVideos/$i] category saved [id=$parentId]" . PHP_EOL;
for ($j = 0; $j < $totalSubCategories; $j++) {
$catTitle = "$i Auto SubCategory $date";
$catCleanTitle = "{$i}-Auto-SubCategory-".date('YmdHis');
$cat = new Category(0);
$cat->setName($catTitle);
$cat->setClean_name($catCleanTitle);
$cat->setParentId($parentId);
$id = $cat->save(true);
echo "pupulating [$totalVideos/$i] subcategory saved [id=$id]" . PHP_EOL;
}
}
echo "pupulating ... ";
$cats = Category::getAllCategories();
echo "pupulating ... ".__LINE__;
$videos = Video::getAllVideosLight('');
echo "pupulating ... ".__LINE__;
$total = count($videos);
echo "[{$total}/{$key}] pupulating video start ";
foreach ($videos as $key => $value) {
$video = new Video('', '', $value['id']);
$index = array_rand($cats);
$video->setCategories_id($cats[$index]['id']);
$id = $video->save(false, true);
echo "[{$total}/{$key}] pupulating video category saved [id=$id catId={$cats[$index]['id']}]" . PHP_EOL;
}
exit;
$newVideosIds = array();
// create videos
for ($i = 0; $i < $totalVideos; $i++) {
$date = date('Y/m/d H:i:s');
$title = "[$i] Auto {$date}";
$filename = "testvideo{$i}_" . uniqid();
$video = new Video($title, $filename);
$video->setDuration("00:00:45");
$video->setType('video');
$video->setDuration_in_seconds(45);
$video->setDescription($title);
$video->setUsers_id(1);
$index = array_rand($cats);
$video->setCategories_id($cats[$index]['id']);
$video->setStatus(Video::$statusActive);
$video->setFilesize(2858747);
$video->setLikes(rand(0, 1000));
$video->setDislikes(rand(0, 1000));
$path = Video::getPathToFile($filename, true);
$mp4Filename = "{$path}_480.mp4";
$mp3Filename = "{$path}.mp3";
$jpgFilename = "{$path}.jpg";
$spritFilename = "{$path}_thumbsSprit.jpg";
$subtitleSRTFilename = "{$path}.srt";
$subtitleVTTFilename = "{$path}.vtt";
createImageWithText("[$i] Auto Pupulated", $date, $jpgFilename);
copy($videoFile, $mp4Filename);
copy($audioFile, $mp3Filename);
copy($spritFile, $spritFilename);
copy($subtitleSRT, $subtitleSRTFilename);
copy($subtitleVTT, $subtitleVTTFilename);
$id = $video->save(false, true);
$newVideosIds[] = $id;
echo "pupulating [$totalVideos/$i] Video saved [id=$id]" . PHP_EOL;
}
AVideoPlugin::loadPlugin('PlayLists');
if(empty($newVideosIds)){
$global['rowCount'] = 99999;
$videos = Video::getAllVideosLight("", false, true, false);
$newVideosIds = array();
foreach ($videos as $key => $video) {
$newVideosIds[] = $video['id'];
}
}
for ($i = 0; $i < $totalPlaylists; $i++) {
$name = "Playlist test autogenerated $i " . date('Y/m/d H:i:s');
$playlist = new PlayList(0);
$playlist->setName($name);
$playlist->setStatus('a');
$id = $playlist->save();
echo "pupulating [$totalPlaylists/$i] Playlist saved [id=$id]" . PHP_EOL;
for ($j = 0; $j < $totalVideosPerPlaylist; $j++) {
$playList = new PlayList($id);
$playList->addVideo($newVideosIds[array_rand($newVideosIds)], 1);
echo "pupulating [$totalVideosPerPlaylist/$j] Video added in a Playlist" . PHP_EOL;
}
}
die();
function createImageWithText($text1, $text2, $filename)
{
@ -184,8 +75,116 @@ function createImageWithText($text1, $text2, $filename)
// Free up memory
imagedestroy($image);
}
*/
/*
for ($i = 0; $i < $totalCategories; $i++) {
$date = date('Y/m/d H:i:s');
$catTitle = "$i Auto Category $date";
$catCleanTitle = "{$i}-Auto-Category-".date('YmdHis');
$cat = new Category(0);
$cat->setName($catTitle);
$cat->setClean_name($catCleanTitle);
$parentId = $cat->save(true);
echo "pupulating [$totalVideos/$i] category saved [id=$parentId]" . PHP_EOL;
for ($j = 0; $j < $totalSubCategories; $j++) {
$catTitle = "$i Auto SubCategory $date";
$catCleanTitle = "{$i}-Auto-SubCategory-".date('YmdHis');
$cat = new Category(0);
$cat->setName($catTitle);
$cat->setClean_name($catCleanTitle);
$cat->setParentId($parentId);
$id = $cat->save(true);
echo "pupulating [$totalVideos/$i] subcategory saved [id=$id]" . PHP_EOL;
}
}
*/
echo "pupulating ... ";
$cats = Category::getAllCategories();
echo "pupulating ... ".__LINE__;
$videos = Video::getAllVideosLight('');
echo "pupulating ... ".__LINE__;
$total = count($videos);
echo "[{$total}/{$key}] pupulating video start ";
foreach ($videos as $key => $value) {
$video = new Video('', '', $value['id']);
$index = array_rand($cats);
$video->setCategories_id($cats[$index]['id']);
$id = $video->save(false, true);
echo "[{$total}/{$key}] pupulating video category saved [id=$id catId={$cats[$index]['id']}]" . PHP_EOL;
}
$newVideosIds = array();
// create videos
for ($i = 0; $i < $totalVideos; $i++) {
$date = date('Y/m/d H:i:s');
$title = "[$i] Auto {$date}";
$filename = "testvideo{$i}_" . uniqid();
$video = new Video($title, $filename);
$video->setDuration("00:00:45");
$video->setType('video');
$video->setDuration_in_seconds(45);
$video->setDescription($title);
$video->setUsers_id(1);
$index = array_rand($cats);
$video->setCategories_id($cats[$index]['id']);
$video->setStatus(Video::$statusActive);
$video->setFilesize(2858747);
$video->setLikes(rand(0, 1000));
$video->setDislikes(rand(0, 1000));
$path = Video::getPathToFile($filename, true);
$mp4Filename = "{$path}_480.mp4";
$mp3Filename = "{$path}.mp3";
$jpgFilename = "{$path}.jpg";
$spritFilename = "{$path}_thumbsSprit.jpg";
$subtitleSRTFilename = "{$path}.srt";
$subtitleVTTFilename = "{$path}.vtt";
createImageWithText("[$i] Auto Pupulated", $date, $jpgFilename);
copy($videoFile, $mp4Filename);
copy($audioFile, $mp3Filename);
copy($spritFile, $spritFilename);
copy($subtitleSRT, $subtitleSRTFilename);
copy($subtitleVTT, $subtitleVTTFilename);
$id = $video->save(false, true);
$newVideosIds[] = $id;
echo "pupulating [$totalVideos/$i] Video saved [id=$id]" . PHP_EOL;
}
/*
AVideoPlugin::loadPlugin('PlayLists');
if(empty($newVideosIds)){
$global['rowCount'] = 99999;
$videos = Video::getAllVideosLight("", false, true, false);
$newVideosIds = array();
foreach ($videos as $key => $video) {
$newVideosIds[] = $video['id'];
}
}
for ($i = 0; $i < $totalPlaylists; $i++) {
$name = "Playlist test autogenerated $i " . date('Y/m/d H:i:s');
$playlist = new PlayList(0);
$playlist->setName($name);
$playlist->setStatus('a');
$id = $playlist->save();
echo "pupulating [$totalPlaylists/$i] Playlist saved [id=$id]" . PHP_EOL;
for ($j = 0; $j < $totalVideosPerPlaylist; $j++) {
$playList = new PlayList($id);
$playList->addVideo($newVideosIds[array_rand($newVideosIds)], 1);
echo "pupulating [$totalVideosPerPlaylist/$j] Video added in a Playlist" . PHP_EOL;
}
}
//die();
AVideoPlugin::loadPlugin('PlayLists');
$pls = PlayList::getAll();
$videos = Video::getAllVideosLight('');