Skip to content

Commit

Permalink
build index file
Browse files Browse the repository at this point in the history
  • Loading branch information
power721 committed Jul 7, 2023
1 parent 4f55db4 commit 5a27d94
Show file tree
Hide file tree
Showing 37 changed files with 1,400 additions and 101 deletions.
7 changes: 7 additions & 0 deletions doc/README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ tvbox/my.json不能在TvBox直接使用,请使用订阅地址!

阿里token和开放token每天会刷新,时间和自动签到时间一致。即使没有开启自动签到,也会刷新。

### 索引
对于阿里云盘资源,建议使用文件数量少的路径,并限速,防止被封号。

![索引页面](https://raw.githubusercontent.com/power721/alist-tvbox/master/doc/atv_index.png)

![索引模板](https://raw.githubusercontent.com/power721/alist-tvbox/master/doc/atv_index_template.png)

### 别名
把一些路径合并成一个路径。

Expand Down
Binary file added doc/atv_index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/atv_index_template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
<artifactId>commons-text</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>com.hankcs</groupId>
<artifactId>hanlp</artifactId>
<version>portable-1.8.3</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/cn/har01d/alist_tvbox/AListApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableAsync
@EnableScheduling
@EnableConfigurationProperties(AppProperties.class)
@SpringBootApplication
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/cn/har01d/alist_tvbox/domain/TaskResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cn.har01d.alist_tvbox.domain;

public enum TaskResult {
OK,
FAILED,
CANCELLED,
}
7 changes: 7 additions & 0 deletions src/main/java/cn/har01d/alist_tvbox/domain/TaskStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cn.har01d.alist_tvbox.domain;

public enum TaskStatus {
READY,
RUNNING,
COMPLETED
}
5 changes: 5 additions & 0 deletions src/main/java/cn/har01d/alist_tvbox/domain/TaskType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package cn.har01d.alist_tvbox.domain;

public enum TaskType {
INDEX
}
10 changes: 10 additions & 0 deletions src/main/java/cn/har01d/alist_tvbox/dto/GenerateRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package cn.har01d.alist_tvbox.dto;

import lombok.Data;

@Data
public class GenerateRequest {
private Integer siteId;
private String path;
private boolean includeSub;
}
20 changes: 20 additions & 0 deletions src/main/java/cn/har01d/alist_tvbox/dto/IndexRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cn.har01d.alist_tvbox.dto;

import lombok.Data;

import java.util.HashSet;
import java.util.Set;

@Data
public class IndexRequest {
private Integer siteId;
private String indexName = "index";
private boolean excludeExternal;
private boolean incremental;
private boolean compress;
private int maxDepth = 10;
private int sleep = 2000;
private Set<String> paths = new HashSet<>();
private Set<String> stopWords = new HashSet<>();
private Set<String> excludes = new HashSet<>();
}
8 changes: 8 additions & 0 deletions src/main/java/cn/har01d/alist_tvbox/dto/IndexResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package cn.har01d.alist_tvbox.dto;

import lombok.Data;

@Data
public class IndexResponse {
private final Integer taskId;
}
11 changes: 11 additions & 0 deletions src/main/java/cn/har01d/alist_tvbox/dto/IndexTemplateDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package cn.har01d.alist_tvbox.dto;

import lombok.Data;

@Data
public class IndexTemplateDto {
private Integer siteId;
private String name;
private String data;
private int sleep = 2000;
}
42 changes: 42 additions & 0 deletions src/main/java/cn/har01d/alist_tvbox/entity/IndexTemplate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package cn.har01d.alist_tvbox.entity;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.Hibernate;

import javax.persistence.*;
import java.time.Instant;
import java.util.Objects;

@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@TableGenerator(name = "tableGenerator", table = "id_generator", pkColumnName = "entity_name", valueColumnName = "next_id", allocationSize = 1)
public class IndexTemplate {
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "tableGenerator")
private Integer id;
private Integer siteId;
private String name;
@Column(columnDefinition = "TEXT")
private String data;
private int sleep;
private Instant createdTime;

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
IndexTemplate that = (IndexTemplate) o;
return id != null && Objects.equals(id, that.id);
}

@Override
public int hashCode() {
return getClass().hashCode();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package cn.har01d.alist_tvbox.entity;

import org.springframework.data.jpa.repository.JpaRepository;

public interface IndexTemplateRepository extends JpaRepository<IndexTemplate, Integer> {
}
54 changes: 54 additions & 0 deletions src/main/java/cn/har01d/alist_tvbox/entity/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package cn.har01d.alist_tvbox.entity;

import cn.har01d.alist_tvbox.domain.TaskResult;
import cn.har01d.alist_tvbox.domain.TaskStatus;
import cn.har01d.alist_tvbox.domain.TaskType;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.Hibernate;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.TableGenerator;
import java.time.Instant;
import java.util.Objects;

@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@TableGenerator(name = "tableGenerator", table = "id_generator", pkColumnName = "entity_name", valueColumnName = "next_id", allocationSize = 1)
public class Task {
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "tableGenerator")
private Integer id;
private String name;
private TaskType type;
private TaskStatus status = TaskStatus.READY;
private TaskResult result;
private String data;
private String summary;
private String error;
private Instant createdTime;
private Instant startTime;
private Instant updatedTime;
private Instant endTime;

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
Task task = (Task) o;
return id != null && Objects.equals(id, task.id);
}

@Override
public int hashCode() {
return getClass().hashCode();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cn.har01d.alist_tvbox.entity;

import org.springframework.data.jpa.repository.JpaRepository;

import java.time.Instant;

public interface TaskRepository extends JpaRepository<Task, Integer> {
long deleteAllByCreatedTimeBefore(Instant time);
}
4 changes: 2 additions & 2 deletions src/main/java/cn/har01d/alist_tvbox/log/LogsSseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public LogsSseService(SseTemplate template, MonitoringFileService monitoringFile
.forEach(line ->
template.broadcast(TOPIC, SseEmitter.event()
.id(String.valueOf(COUNTER.incrementAndGet()))
.data(COUNTER.get() + ": " + line)));
.data(String.format("%03d: %s", COUNTER.get(), line))));
} catch (Exception e) {
log.warn("", e);
}
Expand All @@ -50,7 +50,7 @@ public SseEmitter newSseEmitter() throws IOException {
for (String line : lines.subList(start, end)) {
emitter.send(SseEmitter.event()
.id(String.valueOf(COUNTER.incrementAndGet()))
.data(COUNTER.get() + ": " + line));
.data(String.format("%03d: %s", COUNTER.get(), line)));
}
return emitter;
}
Expand Down
Loading

0 comments on commit 5a27d94

Please sign in to comment.