remote: do not send the cover in the metas
[fanfix.git] / src / be / nikiroo / fanfix / supported / InfoText.java
... / ...
CommitLineData
1package be.nikiroo.fanfix.supported;
2
3import java.io.File;
4import java.io.IOException;
5import java.net.URL;
6
7import be.nikiroo.fanfix.data.MetaData;
8
9/**
10 * Support class for <tt>.info</tt> text files ({@link Text} files with a
11 * <tt>.info</tt> metadata file next to them).
12 * <p>
13 * The <tt>.info</tt> file is supposed to be written by this program, or
14 * compatible.
15 *
16 * @author niki
17 */
18class InfoText extends Text {
19 @Override
20 public String getSourceName() {
21 return "info-text";
22 }
23
24 protected File getInfoFile() {
25 return new File(assureNoTxt(getSourceFile()).getPath() + ".info");
26 }
27
28 @Override
29 protected MetaData getMeta() throws IOException {
30 MetaData meta = InfoReader.readMeta(getInfoFile(), true);
31
32 // Some old .info files don't have those now required fields...
33 String test = meta.getTitle() == null ? "" : meta.getTitle();
34 test += meta.getAuthor() == null ? "" : meta.getAuthor();
35 test += meta.getDate() == null ? "" : meta.getDate();
36 test += meta.getUrl() == null ? "" : meta.getUrl();
37 if (test.isEmpty()) {
38 MetaData superMeta = super.getMeta();
39 if (meta.getTitle() == null || meta.getTitle().isEmpty()) {
40 meta.setTitle(superMeta.getTitle());
41 }
42 if (meta.getAuthor() == null || meta.getAuthor().isEmpty()) {
43 meta.setAuthor(superMeta.getAuthor());
44 }
45 if (meta.getDate() == null || meta.getDate().isEmpty()) {
46 meta.setDate(superMeta.getDate());
47 }
48 if (meta.getUrl() == null || meta.getUrl().isEmpty()) {
49 meta.setUrl(superMeta.getUrl());
50 }
51 }
52
53 return meta;
54 }
55
56 @Override
57 protected boolean supports(URL url) {
58 return supports(url, true);
59 }
60}