Skip to content

Commit cb44dfa

Browse files
authored
Merge pull request #939 from mediathekview/dev/importFilmlists
Filmlistimport & Url availability
2 parents 7fe4fa4 + 4f8060d commit cb44dfa

19 files changed

+460
-89
lines changed

MServer-Config.yaml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,30 @@ writeFilmlistIdFileEnabled: true
8383
#The fimlist id file path
8484
filmlistIdFilePath: target/filmlists/filmlist.id
8585

86-
# Sets if a filmlist should be imported
87-
filmlistImporEnabled: false
8886

89-
# The format of the film list to import.
90-
# Possible are: JSON, OLD_JSON, JSON_COMPRESSED_XZ, OLD_JSON_COMPRESSED_XZ, JSON_COMPRESSED_GZIP, OLD_JSON_COMPRESSED_BZIP, JSON_COMPRESSED_GZIP, OLD_JSON_COMPRESSED_BZIP
91-
#filmlistImportFormat: OLD_JSON_COMPRESSED_XZ
92-
93-
# The path/URL of the film list to import.
94-
#filmlistImportLocation: http://verteiler1.mediathekview.de/Filmliste-akt.xz
87+
# import additional filmlist sources
88+
importFilmlistConfigurations :
89+
- active: false
90+
path: "someCrawlerlist.json"
91+
format: OLD_JSON
92+
createDiff: false
93+
checkImportListUrl: false
94+
- active: false
95+
path: "someMoreCrawlerlist.json"
96+
format: OLD_JSON
97+
createDiff: false
98+
checkImportListUrl: false
99+
- active: false
100+
path: "https://verteiler1.mediathekview.de/filme-org.xz"
101+
format: OLD_JSON_COMPRESSED_XZ
102+
createDiff: true
103+
checkImportListUrl: true
104+
105+
# film url is consider invalid if the size is below the minSize
106+
checkImportListUrlMinSize: 5012
107+
108+
# abort url checking after x sec
109+
checkImportListUrlTimeoutInSec: 1800
95110

96111
#### Default crawler configurations ####
97112
# The maximum amount of URLs to be processed per task.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package de.mediathekview.mserver.base.config;
2+
3+
import java.util.Objects;
4+
5+
import de.mediathekview.mlib.filmlisten.FilmlistFormats;
6+
7+
public class ImportFilmlistConfiguration {
8+
private final Boolean active;
9+
private final String path;
10+
private final FilmlistFormats format;
11+
private final Boolean createDiff;
12+
private final Boolean checkImportListUrl;
13+
14+
15+
public ImportFilmlistConfiguration(Boolean active, String path, FilmlistFormats format, Boolean createDiff, Boolean checkImportListUrl) {
16+
this.active = active;
17+
this.path = path;
18+
this.format = format;
19+
this.createDiff = createDiff;
20+
this.checkImportListUrl = checkImportListUrl;
21+
}
22+
23+
public ImportFilmlistConfiguration() {
24+
this.active = null;
25+
this.path = null;
26+
this.format = null;
27+
this.createDiff = null;
28+
this.checkImportListUrl = null;
29+
}
30+
31+
public Boolean isCheckImportListUrl() {
32+
return checkImportListUrl;
33+
}
34+
35+
public Boolean isActive() {
36+
return active;
37+
}
38+
public String getPath() {
39+
return path;
40+
}
41+
public FilmlistFormats getFormat() {
42+
return format;
43+
}
44+
public Boolean isCreateDiff() {
45+
return createDiff;
46+
}
47+
48+
@Override
49+
public boolean equals(Object obj) {
50+
if (this == obj) {
51+
return true;
52+
}
53+
if (!(obj instanceof final ImportFilmlistConfiguration that)) {
54+
return false;
55+
}
56+
if (!super.equals(obj)) {
57+
return false;
58+
}
59+
return Objects.equals(isActive(), that.isActive())
60+
&& Objects.equals(getPath(), that.getPath())
61+
&& Objects.equals(getFormat(), that.getFormat())
62+
&& Objects.equals(isCreateDiff(), that.isCreateDiff()
63+
&& Objects.equals(isCheckImportListUrl(), that.isCheckImportListUrl()));
64+
}
65+
66+
@Override
67+
public int hashCode() {
68+
return Objects.hash(
69+
super.hashCode(),
70+
isActive(),
71+
getPath(),
72+
getFormat(),
73+
isCreateDiff(),
74+
isCheckImportListUrl());
75+
}
76+
}

