Reduces the SQL errors of certain songs with apostrophes in their names.
This commit is contained in:
@@ -404,7 +404,7 @@ public class LocalSongProvider implements SongProvider<LocalSong>
|
|||||||
public void compute()
|
public void compute()
|
||||||
{
|
{
|
||||||
Process process;
|
Process process;
|
||||||
String line;
|
String line, lineData;
|
||||||
String[] streamData;
|
String[] streamData;
|
||||||
|
|
||||||
String type;
|
String type;
|
||||||
@@ -526,12 +526,13 @@ public class LocalSongProvider implements SongProvider<LocalSong>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "track" -> {
|
case "track" -> {
|
||||||
line = line.substring(line
|
lineData = line.substring(line
|
||||||
.indexOf(':') + 2);
|
.indexOf(':') + 2);
|
||||||
if (line.indexOf('/') >= 0)
|
if (lineData.indexOf('/') >= 0)
|
||||||
{
|
{
|
||||||
track = Arrays
|
track = Arrays
|
||||||
.stream(line.split("/"))
|
.stream(lineData
|
||||||
|
.split("/"))
|
||||||
.map(Integer::parseInt)
|
.map(Integer::parseInt)
|
||||||
.toArray(Integer[]::new);
|
.toArray(Integer[]::new);
|
||||||
}
|
}
|
||||||
@@ -540,11 +541,11 @@ public class LocalSongProvider implements SongProvider<LocalSong>
|
|||||||
if (track != null)
|
if (track != null)
|
||||||
{
|
{
|
||||||
track[0] = Integer
|
track[0] = Integer
|
||||||
.parseInt(line);
|
.parseInt(lineData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
track = new Integer[]{Integer.parseInt(line), -1};
|
track = new Integer[]{Integer.parseInt(lineData), -1};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -563,12 +564,13 @@ public class LocalSongProvider implements SongProvider<LocalSong>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "disc" -> {
|
case "disc" -> {
|
||||||
line = line.substring(line
|
lineData = line.substring(line
|
||||||
.indexOf(':') + 2);
|
.indexOf(':') + 2);
|
||||||
if (line.indexOf('/') >= 0)
|
if (lineData.indexOf('/') >= 0)
|
||||||
{
|
{
|
||||||
disc = Arrays
|
disc = Arrays
|
||||||
.stream(line.split("/"))
|
.stream(lineData
|
||||||
|
.split("/"))
|
||||||
.map(Integer::parseInt)
|
.map(Integer::parseInt)
|
||||||
.toArray(Integer[]::new);
|
.toArray(Integer[]::new);
|
||||||
}
|
}
|
||||||
@@ -577,11 +579,11 @@ public class LocalSongProvider implements SongProvider<LocalSong>
|
|||||||
if (disc != null)
|
if (disc != null)
|
||||||
{
|
{
|
||||||
disc[0] = Integer
|
disc[0] = Integer
|
||||||
.parseInt(line);
|
.parseInt(lineData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disc = new Integer[]{Integer.parseInt(line), -1};
|
disc = new Integer[]{Integer.parseInt(lineData), -1};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -602,20 +604,25 @@ public class LocalSongProvider implements SongProvider<LocalSong>
|
|||||||
case "duration:" -> {
|
case "duration:" -> {
|
||||||
if (duration == 0)
|
if (duration == 0)
|
||||||
{
|
{
|
||||||
line = line.substring(line
|
lineData = line.substring(line
|
||||||
.indexOf(':') + 2, line
|
.indexOf(':') + 2, line
|
||||||
.indexOf(','));
|
.indexOf(','));
|
||||||
duration = Long.parseLong(line
|
if (!lineData.equals(
|
||||||
|
"N/A"))
|
||||||
|
{
|
||||||
|
duration = Long
|
||||||
|
.parseLong(lineData
|
||||||
.substring(0, 2)) * 3600 * 1000 + Long
|
.substring(0, 2)) * 3600 * 1000 + Long
|
||||||
.parseLong(line
|
.parseLong(lineData
|
||||||
.substring(3, 5)) * 60 * 1000 + Long
|
.substring(3, 5)) * 60 * 1000 + Long
|
||||||
.parseLong(line
|
.parseLong(lineData
|
||||||
.substring(6, 8)) * 1000 + (long) (Float
|
.substring(6, 8)) * 1000 + (long) (Float
|
||||||
.parseFloat(line
|
.parseFloat(lineData
|
||||||
.substring(8, line
|
.substring(8, lineData
|
||||||
.length() - 1)) * 1000);
|
.length() - 1)) * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case "stream" -> {
|
case "stream" -> {
|
||||||
streamData = line.split(" ");
|
streamData = line.split(" ");
|
||||||
if (streamData[2].equals("Audio:"))
|
if (streamData[2].equals("Audio:"))
|
||||||
@@ -755,7 +762,7 @@ public class LocalSongProvider implements SongProvider<LocalSong>
|
|||||||
.split(";"))
|
.split(";"))
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(Arrays::stream)
|
.flatMap(Arrays::stream)
|
||||||
.map(String::trim)
|
.map(String::trim).map(s -> s.replaceAll("'", "''"))
|
||||||
.collect(Collectors
|
.collect(Collectors
|
||||||
.joining(";")))
|
.joining(";")))
|
||||||
.append("', ");
|
.append("', ");
|
||||||
@@ -845,6 +852,8 @@ public class LocalSongProvider implements SongProvider<LocalSong>
|
|||||||
.stream()
|
.stream()
|
||||||
.flatMap(Arrays::stream)
|
.flatMap(Arrays::stream)
|
||||||
.map(String::trim)
|
.map(String::trim)
|
||||||
|
.map(s -> s
|
||||||
|
.replaceAll("'", "''"))
|
||||||
.collect(Collectors
|
.collect(Collectors
|
||||||
.joining(";")))
|
.joining(";")))
|
||||||
.append("',");
|
.append("',");
|
||||||
|
|||||||
Reference in New Issue
Block a user