Skip to content

Commit 7fe4fa4

Browse files
authored
Merge pull request #927 from mediathekview/dev/livestreamImport
Dev/livestream import
2 parents bb04fd1 + 4b36765 commit 7fe4fa4

19 files changed

+309
-15
lines changed

MServer-Config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ senderIncluded:
3232
# list of films to be ignored by crawler search
3333
ignoreFilmlistPath: "ignoreFilmlist.txt"
3434

35+
# list of livestreams to be added
36+
importLivestreamConfiguration:
37+
active: false
38+
path: "live-streams.json"
39+
format: OLD_JSON
40+
3541
# The formats in which the filmlist should be saved to.
3642
# 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
3743
filmlistSaveFormats:
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 ImportLivestreamConfiguration {
8+
private final Boolean active;
9+
private final String path;
10+
private final FilmlistFormats format;
11+
12+
public ImportLivestreamConfiguration(Boolean active, String path, FilmlistFormats format) {
13+
this.active = active;
14+
this.path = path;
15+
this.format = format;
16+
}
17+
18+
public ImportLivestreamConfiguration() {
19+
this.active = null;
20+
this.path = null;
21+
this.format = null;
22+
}
23+
24+
public Boolean isActive() {
25+
return active;
26+
}
27+
public String getPath() {
28+
return path;
29+
}
30+
public FilmlistFormats getFormat() {
31+
return format;
32+
}
33+
34+
@Override
35+
public boolean equals(Object obj) {
36+
if (this == obj) {
37+
return true;
38+
}
39+
if (!(obj instanceof final ImportLivestreamConfiguration that)) {
40+
return false;
41+
}
42+
if (!super.equals(obj)) {
43+
return false;
44+
}
45+
return Objects.equals(isActive(), that.isActive())
46+
&& Objects.equals(getPath(), that.getPath())
47+
&& Objects.equals(getFormat(), that.getFormat());
48+
}
49+
50+
@Override
51+
public int hashCode() {
52+
return Objects.hash(
53+
super.hashCode(),
54+
isActive(),
55+
getPath(),
56+
getFormat());
57+
}
58+
}

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public class MServerConfigDTO extends MServerBasicConfigDTO implements ConfigDTO
1616
private final String filmlistIdFilePath;
1717
/** ignore certain film by title **/
1818
private final String ignoreFilmlistPath;
19+
/** add livestreams from external list **/
20+
private final ImportLivestreamConfiguration importLivestreamConfiguration;
1921
/** The maximum amount of cpu threads to be used. */
2022
private Integer maximumCpuThreads;
2123
/**
@@ -86,7 +88,8 @@ public MServerConfigDTO() {
8688
writeFilmlistIdFileEnabled = true;
8789
filmlistIdFilePath = "filmlist.id";
8890
ignoreFilmlistPath = "ignoreFilmlist.txt";
89-
91+
importLivestreamConfiguration = new ImportLivestreamConfiguration(false, "live-streams.json", FilmlistFormats.OLD_JSON);
92+
9093
Arrays.stream(Sender.values())
9194
.forEach(sender -> senderConfigurations.put(sender, new MServerBasicConfigDTO(this)));
9295
}
@@ -235,6 +238,11 @@ public String getIgnoreFilmslistPath() {
235238
return ignoreFilmlistPath;
236239
}
237240

241+
public ImportLivestreamConfiguration getImportLivestreamConfiguration() {
242+
return importLivestreamConfiguration;
243+
}
244+
245+
238246
/**
239247
* Loads the {@link Sender} specific configuration and if it not exist creates one.
240248
*
@@ -285,7 +293,8 @@ && getFilmlistImportFormat() == that.getFilmlistImportFormat()
285293
&& Objects.equals(getFilmlistHashFilePath(), that.getFilmlistHashFilePath())
286294
&& Objects.equals(getWriteFilmlistIdFileEnabled(), that.getWriteFilmlistIdFileEnabled())
287295
&& Objects.equals(getFilmlistIdFilePath(), that.getFilmlistIdFilePath())
288-
&& Objects.equals(getIgnoreFilmslistPath(), that.getIgnoreFilmslistPath());
296+
&& Objects.equals(getIgnoreFilmslistPath(), that.getIgnoreFilmslistPath())
297+
&& Objects.equals(getImportLivestreamConfiguration(), that.getImportLivestreamConfiguration());
289298
}
290299

291300
@Override
@@ -310,7 +319,8 @@ public int hashCode() {
310319
getFilmlistHashFilePath(),
311320
getWriteFilmlistIdFileEnabled(),
312321
getFilmlistIdFilePath(),
313-
getIgnoreFilmslistPath());
322+
getIgnoreFilmslistPath(),
323+
getImportLivestreamConfiguration());
314324
}
315325

316326
public void initializeSenderConfigurations() {

src/main/java/de/mediathekview/mserver/crawler/CrawlerManager.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,30 @@ public void importFilmlist() {
155155
importFilmlist(config.getFilmlistImportFormat(), config.getFilmlistImportLocation());
156156
}
157157
}
158+
159+
public void importLivestreamFilmlist() {
160+
if (Boolean.TRUE.equals(config.getImportLivestreamConfiguration().isActive())) {
161+
importLivestreamFilmlist(config.getImportLivestreamConfiguration().getFormat(), config.getImportLivestreamConfiguration().getPath());
162+
}
163+
}
164+
165+
public void importLivestreamFilmlist(final FilmlistFormats aFormat, final String aFilmlistLocation) {
166+
try {
167+
final Optional<Filmlist> importedFilmlist;
168+
if (aFilmlistLocation.startsWith(HTTP)) {
169+
importedFilmlist = importFilmListFromURl(aFormat, aFilmlistLocation);
170+
} else {
171+
importedFilmlist = importFilmlistFromFile(aFormat, aFilmlistLocation);
172+
}
173+
// remove livestreams
174+
filmlist.getFilms().entrySet().removeIf(entry -> entry.getValue().getThema().equalsIgnoreCase("Livestream"));
175+
// add new
176+
importedFilmlist.ifPresent( imp -> imp.getFilms().entrySet().forEach( entry -> filmlist.add(entry.getValue())));
177+
//
178+
} catch (final IOException ioException) {
179+
LOG.fatal(String.format(FILMLIST_IMPORT_ERROR_TEMPLATE, aFilmlistLocation), ioException);
180+
}
181+
}
158182

159183
/**
160184
* Imports the film list with the given {@link FilmlistFormats} and the given location.
@@ -503,4 +527,9 @@ private void runCrawlers(final AbstractCrawler... aCrawlers) {
503527
Thread.currentThread().interrupt();
504528
}
505529
}
530+
531+
// Added to allow JUNIT tests
532+
public Filmlist getFilmlist() {
533+
return filmlist;
534+
}
506535
}

src/main/java/de/mediathekview/mserver/ui/config/MServerConfigUI.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ void start() {
101101
if (config.getFilmlistImporEnabled() != null && config.getFilmlistImporEnabled()) {
102102
manager.importFilmlist();
103103
}
104+
if (Boolean.TRUE.equals(config.getImportLivestreamConfiguration().isActive())) {
105+
manager.importLivestreamFilmlist();
106+
}
104107
} finally {
105108
manager.filterFilmlist();
106109
manager.saveFilmlist();

src/main/resources/MServer-Config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ senderIncluded:
2626
# list of films to be ignored by crawler search
2727
ignoreFilmlistPath: "ignoreFilmlist.txt"
2828

29+
# list of livestreams to be added
30+
importLivestreamConfiguration:
31+
active: false
32+
path: "src/main/resources/live-streams.json"
33+
format: OLD_JSON
34+
2935
# The formats in which the filmlist should be saved to.
3036
# 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
3137
filmlistSaveFormats:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Filmliste":["20.08.2023, 14:22","20.08.2023, 14:22","3.1.213"," [Vers.: 3.1.213 ]","b37878aa-d85f-41d1-89ab-053ccf278b2f"],"Filmliste":["Sender","Thema","Titel","Datum","Zeit","Dauer","Größe [MB]","Beschreibung","Url","Website","Url Untertitel","Url RTMP","Url Klein","Url RTMP Klein","Url HD","Url RTMP HD","DatumL","Url History","Geo","neu"],"X":["ARD","Livestream","tagesschau24 Livestream","","","00:00:00","0","","https://tagesschau.akamaized.net/hls/live/2020115/tagesschau/tagesschau_1/master.m3u8","","","","","","","","0","","","false"],"X":["","","ARD-alpha Livestream","","","00:00:00","0","","https://mcdn.br.de/br/fs/ard_alpha/hls/de/master.m3u8","","","","","","","","0","","","false"],"X":["","","one HD Livestream","","","00:00:00","0","","https://mcdn.one.ard.de/ardone/hls/master.m3u8","","","","","","","","0","","","false"],"X":["","","Das Erste HD Livestream","","","00:00:00","0","","https://mcdn.daserste.de/daserste/de/master.m3u8","","","","","","","","0","","","false"],"X":["ARTE.DE","","ARTE HD Livestream","","","00:00:00","0","","https://artesimulcast.akamaized.net/hls/live/2030993/artelive_de/master.m3u8","","","","","","","","0","","","false"],"X":["ARTE.FR","","ARTE HD (FR) Livestream","","","00:00:00","0","","https://artesimulcast.akamaized.net/hls/live/2031003/artelive_fr/master.m3u8","","","","","","","","0","","","false"],"X":["BR","","BR Fernsehen Nord HD Livestream","","","00:00:00","0","","https://mcdn.br.de/br/fs/bfs_nord/hls/de/master.m3u8","","","","","","","","0","","","false"],"X":["","","BR Fernsehen Süd HD Livestream","","","00:00:00","0","","https://brcdn.vo.llnwd.net/br/fs/bfs_sued/hls/de/master.m3u8","","","","","","","","0","","","false"],"X":["3Sat","","3sat Livestream","","","00:00:00","0","","https://zdf-hls-18.akamaized.net/hls/live/2016501/dach/veryhigh/master.m3u8","","","","","","","","0","","","false"],"X":["DW","","Deutsche Welle Livestream","","","00:00:00","0","","https://dwamdstream111.akamaized.net/hls/live/2017972/dwstream111/index.m3u8","","","","","","","","0","","","false"],"X":["","","Deutsche Welle (ES) Livestream","","","00:00:00","0","","https://dwamdstream109.akamaized.net/hls/live/2017970/dwstream109/index.m3u8","","","","","","","","0","","","false"],"X":["","","Deutsche Welle+ Livestream","","","00:00:00","0","","https://dwamdstream110.akamaized.net/hls/live/2017971/dwstream110/index.m3u8","","","","","","","","0","","","false"],"X":["","","Deutsche Welle (EN) Livestream","","","00:00:00","0","","https://dwamdstream107.akamaized.net/hls/live/2017968/dwstream107/index.m3u8","","","","","","","","0","","","false"],"X":["HR","","hr-fernsehen Livestream","","","00:00:00","0","","https://hrhlsde.akamaized.net/hls/live/2024526/hrhlsde/index.m3u8","","","","","","","","0","","","false"],"X":["KiKA","","KiKA Livestream","","","00:00:00","0","","https://kikageohls.akamaized.net/hls/live/2022693/livetvkika_de/master.m3u8","","","","","","","","0","","","false"],"X":["MDR","","MDR Sachsen HD Livestream","","","00:00:00","0","","https://mdrtvsnhls.akamaized.net/hls/live/2016928/mdrtvsn/index.m3u8","","","","","","","","0","","","false"],"X":["","","MDR Thüringen HD Livestream","","","00:00:00","0","","https://mdrtvthhls.akamaized.net/hls/live/2016880/mdrtvth/index.m3u8","","","","","","","","0","","","false"],"X":["","","MDR Sachsen-Anhalt HD Livestream","","","00:00:00","0","","https://mdrtvsahls.akamaized.net/hls/live/2016879/mdrtvsa/index.m3u8","","","","","","","","0","","","false"],"X":["NDR","","NDR Schleswig-Holstein HD Livestream","","","00:00:00","0","","https://mcdn.ndr.de/ndr/hls/ndr_fs/ndr_sh/master.m3u8","","","","","","","","0","","","false"],"X":["","","NDR Mecklenburg-Vorpommern HD Livestream","","","00:00:00","0","","https://mcdn.ndr.de/ndr/hls/ndr_fs/ndr_mv/master.m3u8","","","","","","","","0","","","false"],"X":["","","NDR Niedersachsen HD Livestream","","","00:00:00","0","","https://mcdn.ndr.de/ndr/hls/ndr_fs/ndr_nds/master.m3u8","","","","","","","","0","","","false"],"X":["","","NDR Hamburg HD Livestream","","","00:00:00","0","","https://mcdn.ndr.de/ndr/hls/ndr_fs/ndr_hh/master.m3u8","","","","","","","","0","","","false"],"X":["ORF","","ORF eins HD Livestream","","","00:00:00","0","","https://orf1.mdn.ors.at/out/u/orf1/q6a/manifest_6.m3u8","","","","","","","","0","","","false"],"X":["","","ORF SPORT + Livestream","","","00:00:00","0","","https://orfs.mdn.ors.at/out/u/orfs/q6a/manifest_6.m3u8","","","","","","","","0","","","false"],"X":["","","ORF III HD Livestream","","","00:00:00","0","","https://orf3.mdn.ors.at/out/u/orf3/q6a/manifest_6.m3u8","","","","","","","","0","","","false"],"X":["","","ORF 2 HD Livestream","","","00:00:00","0","","https://orf2.mdn.ors.at/out/u/orf2/qxb/manifest.m3u8","","","","","","","","0","","","false"],"X":["PHOENIX","","phoenix Livestream","","","00:00:00","0","","https://zdf-hls-19.akamaized.net/hls/live/2016502/de/veryhigh/master.m3u8","","","","","","","","0","","","false"],"X":["RBB","","rbb Brandenburg HD Livestream","","","00:00:00","0","","https://rbb-hls-brandenburg.akamaized.net/hls/live/2017825/rbb_brandenburg/master.m3u8","","","","","","","","0","","","false"],"X":["","","rbb Berlin HD Livestream","","","00:00:00","0","","https://rbb-hls-berlin.akamaized.net/hls/live/2017824/rbb_berlin/master.m3u8","","","","","","","","0","","","false"],"X":["SR","","SR Fernsehen HD Livestream","","","00:00:00","0","","https://srfs.akamaized.net/hls/live/689649/srfsgeo/index.m3u8","","","","","","","","0","","","false"],"X":["SWR","","SWR Rheinland-Pfalz HD Livestream","","","00:00:00","0","","https://swrrpd-hls.akamaized.net/hls/live/2018676/swrrpd/master.m3u8","","","","","","","","0","","","false"],"X":["","","SWR Baden-Württemberg HD Livestream","","","00:00:00","0","","https://swrbwd-hls.akamaized.net/hls/live/2018672/swrbwd/master.m3u8","","","","","","","","0","","","false"],"X":["WDR","","WDR Aachen HD Livestream","","","00:00:00","0","","https://wdrlokalzeit.akamaized.net/hls/live/2018019-b/wdrlz_aachen/master.m3u8","","","","","","","","0","","","false"],"X":["","","WDR Köln HD Livestream","","","00:00:00","0","","https://wdrlokalzeit.akamaized.net/hls/live/2023550-b/wdrlz_koeln/master.m3u8","","","","","","","","0","","","false"],"X":["","","WDR Duisburg HD Livestream","","","00:00:00","0","","https://wdrlokalzeit.akamaized.net/hls/live/2018024-b/wdrlz_duisburg/master.m3u8","","","","","","","","0","","","false"],"X":["","","WDR HD Livestream","","","00:00:00","0","","https://wdrfs247.akamaized.net/hls/live/681509/wdr_msl4_fs247/index.m3u8","","","","","","","","0","","","false"],"X":["","","WDR Ruhr HD Livestream","","","00:00:00","0","","https://wdrlokalzeit.akamaized.net/hls/live/2018027-b/wdrlz_essen/master.m3u8","","","","","","","","0","","","false"],"X":["","","WDR Düsseldorf HD Livestream","","","00:00:00","0","","https://wdrlokalzeit.akamaized.net/hls/live/2018023-b/wdrlz_duesseldorf/master.m3u8","","","","","","","","0","","","false"],"X":["","","WDR Bonn HD Livestream","","","00:00:00","0","","https://wdrlokalzeit.akamaized.net/hls/live/2018021-b/wdrlz_bonn/master.m3u8","","","","","","","","0","","","false"],"X":["","","WDR Dortmund HD Livestream","","","00:00:00","0","","https://wdrlokalzeit.akamaized.net/hls/live/2018022-b/wdrlz_dortmund/master.m3u8","","","","","","","","0","","","false"],"X":["","","WDR Bergisches Land HD Livestream","","","00:00:00","0","","https://wdrlokalzeit.akamaized.net/hls/live/2018028-b/wdrlz_wuppertal/master.m3u8","","","","","","","","0","","","false"],"X":["","","WDR Münsterland HD Livestream","","","00:00:00","0","","https://wdrlokalzeit.akamaized.net/hls/live/2018025-b/wdrlz_muensterland/master.m3u8","","","","","","","","0","","","false"],"X":["","","WDR Ostwestfalen HD Livestream","","","00:00:00","0","","https://wdrlokalzeit.akamaized.net/hls/live/2018026-b/wdrlz_bielefeld/master.m3u8","","","","","","","","0","","","false"],"X":["","","WDR Südwestfalen HD Livestream","","","00:00:00","0","","https://wdrlokalzeit.akamaized.net/hls/live/2018020-b/wdrlz_siegen/master.m3u8","","","","","","","","0","","","false"],"X":["ZDF","","ZDF HD Livestream","","","00:00:00","0","","https://zdf-hls-15.akamaized.net/hls/live/2016498/de/veryhigh/master.m3u8","","","","","","","","0","","","false"],"X":["","","ZDFinfo HD Livestream","","","00:00:00","0","","https://zdf-hls-17.akamaized.net/hls/live/2016500/de/veryhigh/master.m3u8","","","","","","","","0","","","false"],"X":["","","ZDFneo HD Livestream","","","00:00:00","0","","https://zdf-hls-16.akamaized.net/hls/live/2016499/de/veryhigh/master.m3u8","","","","","","","","0","","","false"]}

0 commit comments

Comments
 (0)