src/main/java/de/mediathekview/mserver/base/config/MServerConfigDTO.java

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,28 @@ public class MServerConfigDTO extends MServerBasicConfigDTO implements ConfigDTO
1818
private final String ignoreFilmlistPath;
1919
/** add livestreams from external list **/
2020
private final ImportLivestreamConfiguration importLivestreamConfiguration;
21+
/** add additional filmlist from external **/
22+
private final List<ImportFilmlistConfiguration> importFilmlistConfigurations;
2123
/** The maximum amount of cpu threads to be used. */
2224
private Integer maximumCpuThreads;
2325
/**
2426
* The maximum duration in minutes the server should run.<br>
2527
* If set to 0 the server runs without a time limit.
2628
*/
2729
private Integer maximumServerDurationInMinutes;
28-
30+
private Long checkImportListUrlMinSize;
31+
private Long checkImportListUrlTimeoutInSec;
32+
2933
private Map<Sender, MServerBasicConfigDTO> senderConfigurations;
3034
private Set<Sender> senderExcluded;
3135
private Set<Sender> senderIncluded;
3236
private Set<FilmlistFormats> filmlistSaveFormats;
3337
private Map<FilmlistFormats, String> filmlistSavePaths;
3438
private Map<FilmlistFormats, String> filmlistDiffSavePaths;
35-
private FilmlistFormats filmlistImportFormat;
3639
private String filmlistImportLocation;
3740
private MServerLogSettingsDTO logSettings;
3841
private Map<CrawlerUrlType, URL> crawlerURLs;
3942
private Map<CrawlerApiParam, String> crawlerApiParams;
40-
private Boolean filmlistImporEnabled;
4143

