* make commonly used meta-info bindings more easy to use
This commit is contained in:
parent
4c6a9a4856
commit
4f04e5f4ab
|
@ -305,16 +305,50 @@ public class MediaBindingBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Define("actors")
|
||||||
|
public Object getActors() {
|
||||||
|
return getMetaInfo().getProperty("actors");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Define("genres")
|
||||||
|
public Object getGenres() {
|
||||||
|
return getMetaInfo().getProperty("genres");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Define("director")
|
||||||
|
public Object getDirector() {
|
||||||
|
return getMetaInfo().getProperty("director");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Define("certification")
|
||||||
|
public Object getCertification() {
|
||||||
|
return getMetaInfo().getProperty("certification");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Define("rating")
|
||||||
|
public Object getRating() {
|
||||||
|
return getMetaInfo().getProperty("rating");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("info")
|
@Define("info")
|
||||||
public synchronized Object getMetaInfo() throws Exception {
|
public synchronized AssociativeScriptObject getMetaInfo() {
|
||||||
if (metaInfo == null) {
|
if (metaInfo == null) {
|
||||||
|
try {
|
||||||
if (infoObject instanceof Episode)
|
if (infoObject instanceof Episode)
|
||||||
metaInfo = WebServices.TheTVDB.getSeriesInfoByName(((Episode) infoObject).getSeriesName(), Locale.ENGLISH);
|
metaInfo = WebServices.TheTVDB.getSeriesInfoByName(((Episode) infoObject).getSeriesName(), Locale.ENGLISH);
|
||||||
if (infoObject instanceof Movie)
|
if (infoObject instanceof Movie)
|
||||||
metaInfo = WebServices.TMDb.getMovieInfo((Movie) infoObject, Locale.ENGLISH);
|
metaInfo = WebServices.TMDb.getMovieInfo((Movie) infoObject, Locale.ENGLISH);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Failed to retrieve metadata: " + infoObject, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return metaInfo;
|
return new AssociativeScriptObject(new PropertyBindings(metaInfo, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -325,25 +359,25 @@ public class MediaBindingBean {
|
||||||
|
|
||||||
|
|
||||||
@Define("media")
|
@Define("media")
|
||||||
public Object getGeneralMediaInfo() {
|
public AssociativeScriptObject getGeneralMediaInfo() {
|
||||||
return new AssociativeScriptObject(getMediaInfo().snapshot(StreamKind.General, 0));
|
return new AssociativeScriptObject(getMediaInfo().snapshot(StreamKind.General, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("video")
|
@Define("video")
|
||||||
public Object getVideoInfo() {
|
public AssociativeScriptObject getVideoInfo() {
|
||||||
return new AssociativeScriptObject(getMediaInfo().snapshot(StreamKind.Video, 0));
|
return new AssociativeScriptObject(getMediaInfo().snapshot(StreamKind.Video, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("audio")
|
@Define("audio")
|
||||||
public Object getAudioInfo() {
|
public AssociativeScriptObject getAudioInfo() {
|
||||||
return new AssociativeScriptObject(getMediaInfo().snapshot(StreamKind.Audio, 0));
|
return new AssociativeScriptObject(getMediaInfo().snapshot(StreamKind.Audio, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Define("text")
|
@Define("text")
|
||||||
public Object getTextInfo() {
|
public AssociativeScriptObject getTextInfo() {
|
||||||
return new AssociativeScriptObject(getMediaInfo().snapshot(StreamKind.Text, 0));
|
return new AssociativeScriptObject(getMediaInfo().snapshot(StreamKind.Text, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class PropertyBindings extends AbstractMap<String, Object> {
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
|
|
||||||
// get method bindings
|
// get method bindings
|
||||||
for (Method method : object.getClass().getMethods()) {
|
for (Method method : object.getClass().getDeclaredMethods()) {
|
||||||
if (method.getReturnType() != void.class && method.getParameterTypes().length == 0) {
|
if (method.getReturnType() != void.class && method.getParameterTypes().length == 0) {
|
||||||
// normal properties
|
// normal properties
|
||||||
if (method.getName().length() > 3 && method.getName().substring(0, 3).equalsIgnoreCase("get")) {
|
if (method.getName().length() > 3 && method.getName().substring(0, 3).equalsIgnoreCase("get")) {
|
||||||
|
@ -37,9 +37,6 @@ public class PropertyBindings extends AbstractMap<String, Object> {
|
||||||
if (method.getName().length() > 2 && method.getName().substring(0, 3).equalsIgnoreCase("is")) {
|
if (method.getName().length() > 2 && method.getName().substring(0, 3).equalsIgnoreCase("is")) {
|
||||||
properties.put(method.getName().substring(2), method);
|
properties.put(method.getName().substring(2), method);
|
||||||
}
|
}
|
||||||
|
|
||||||
// just bind all methods to their original name as well
|
|
||||||
properties.put(method.getName(), method);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
parameter.exclude: ^StreamKind|Count$
|
parameter.exclude: ^StreamKind|Count$
|
||||||
|
|
||||||
# preview expressions (keys are tagged so they can be sorted alphabetically)
|
# preview expressions (keys are tagged so they can be sorted alphabetically)
|
||||||
expressions: n,y,s,e,t,airdate,startdate,absolute,special,imdb,episode,sxe,s00e00,movie,vc,ac,cf,vf,af,resolution,ws,sdhd,source,group,crc32,fn,ext,file,pi,pn,lang,info,info.actors,info.director,info.genres[0],info.certification,info.rating,info.runtime,info.status,media.title,media.durationString,media.overallBitRateString,video.codecID,video.frameRate,video.displayAspectRatioString,video.height,video.scanType,audio.format,audio.bitRateString,audio.language,text.codecInfo,text.language
|
expressions: n,y,s,e,t,airdate,startdate,absolute,special,imdb,episode,sxe,s00e00,movie,vc,ac,cf,vf,af,resolution,ws,sdhd,source,group,crc32,fn,ext,file,pi,pn,lang,actors,director,genres,certification,rating,info.runtime,info.status,media.title,media.durationString,media.overallBitRateString,video.codecID,video.frameRate,video.displayAspectRatioString,video.height,video.scanType,audio.format,audio.bitRateString,audio.language,text.codecInfo,text.language
|
||||||
|
|
Loading…
Reference in New Issue