* make commonly used meta-info bindings more easy to use

This commit is contained in:
Reinhard Pointner 2012-02-20 07:07:06 +00:00
parent 4c6a9a4856
commit 4f04e5f4ab
3 changed files with 46 additions and 15 deletions

View File

@ -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")
public synchronized Object getMetaInfo() throws Exception {
public synchronized AssociativeScriptObject getMetaInfo() {
if (metaInfo == null) {
try {
if (infoObject instanceof Episode)
metaInfo = WebServices.TheTVDB.getSeriesInfoByName(((Episode) infoObject).getSeriesName(), Locale.ENGLISH);
if (infoObject instanceof Movie)
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")
public Object getGeneralMediaInfo() {
public AssociativeScriptObject getGeneralMediaInfo() {
return new AssociativeScriptObject(getMediaInfo().snapshot(StreamKind.General, 0));
}
@Define("video")
public Object getVideoInfo() {
public AssociativeScriptObject getVideoInfo() {
return new AssociativeScriptObject(getMediaInfo().snapshot(StreamKind.Video, 0));
}
@Define("audio")
public Object getAudioInfo() {
public AssociativeScriptObject getAudioInfo() {
return new AssociativeScriptObject(getMediaInfo().snapshot(StreamKind.Audio, 0));
}
@Define("text")
public Object getTextInfo() {
public AssociativeScriptObject getTextInfo() {
return new AssociativeScriptObject(getMediaInfo().snapshot(StreamKind.Text, 0));
}

View File

@ -26,7 +26,7 @@ public class PropertyBindings extends AbstractMap<String, Object> {
this.defaultValue = defaultValue;
// get method bindings
for (Method method : object.getClass().getMethods()) {
for (Method method : object.getClass().getDeclaredMethods()) {
if (method.getReturnType() != void.class && method.getParameterTypes().length == 0) {
// normal properties
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")) {
properties.put(method.getName().substring(2), method);
}
// just bind all methods to their original name as well
properties.put(method.getName(), method);
}
}
}

View File

@ -2,4 +2,4 @@
parameter.exclude: ^StreamKind|Count$
# 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