4244
public MServerConfigDTO() {
4345
super();
@@ -61,6 +63,9 @@ public MServerConfigDTO() {
6163

6264
maximumCpuThreads = 80;
6365
maximumServerDurationInMinutes = 0;
66+
checkImportListUrlMinSize = 2048L;
67+
checkImportListUrlTimeoutInSec = 3600L;
68+
6469
filmlistSaveFormats.add(FilmlistFormats.JSON);
6570
filmlistSaveFormats.add(FilmlistFormats.OLD_JSON);
6671
filmlistSaveFormats.add(FilmlistFormats.JSON_COMPRESSED_XZ);
@@ -79,16 +84,13 @@ public MServerConfigDTO() {
7984
filmlistSavePaths.put(FilmlistFormats.JSON_COMPRESSED_BZIP, "filmliste.json.bz");
8085
filmlistSavePaths.put(FilmlistFormats.OLD_JSON_COMPRESSED_BZIP, "filmliste_old.json.bz");
8186

82-
filmlistImporEnabled = true;
83-
filmlistImportFormat = FilmlistFormats.OLD_JSON_COMPRESSED_XZ;
84-
filmlistImportLocation = "https://verteiler1.mediathekview.de/Filmliste-akt.xz";
85-
8687
writeFilmlistHashFileEnabled = false;
8788
filmlistHashFilePath = "filmlist.hash";
8889
writeFilmlistIdFileEnabled = true;
8990
filmlistIdFilePath = "filmlist.id";
9091
ignoreFilmlistPath = "ignoreFilmlist.txt";
9192
importLivestreamConfiguration = new ImportLivestreamConfiguration(false, "live-streams.json", FilmlistFormats.OLD_JSON);
93+
importFilmlistConfigurations = new ArrayList<>();
9294

9395
Arrays.stream(Sender.values())
9496
.forEach(sender -> senderConfigurations.put(sender, new MServerBasicConfigDTO(this)));
@@ -122,14 +124,6 @@ public void setFilmlistDiffSavePaths(final Map<FilmlistFormats, String> filmlist
122124
this.filmlistDiffSavePaths = filmlistDiffSavePaths;
123125
}
124126

125-
public FilmlistFormats getFilmlistImportFormat() {
126-
return filmlistImportFormat;
127-
}
128-
129-
public void setFilmlistImportFormat(final FilmlistFormats filmlistImportFormat) {
130-
this.filmlistImportFormat = filmlistImportFormat;
131-
}
132-
133127
public String getFilmlistImportLocation() {
134128
return filmlistImportLocation;
135129
}
@@ -177,6 +171,22 @@ public Integer getMaximumServerDurationInMinutes() {
177171
public void setMaximumServerDurationInMinutes(final Integer aMaximumServerDurationInMinutes) {
178172
maximumServerDurationInMinutes = aMaximumServerDurationInMinutes;
179173
}
174+
175+
public Long getCheckImportListUrlMinSize() {
176+
return checkImportListUrlMinSize;
177+
}
178+
179+
public void setCheckImportListUrlMinSize(final Long checkImportListUrlMinSize) {
180+
this.checkImportListUrlMinSize = checkImportListUrlMinSize;
181+
}
182+
183+
public Long getCheckImportListUrlTimeoutInSec() {
184+
return checkImportListUrlTimeoutInSec;
185+
}
186+
187+
public void setCheckImportListUrlTimeoutInSec(final Long checkImportListUrlTimeoutInSec) {
188+
this.checkImportListUrlTimeoutInSec = checkImportListUrlTimeoutInSec;
189+
}
180190

181191
public Map<Sender, MServerBasicConfigDTO> getSenderConfigurations() {
182192
return senderConfigurations;
@@ -242,6 +252,9 @@ public ImportLivestreamConfiguration getImportLivestreamConfiguration() {
242252
return importLivestreamConfiguration;
243253
}
244254

255+
public List<ImportFilmlistConfiguration> getImportFilmlistConfigurations() {
256+
return importFilmlistConfigurations;
257+
}
245258

246259
/**
247260
* Loads the {@link Sender} specific configuration and if it not exist creates one.
@@ -255,14 +268,6 @@ public MServerBasicConfigDTO getSenderConfig(final Sender aSender) {
255268
return senderConfigurations.get(aSender);
256269
}
257270

258-
public Boolean getFilmlistImporEnabled() {
259-
return filmlistImporEnabled;
260-
}
261-
262-
public void setFilmlistImporEnabled(final Boolean filmlistImporEnabled) {
263-
this.filmlistImporEnabled = filmlistImporEnabled;
264-
}
265-
266271
@Override
267272
public boolean equals(final Object o) {
268273
if (this == o) {
@@ -276,25 +281,25 @@ public boolean equals(final Object o) {
276281
}
277282
return Objects.equals(getCopySettings(), that.getCopySettings())
278283
&& Objects.equals(getMaximumCpuThreads(), that.getMaximumCpuThreads())
279-
&& Objects.equals(
280-
getMaximumServerDurationInMinutes(), that.getMaximumServerDurationInMinutes())
284+
&& Objects.equals(getMaximumServerDurationInMinutes(), that.getMaximumServerDurationInMinutes())
285+
&& Objects.equals(getCheckImportListUrlMinSize(), that.getCheckImportListUrlMinSize())
286+
&& Objects.equals(getCheckImportListUrlTimeoutInSec(), that.getCheckImportListUrlTimeoutInSec())
281287
&& Objects.equals(senderConfigurations, that.senderConfigurations)
282288
&& Objects.equals(getSenderExcluded(), that.getSenderExcluded())
283289
&& Objects.equals(getSenderIncluded(), that.getSenderIncluded())
284290
&& Objects.equals(getFilmlistSaveFormats(), that.getFilmlistSaveFormats())
285291
&& Objects.equals(getFilmlistSavePaths(), that.getFilmlistSavePaths())
286292
&& Objects.equals(getFilmlistDiffSavePaths(), that.getFilmlistDiffSavePaths())
287-
&& getFilmlistImportFormat() == that.getFilmlistImportFormat()
288293
&& Objects.equals(getFilmlistImportLocation(), that.getFilmlistImportLocation())
289294
&& Objects.equals(getLogSettings(), that.getLogSettings())
290295
&& Objects.equals(getCrawlerURLs(), that.getCrawlerURLs())
291-
&& Objects.equals(getFilmlistImporEnabled(), that.getFilmlistImporEnabled())
292296
&& Objects.equals(getWriteFilmlistHashFileEnabled(), that.getWriteFilmlistHashFileEnabled())
293297
&& Objects.equals(getFilmlistHashFilePath(), that.getFilmlistHashFilePath())
294298
&& Objects.equals(getWriteFilmlistIdFileEnabled(), that.getWriteFilmlistIdFileEnabled())
295299
&& Objects.equals(getFilmlistIdFilePath(), that.getFilmlistIdFilePath())
296300
&& Objects.equals(getIgnoreFilmslistPath(), that.getIgnoreFilmslistPath())
297-
&& Objects.equals(getImportLivestreamConfiguration(), that.getImportLivestreamConfiguration());
301+
&& Objects.equals(getImportLivestreamConfiguration(), that.getImportLivestreamConfiguration())
302+
&& Objects.equals(getImportFilmlistConfigurations(), that.getImportFilmlistConfigurations());
298303
}
299304

300305
@Override
@@ -304,23 +309,24 @@ public int hashCode() {
304309
getCopySettings(),
305310
getMaximumCpuThreads(),
306311
getMaximumServerDurationInMinutes(),
312+
getCheckImportListUrlMinSize(),
313+
getCheckImportListUrlTimeoutInSec(),
307314
senderConfigurations,
308315
getSenderExcluded(),
309316
getSenderIncluded(),
310317
getFilmlistSaveFormats(),
311318
getFilmlistSavePaths(),
312319
getFilmlistDiffSavePaths(),
313-
getFilmlistImportFormat(),
314320
getFilmlistImportLocation(),
315321
getLogSettings(),
316322
getCrawlerURLs(),
317-
getFilmlistImporEnabled(),
318323
getWriteFilmlistHashFileEnabled(),
319324
getFilmlistHashFilePath(),
320325
getWriteFilmlistIdFileEnabled(),
321326
getFilmlistIdFilePath(),
322327
getIgnoreFilmslistPath(),
323-
getImportLivestreamConfiguration());
328+
getImportLivestreamConfiguration(),
329+
getImportFilmlistConfigurations());
324330
}
325331

326332
public void initializeSenderConfigurations() {

src/main/java/de/mediathekview/mserver/base/messages/ServerMessages.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public enum ServerMessages implements Message {
2727
NO_FILMLIST_IMPORT_FORMAT_IN_CONFIG("noFilmlistImportFormatInConfig", MessageTypes.FATAL_ERROR),
2828
NO_FILMLIST_IMPORT_LOCATION_IN_CONFIG(
2929
"noFilmlistImportLocationInConfig", MessageTypes.FATAL_ERROR),
30+
NO_FILMLIST_IMPORT_ACTIVE_IN_CONFIG("noFilmlistImportActgiveInConfig", MessageTypes.FATAL_ERROR),
31+
NO_FILMLIST_IMPORT_DIFF_IN_CONFIG("noFilmlistImportCreateDiffInConfig", MessageTypes.FATAL_ERROR),
32+
NO_FILMLIST_IMPORT_CHECK_IN_CONFIG("noFilmlistImportCheckUrlInConfig", MessageTypes.FATAL_ERROR),
3033
FORMAT_NOT_IN_SAVE_FORMATS("formatNotInSaveFormats", MessageTypes.ERROR),
3134
UI_TO_MANY_ARGUMENTS("uiToManyArguments", MessageTypes.ERROR),
3235
UI_UNKNOWN_ARGUMENT("uiUnknownArgument", MessageTypes.FATAL_ERROR),

0 commit comments

Comments
 (0)