diff --git a/Web/index.html b/Web/index.html index 6a0c6a8..ec55e72 100644 --- a/Web/index.html +++ b/Web/index.html @@ -59,7 +59,7 @@
-
+
{{= item.title}}

开播时长:{{= item.liveTime}}

diff --git a/src/main/java/com/yutou/bilibili/Controllers/VideoFileController.java b/src/main/java/com/yutou/bilibili/Controllers/VideoFileController.java index b10b527..d563b2e 100644 --- a/src/main/java/com/yutou/bilibili/Controllers/VideoFileController.java +++ b/src/main/java/com/yutou/bilibili/Controllers/VideoFileController.java @@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLDecoder; @@ -52,7 +53,13 @@ public class VideoFileController { url = URLDecoder.decode(url, StandardCharsets.UTF_8); String encode = AppTools.getMD5(url); File img = new File("cache" + File.separator + "image" + File.separator + encode); - if (img.exists()) { + int length; + try { + length = new URL(url).openConnection().getContentLength(); + } catch (IOException e) { + throw new RuntimeException(e); + } + if (img.exists()&&length==img.length()) { return Tools.getFile(img); } if (!img.getParentFile().exists()) { diff --git a/src/main/java/com/yutou/common/databases/SQLiteManager.java b/src/main/java/com/yutou/common/databases/SQLiteManager.java index 8c4a3d1..bed87a2 100644 --- a/src/main/java/com/yutou/common/databases/SQLiteManager.java +++ b/src/main/java/com/yutou/common/databases/SQLiteManager.java @@ -53,8 +53,6 @@ public abstract class SQLiteManager { type = BuildSqlItem.TYPE_BOOLEAN; } else if (field.getType() == ISqlDatabaseBean.class) { type = BuildSqlItem.TYPE_TEXT; - } else if (field.getType() == String.class) { - type = BuildSqlItem.TYPE_INT; } items.add(BuildSqlItem.create().setName(name).setType(type).setNull(!"id".equals(name)).setKey("id".equals(name))); } @@ -135,14 +133,16 @@ public abstract class SQLiteManager { if ("id".equals(key)) { continue; } + if("sql_time".equals(key)){ + statement.setLong(i++,json.getDate(key).getTime()); + continue; + } if (json.get(key) instanceof String) { statement.setString(i++, json.get(key).toString()); } else if (json.get(key) instanceof Integer) { statement.setInt(i++, json.getInteger(key)); } else if (json.get(key) instanceof Long) { statement.setLong(i++, json.getLong(key)); - } else if (json.get(key) instanceof String) { - statement.setObject(i++, json.get(key)); } else if (json.get(key) instanceof Boolean) { statement.setBoolean(i++, json.getBoolean(key)); } else if(json.get(key) instanceof Date){ @@ -204,8 +204,8 @@ public abstract class SQLiteManager { } // 设置 sql_time 的值 - String id = String.valueOf(t.getSql_time()); - statement.setString(i, id); + long id = t.getSql_time().getTime(); + statement.setLong(i, id); statement.executeUpdate(); statement.close(); diff --git a/src/main/java/com/yutou/common/okhttp/HttpDownloadUtils.java b/src/main/java/com/yutou/common/okhttp/HttpDownloadUtils.java index 310bc7b..9693c1d 100644 --- a/src/main/java/com/yutou/common/okhttp/HttpDownloadUtils.java +++ b/src/main/java/com/yutou/common/okhttp/HttpDownloadUtils.java @@ -67,7 +67,6 @@ public class HttpDownloadUtils { } public static File downloadSync(Builder builder) { - createHttpClient(builder); try { Response response = createHttpClient(builder).execute(); InputStream inputStream = Objects.requireNonNull(response.body()).byteStream(); diff --git a/src/main/java/com/yutou/common/utils/FFmpegUtils.java b/src/main/java/com/yutou/common/utils/FFmpegUtils.java index 74c1f6a..3d0dd7a 100644 --- a/src/main/java/com/yutou/common/utils/FFmpegUtils.java +++ b/src/main/java/com/yutou/common/utils/FFmpegUtils.java @@ -72,8 +72,8 @@ public class FFmpegUtils extends AbsVideoRecord { public static FFmpegUtils segment(String videoId, String ffmpegPath, File video, String outputPath) { try { FileUtils.deleteDirectory(new File(outputPath)); - } catch (IOException e) { - throw new RuntimeException(e); + } catch (IOException ignored) { + } new File(outputPath).mkdirs(); FFmpegUtils ffmpeg = new FFmpegUtils();