EditVideoMp4.php
2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* @remark :
* @name :EditVideoMp4.php
* @author :lyh
* @method :post
* @time :2024/4/16 9:44
*/
namespace App\Console\Commands\Test;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class EditVideoMp4 extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'edit_video';
/**
* The console command description.
*
* @var string
*/
protected $description = 'edit_mp4';
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>1]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->copyTable();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :获取video的src
* @name :getVideoSrc
* @author :lyh
* @method :post
* @time :2024/4/16 9:46
*/
public function getVideoSrc($html){
$videoArr = [];
$html = file_get_contents($html);
$pattern = '/<video.*?src=[\'"]([^\'"]+)[\'"].*?>/i';
preg_match_all($pattern, $html, $matches);
$srcLinks = $matches[1];
foreach ($srcLinks as $link) {
$videoArr[] = $link;
}
return $videoArr;
}
/**
* @remark :复制表
* @name :copyTable
* @author :lyh
* @method :post
* @time :2024/4/16 9:51
*/
public function copyTable(){
// 原始表名和新表名
$originalTableName = "gl_web_template";
$newTableName = "gl_web_template_copy";
// 检查原始表是否存在
$result = DB::connection('custom_mysql')->query("SHOW TABLES LIKE '{$originalTableName}'");
if ($result->num_rows == 1) {
// 复制原始表结构到新表
DB::connection('custom_mysql')->query("CREATE TABLE {$newTableName} LIKE {$originalTableName}");
// 复制原始表数据到新表
DB::connection('custom_mysql')->query("INSERT INTO {$newTableName} SELECT * FROM {$originalTableName}");
echo "表复制成功!";
} else {
echo "原始表不存在!";
}
DB::connection('custom_mysql')->close();
}
}