-
Notifications
You must be signed in to change notification settings - Fork 0
/
mid3TagMp3Transfer.php
213 lines (191 loc) · 7.17 KB
/
mid3TagMp3Transfer.php
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Copy & Edit of ID3 tags</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta property="og:url" content="https://smolka.lima-city.de/">
<meta name="author" content="Jürgen Smolka">
<script type="text/javascript" src="dhtml.js"></script>
<!-- JS202106 -->
</head>
<?php
$GUI = "ID3-tags-powered-by:ID3 by github.com/ttimer/GUI-for-mID3v2";
$GU2 = "ID3 by github.com/ttimer/GUIx-for-mID3v2";
$LNK = "https://github.com/ttimer/GUI-for-mID3v2/";
// Um ein Bild-Dummy zu erstellen, kann von einer
// MP3-Datei eine ID3-Tags-Kopie gezogen werden.
// (abc01.mp3 ==> dummy:X01-00.mp3 ==> abc00.mp3)
$quelle = "";
$ziel = "";
$noquelle = "";
$noziel = "";
$viewonly = "";
$apicture = "";
$Xpicture = "";
$Xkopie = "";
$execute = "";
$befehl = "";
$var = "";
$tag = "";
$tags = "";
$para = "";
$paras = "";
$pflag = "";
$array = null;
$shellBefehl = "";
if(isset($_POST["quelle"]))
$quelle = $_POST["quelle"];
if(isset($_POST["ziel"]))
$ziel = $_POST["ziel"];
if(isset($_POST["viewonly"]))
$viewonly = $_POST["viewonly"];
if(isset($_POST["apicture"]))
$Xpicture = "checked";
if(isset($_POST["execute"]))
$execute = $_POST["execute"];
if(isset($_POST["kopie"]) && $quelle != $ziel)
$Xkopie = $_POST["kopie"];
if(isset($_POST["befehl"]))
$befehl = $_POST["befehl"];
?>
<?php
if (isset($_POST["submit"])) {
// Daten der Quelldatei lesen und anzeigen
if($viewonly && !$execute) {
$shellBefehl = "mid3v2 -l '$quelle'";
exec($shellBefehl, $var);
$tags = $var;
if(!is_file($quelle) || !file_exists($quelle)) $noquelle = 'true';
$shellBefehl = "";
$var = "";
$shellBefehl = "mid3v2 -l '$ziel'";
exec($shellBefehl, $var);
if(!is_file($ziel) || !file_exists($ziel)) $noziel = 'true';
$shellBefehl = "";
$var = "";
$paras = "";
if(isset($_POST["apicture"]))
$paras = " --APIC 'pic.jpg'";
foreach($tags as $tag) {
if(strstr($tag, "=")) {
if(strstr($tag, "APIC="))
$pflag = "P";
if(strstr($tag, "APIC=") || strstr($tag, "unrepresentable data") ||
strstr($tag, "TLEN=") || strstr($tag, "ID3 by github.com/ttimer/GUI-for-mID3v2"))
continue;
$tag = str_replace("'", "’", $tag); // abc'd fff => abc’d fff (Rückwandlung am Schrittende)
$para = " --$tag'";
if(strstr($para, "--COMM")) {
$para = str_replace("iTunNORM", "iTunNORM:", $para);
$para = str_replace("iTunPGAP", "iTunPGAP:", $para);
$para = str_replace("iTunSMPB", "iTunSMPB:", $para);
// COMM==XXX=? => --COMM ':?:XXX'
$array = explode("=", $para, 4);
$array[3] = str_replace("'", "", $array[3]);
$para = "$array[0] '$array[1]:$array[3]:$array[2]'";
// --COMM ':https://ar... => -e --COMM ':https\://ar...
if(stristr($para, "http:") || stristr($para, "https:")) {
$para = str_replace(" --", " -e --", $para);
$para = str_replace("http:", "http\:", $para);
$para = str_replace("HTTP:", "HTTP\:", $para);
$para = str_replace("https:", "https\:", $para);
$para = str_replace("HTTPS:", "HTTPS\:", $para);
}
}
if(strstr($para, "--TXXX")) {
$array = explode("=", $para, 3);
$para = "$array[0] '$array[1]:$array[2]";
// $para = "$array[0] '$array[1]¦$array[2]"; // Rückwandlung am Schrittende :: DELETE ???
}
$para = str_replace("=", " '", $para);
if(strstr($para, "’")) { // Ggf. Rückwandlung (siehe oben)
$para = str_replace("'", '"', $para); // 'ab’d ff' => "ab’d ff" (' -> ")
$para = str_replace("’", "'", $para); // "ab’d ff" => "ab'd ff" (’ -> ')
}
// if(strstr($para, "¦")) {
// $para = str_replace("¦", "=", $para); // 'abc¦xyz' => 'abc=xyz' (¦ -> =) :: DELETE ???
// }
$paras = $paras . $para;
}
}
$paras = trim($paras);
$paras = str_replace(" '' ", " ' ' ", $paras); // TPE1=' ' anstatt =''
//if($paras != "" || $paras != 0)
$shellBefehl = "mid3v2 $paras '$ziel'";
$befehl = $shellBefehl;
$befehl = str_replace(" --WXXX '$GU2'", "", $befehl);
}
// Daten auf die Zieldatei übertragen
// (ggf. vorab im Textfeld anpassen/erweitern -- bspw. Tracknummer minus 1)
if($execute) {
if($Xkopie) {
exec("mid3cp '$quelle' '$ziel'");
}
if(!strstr($befehl, $GUI))
$befehl = str_replace("mid3v2", "mid3v2 --WXXX '$GUI'", $befehl);
exec($befehl, $var);
$befehl = str_replace(" --WXXX '$GUI'", "", $befehl);
$befehl = str_replace(" --WXXX '$GU2'", "", $befehl);
$shellBefehl = "";
$var = "";
}
}
?>
<body>
<noscript><h1 style="text-align:center; background-color:yellow;">Please activate JavaScript</h1></noscript>
<form name="id3" method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>" style="margin-left:11%;">
<fieldset style="width:900px;">
<legend><span style="font-weight:700;">Files</span></legend>
<p>
source: <input type="text" name="quelle" style="width:777px;" value="<?php echo $quelle; ?>" placeholder="./artist/album/title.mp3" required />
</p>
<p>
target: <input type="text" name="ziel" style="width:777px;" value="<?php echo $ziel; ?>" placeholder="./artist/album/title.mp3 (x01-00.mp3 may be used here)" required />
</p>
<p style="display:none">
viewonly: <input type="checkbox" name="viewonly" checked />
</p>
<p>
add Pic.: <input type="checkbox" name="apicture" <?php echo $Xpicture; ?> />
<?php if($pflag == "P") echo ' <img src="pic.jpg" width="22" height="22" alt="pic present!" title="dummy pic"> Picture present!'; ?>
</p>
<p>
copy first: <input type="checkbox" name="kopie" checked /> [edit after full copy (esp. w/ APIC, LINK ...)]
</p>
<p>
executeit: <input type="checkbox" name="execute" /> [edit textarea beforehand]
(list of <a href="./mid3TagMp3Frames.php" target="frame" title="mid3v2 -f">tag frames</a> and <a href="./mid3TagMp3Genre.php" target="genre" title="mid3v2 -L">genres</a>)
<!--<a href="./mid3TagMp3Help.php" target="help" title="mid3v2 -h">edit</a>-->
</p>
</fieldset>
<textarea name="befehl" style="width:925px; font-size:12pt; line-height:24pt;" rows="4"><?php echo $befehl; ?></textarea>
<p>
<input type="submit" name="submit" value="submit" style="width:930px;" />
</p>
</form>
<?php
if($noquelle || $noziel) {
echo '<dir style="margin-left:8%; font-weight:bold;">';
if($noquelle)
echo '<p style="color:red;">No source file found!</p>';
if($noziel)
echo '<p style="color:red;">No target file found!</p>';
echo '</dir>';
exit();
}
if(isset($_POST["submit"])) {
echo('<dir style="margin-left:8%;">');
if($Xkopie) { echo("\n<br>'copy first' was $Xkopie <br>\n"); }
else { echo("\n<br>'copy first' was off <br>\n"); }
echo('</dir>');
echo("<br>\n");
echo('<script type="text/javascript">');
echo('if(document.id3.quelle.value == document.id3.ziel.value)');
echo(' clearCheck("name", "kopie", 0);');
echo('</script>');
echo("<br>\n");
}
?>
</body>
</html>