Added PVR jsonrpc methods and types

This commit is contained in:
Synced Synapse 2015-11-03 23:36:28 +00:00
parent ce68ccbeb6
commit fe9f45bb4a
7 changed files with 10553 additions and 0 deletions

View File

@ -0,0 +1,206 @@
package org.xbmc.kore.jsonrpc.method;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.xbmc.kore.jsonrpc.ApiException;
import org.xbmc.kore.jsonrpc.ApiMethod;
import org.xbmc.kore.jsonrpc.type.PVRType;
import java.util.ArrayList;
import java.util.List;
/**
* All JSON RPC methods in PVR.*
*/
public class PVR {
/**
* Retrieves the channel groups for the specified type
*/
public static class GetChannelGroups extends ApiMethod<List<PVRType.DetailsChannelGroup>> {
public final static String METHOD_NAME = "PVR.GetChannelGroups";
private final static String LIST_NODE = "channelgroups";
/**
* Retrieves the channel groups for the specified type
*
* @param channeltype Channel type. See {@link org.xbmc.kore.jsonrpc.type.PVRType.ChannelType}
*/
public GetChannelGroups(String channeltype) {
super();
addParameterToRequest("channeltype", channeltype);
}
@Override
public String getMethodName() {
return METHOD_NAME;
}
@Override
public List<PVRType.DetailsChannelGroup> resultFromJson(ObjectNode jsonObject)
throws ApiException {
JsonNode resultNode = jsonObject.get(RESULT_NODE);
ArrayNode items = resultNode.has(LIST_NODE) ?
(ArrayNode)resultNode.get(LIST_NODE) : null;
if (items == null) {
return new ArrayList<>(0);
}
ArrayList<PVRType.DetailsChannelGroup> result = new ArrayList<>(items.size());
for (JsonNode item : items) {
result.add(new PVRType.DetailsChannelGroup(item));
}
return result;
}
}
/**
* Retrieves the channel list
*/
public static class GetChannels extends ApiMethod<List<PVRType.DetailsChannel>> {
public final static String METHOD_NAME = "PVR.GetChannels";
private final static String LIST_NODE = "channels";
/**
* Retrieves the channel list
*
* @param channelgroupid Group id, required
* @param properties Properties to retrieve. See {@link PVRType.FieldsChannel} for a list of
* accepted values
*/
public GetChannels(int channelgroupid, String... properties) {
super();
addParameterToRequest("channelgroupid", channelgroupid);
addParameterToRequest("properties", properties);
}
@Override
public String getMethodName() {
return METHOD_NAME;
}
@Override
public List<PVRType.DetailsChannel> resultFromJson(ObjectNode jsonObject)
throws ApiException {
JsonNode resultNode = jsonObject.get(RESULT_NODE);
ArrayNode items = resultNode.has(LIST_NODE) ?
(ArrayNode)resultNode.get(LIST_NODE) : null;
if (items == null) {
return new ArrayList<>(0);
}
ArrayList<PVRType.DetailsChannel> result = new ArrayList<>(items.size());
for (JsonNode item : items) {
result.add(new PVRType.DetailsChannel(item));
}
return result;
}
}
/**
* Retrieves the program of a specific channel
*/
public static class GetBroadcasts extends ApiMethod<List<PVRType.DetailsBroadcast>> {
public final static String METHOD_NAME = "PVR.GetBroadcasts";
private final static String LIST_NODE = "broadcasts";
/**
* Retrieves the program of a specific channel
*
* @param channelid Channel id, required
* @param properties Properties to retrieve. See {@link PVRType.FieldsBroadcast} for a list of
* accepted values
*/
public GetBroadcasts(int channelid, String... properties) {
super();
addParameterToRequest("channelid", channelid);
addParameterToRequest("properties", properties);
}
@Override
public String getMethodName() {
return METHOD_NAME;
}
@Override
public List<PVRType.DetailsBroadcast> resultFromJson(ObjectNode jsonObject)
throws ApiException {
JsonNode resultNode = jsonObject.get(RESULT_NODE);
ArrayNode items = resultNode.has(LIST_NODE) ?
(ArrayNode)resultNode.get(LIST_NODE) : null;
if (items == null) {
return new ArrayList<>(0);
}
ArrayList<PVRType.DetailsBroadcast> result = new ArrayList<>(items.size());
for (JsonNode item : items) {
result.add(new PVRType.DetailsBroadcast(item));
}
return result;
}
}
/**
* Toggle recording of a channel
*/
public static final class Record extends ApiMethod<String> {
public final static String METHOD_NAME = "PVR.Record";
/**
* Records a channel
*/
public Record(boolean record) {
super();
addParameterToRequest("record", record);
}
/**
* Toggle recording of a channel
*/
public Record() {
super();
addParameterToRequest("record", "toggle");
}
@Override
public String getMethodName() {
return METHOD_NAME;
}
@Override
public String resultFromJson(ObjectNode jsonObject) throws ApiException {
return jsonObject.get(RESULT_NODE).textValue();
}
}
/**
* Starts a channel scan
*/
public static final class Scan extends ApiMethod<String> {
public final static String METHOD_NAME = "PVR.Shutdown";
/**
* Starts a channel scan
*/
public Scan() {
super();
}
@Override
public String getMethodName() {
return METHOD_NAME;
}
@Override
public String resultFromJson(ObjectNode jsonObject) throws ApiException {
return jsonObject.get(RESULT_NODE).textValue();
}
}
}

View File

@ -0,0 +1,211 @@
package org.xbmc.kore.jsonrpc.type;
import com.fasterxml.jackson.databind.JsonNode;
import org.xbmc.kore.utils.JsonUtils;
/**
* Types from PVR.*
*/
public class PVRType {
/**
* Enums for File.Media
*/
public interface ChannelType {
String TV = "tv";
String RADIO = "radio";
String[] allValues = new String[] {
TV, RADIO
};
}
/**
* PVR.Details.ChannelGroup
*/
public static class DetailsChannelGroup extends ItemType.DetailsBase {
public static final String CHANNELGROUPID = "channelgroupid";
public static final String CHANNELTYPE = "channeltype";
public final int channelgroupid;
public final String channeltype;
/**
* Constructor
* @param node JSON object representing a Detail object
*/
public DetailsChannelGroup(JsonNode node) {
super(node);
channelgroupid = JsonUtils.intFromJsonNode(node, CHANNELGROUPID);
channeltype = JsonUtils.stringFromJsonNode(node, CHANNELTYPE, ChannelType.TV);
}
}
/**
* Enums for PVR.Fields.Broadcast
*/
public interface FieldsBroadcast {
String TITLE = "title";
String PLOT = "plot";
String PLOTOUTLINE = "plotoutline";
String STARTTIME = "starttime";
String ENDTIME = "endtime";
String RUNTIME = "runtime";
String PROGRESS = "progress";
String PROGRESSPERCENTAGE = "progresspercentage";
String GENRE = "genre";
String EPISODENAME = "episodename";
String EPISODENUM = "episodenum";
String EPISODEPART = "episodepart";
String FIRSTAIRED = "firstaired";
String HASTIMER = "hastimer";
String ISACTIVE = "isactive";
String PARENTALRATING = "parentalrating";
String WASACTIVE = "wasactive";
String THUMBNAIL = "thumbnail";
String RATING = "rating";
public final static String[] allValues = new String[] {
TITLE, PLOT, PLOTOUTLINE, STARTTIME, ENDTIME, RUNTIME, PROGRESS, PROGRESSPERCENTAGE, GENRE,
EPISODENAME, EPISODENUM, EPISODEPART, FIRSTAIRED, HASTIMER, ISACTIVE, PARENTALRATING,
WASACTIVE, THUMBNAIL, RATING
};
}
/**
* PVR.Details.Broadcast type
*/
public static class DetailsBroadcast extends ItemType.DetailsBase {
public static final String BROADCASTID = "broadcastid";
public static final String ENDTIME = "endtime";
public static final String EPISODENAME = "episodename";
public static final String EPISODENUM = "episodenum";
public static final String EPISODEPART = "episodepart";
public static final String FIRSTAIRED = "firstaired";
public static final String GENRE = "genre";
public static final String HASTIMER = "hastimer";
public static final String ISACTIVE = "isactive";
public static final String PARENTALRATING = "parentalrating";
public static final String PLOT = "plot";
public static final String PLOTOUTLINE = "plotoutline";
public static final String PROGRESS = "progress";
public static final String PROGRESSPERCENTAGE = "progresspercentage";
public static final String RATING = "rating";
public static final String RUNTIME = "runtime";
public static final String STARTTIME = "starttime";
public static final String THUMBNAIL = "thumbnail";
public static final String TITLE = "title";
public static final String WASACTIVE = "wasactive";
public final int broadcastid;
public final String endtime;
public final String episodename;
public final int episodenum;
public final int episodepart;
public final String firstaired;
public final String genre;
public final boolean hastimer;
public final boolean isactive;
public final int parentalrating;
public final String plot;
public final String plotoutline;
public final int progress;
public final double progresspercentage;
public final int rating;
public final int runtime;
public final String starttime;
public final String thumbnail;
public final String title;
public final boolean wasactive;
/**
* Constructor
* @param node JSON object representing a DetailsBroadcast object
*/
public DetailsBroadcast(JsonNode node) {
super(node);
broadcastid = JsonUtils.intFromJsonNode(node, BROADCASTID);
endtime = JsonUtils.stringFromJsonNode(node, ENDTIME);
episodename = JsonUtils.stringFromJsonNode(node, EPISODENAME);
episodenum = JsonUtils.intFromJsonNode(node, EPISODENUM, 0);
episodepart = JsonUtils.intFromJsonNode(node, EPISODEPART, 0);
firstaired = JsonUtils.stringFromJsonNode(node, FIRSTAIRED);
genre = JsonUtils.stringFromJsonNode(node, GENRE);
hastimer = JsonUtils.booleanFromJsonNode(node, HASTIMER, false);
isactive = JsonUtils.booleanFromJsonNode(node, ISACTIVE, false);
parentalrating = JsonUtils.intFromJsonNode(node, PARENTALRATING, 0);
plot = JsonUtils.stringFromJsonNode(node, PLOT);
plotoutline = JsonUtils.stringFromJsonNode(node, PLOTOUTLINE);
progress = JsonUtils.intFromJsonNode(node, PROGRESS, 0);
progresspercentage = JsonUtils.doubleFromJsonNode(node, PROGRESSPERCENTAGE, 0);
rating = JsonUtils.intFromJsonNode(node, RATING, 0);
runtime = JsonUtils.intFromJsonNode(node, RUNTIME, 0);
starttime = JsonUtils.stringFromJsonNode(node, STARTTIME);
thumbnail = JsonUtils.stringFromJsonNode(node, THUMBNAIL);
title = JsonUtils.stringFromJsonNode(node, TITLE);
wasactive = JsonUtils.booleanFromJsonNode(node, WASACTIVE, false);
}
}
/**
* Enums for PVR.Fields.Channel
*/
public interface FieldsChannel {
String THUMBNAIL = "thumbnail";
String CHANNELTYPE = "channeltype";
String HIDDEN = "hidden";
String LOCKED = "locked";
String CHANNEL = "channel";
String LASTPLAYED = "lastplayed";
String BROADCASTNOW = "broadcastnow";
String BROADCASTNEXT = "broadcastnext";
public final static String[] allValues = new String[] {
THUMBNAIL, CHANNELTYPE, HIDDEN, LOCKED, CHANNEL, LASTPLAYED, BROADCASTNOW, BROADCASTNEXT
};
}
/**
* PVR.Details.Channel
*/
public static class DetailsChannel extends ItemType.DetailsBase {
public static final String BROADCASTNEXT = "broadcastnext";
public static final String BROADCASTNOW = "broadcastnow";
public static final String CHANNEL = "channel";
public static final String CHANNELID = "channelid";
public static final String CHANNELTYPE = "channeltype";
public static final String HIDDEN = "hidden";
public static final String LASTPLAYED = "lastplayed";
public static final String LOCKED = "locked";
public static final String THUMBNAIL = "thumbnail";
public final DetailsBroadcast broadcastnext;
public final DetailsBroadcast broadcastnow;
public final String channel;
public final int channelid;
public final String channeltype;
public final boolean hidden;
public final String lastplayed;
public final boolean locked;
public final String thumbnail;
/**
* Constructor
* @param node JSON object representing a Detail object
*/
public DetailsChannel(JsonNode node) {
super(node);
broadcastnext = node.has(BROADCASTNEXT) ? new DetailsBroadcast(node.get(BROADCASTNEXT)) : null;
broadcastnow = node.has(BROADCASTNOW) ? new DetailsBroadcast(node.get(BROADCASTNOW)) : null;
channel = JsonUtils.stringFromJsonNode(node, CHANNEL);
channelid = JsonUtils.intFromJsonNode(node, CHANNELID);
channeltype = JsonUtils.stringFromJsonNode(node, CHANNELTYPE, ChannelType.TV);
hidden = JsonUtils.booleanFromJsonNode(node, HIDDEN, false);
lastplayed = JsonUtils.stringFromJsonNode(node, LASTPLAYED);
locked = JsonUtils.booleanFromJsonNode(node, LOCKED, false);
thumbnail = JsonUtils.stringFromJsonNode(node, THUMBNAIL);
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,306 @@
{
"id": 32,
"jsonrpc": "2.0",
"result": {
"channels": [{
"broadcastnext": {
"broadcastid": 47656,
"cast": "",
"director": "",
"endtime": "2015-11-03 19:30:00",
"episodename": "",
"episodenum": 0,
"episodepart": 0,
"filenameandpath": "pvr://guide/0004/2015-11-03 19:00:00.epg",
"firstaired": "1970-01-01",
"genre": ["Other", "Unknown"],
"hasrecording": false,
"hastimer": false,
"imdbnumber": "",
"isactive": false,
"originaltitle": "",
"parentalrating": 0,
"plot": "A síntese noticiosa sobre o que de mais importante se passou durante o dia. Com apresentação de José Rodrigues dos Santos e João Adelino Faria.",
"plotoutline": "",
"progress": 0,
"progresspercentage": 0.0,
"rating": 0,
"recording": "",
"runtime": "30",
"starttime": "2015-11-03 19:00:00",
"title": "Telejornal",
"wasactive": false,
"writer": "",
"year": 0
},
"broadcastnow": {
"broadcastid": 47655,
"cast": "",
"director": "",
"endtime": "2015-11-03 19:00:00",
"episodename": "",
"episodenum": 0,
"episodepart": 0,
"filenameandpath": "pvr://guide/0004/2015-11-03 18:00:00.epg",
"firstaired": "1970-01-01",
"genre": ["Other", "Unknown"],
"hasrecording": false,
"hastimer": false,
"imdbnumber": "",
"isactive": true,
"originaltitle": "",
"parentalrating": 0,
"plot": "A atualidade diária do nosso país. Portugal em Direto é um espaço de informação nacional apresentado pela jornalista Dina Aguiar.",
"plotoutline": "",
"progress": 458,
"progresspercentage": 14.222222328186035156,
"rating": 0,
"recording": "",
"runtime": "60",
"starttime": "2015-11-03 18:00:00",
"title": "Portugal em Direto",
"wasactive": false,
"writer": "",
"year": 0
},
"channel": "RTP 1",
"channelid": 4,
"channeltype": "tv",
"hidden": false,
"label": "RTP 1",
"lastplayed": "2015-11-03",
"locked": false,
"thumbnail": ""
}, {
"broadcastnext": {
"broadcastid": 54436,
"cast": "",
"director": "",
"endtime": "2015-11-03 21:00:00",
"episodename": "",
"episodenum": 0,
"episodepart": 0,
"filenameandpath": "pvr://guide/0006/2015-11-03 20:08:00.epg",
"firstaired": "1970-01-01",
"genre": ["Other", "Unknown"],
"hasrecording": false,
"hastimer": false,
"imdbnumber": "",
"isactive": false,
"originaltitle": "",
"parentalrating": 0,
"plot": "É Natal na casa dos Lepic. Como todos os anos, a família recebe a visita dos pais de Renaud. Mas rapidamente se percebe que o Bom Papá escondeu certas coisas importantes à Boa Mamã... Na casa dos Bouley, Valérie começou a sua gravidez em grande.",
"plotoutline": "É Natal na casa dos Lepic. Como todos os anos, a família recebe a visita dos pais de Renaud. Mas rapidamente se percebe que o Bom Papá escondeu certas coisas importantes à Boa Mamã... Na ca...",
"progress": 0,
"progresspercentage": 0.0,
"rating": 0,
"recording": "",
"runtime": "52",
"starttime": "2015-11-03 20:08:00",
"title": "Pais Desesperados T1 - Ep. 19",
"wasactive": false,
"writer": "",
"year": 0
},
"broadcastnow": {
"broadcastid": 54435,
"cast": "",
"director": "",
"endtime": "2015-11-03 20:08:00",
"episodename": "",
"episodenum": 0,
"episodepart": 0,
"filenameandpath": "pvr://guide/0006/2015-11-03 15:59:00.epg",
"firstaired": "1970-01-01",
"genre": ["Other", "Unknown"],
"hasrecording": false,
"hastimer": false,
"imdbnumber": "",
"isactive": true,
"originaltitle": "",
"parentalrating": 0,
"plot": "Um mundo de séries de aventura e animação para os mais pequenos. Os desenhos animados mais divertidos e também os heróis de sempre para brincar e jogar com as crianças.",
"plotoutline": "",
"progress": 7718,
"progresspercentage": 51.405620574951171875,
"rating": 0,
"recording": "",
"runtime": "249",
"starttime": "2015-11-03 15:59:00",
"title": "Zig Zag",
"wasactive": false,
"writer": "",
"year": 0
},
"channel": "RTP 2",
"channelid": 6,
"channeltype": "tv",
"hidden": false,
"label": "RTP 2",
"lastplayed": "1970-01-01",
"locked": false,
"thumbnail": ""
}, {
"broadcastnext": {
"broadcastid": 50088,
"cast": "",
"director": "",
"endtime": "2015-11-03 20:00:00",
"episodename": "",
"episodenum": 0,
"episodepart": 0,
"filenameandpath": "pvr://guide/0001/2015-11-03 18:35:00.epg",
"firstaired": "1970-01-01",
"genre": ["Other", "Unknown"],
"hasrecording": false,
"hastimer": false,
"imdbnumber": "",
"isactive": false,
"originaltitle": "",
"parentalrating": 0,
"plot": "Beatriz diz a Murilo que Evandro tem que vê-lo com o relógio no pulso. Silvia interessa-se por Sérgio. Carlos Alberto vai à Souza Rangel para uma reunião com Beatriz. Evandro pede desculpas a Teresa e Estela por causa do vídeo de Rafael e Ivan.",
"plotoutline": "Beatriz diz a Murilo que Evandro tem que vê-lo com o relógio no pulso. Silvia interessa-se por Sérgio. Carlos Alberto vai à Souza Rangel para uma reunião com Beatriz. Evandro pede desculpas...",
"progress": 0,
"progresspercentage": 0.0,
"rating": 0,
"recording": "",
"runtime": "85",
"starttime": "2015-11-03 18:35:00",
"title": "Babilónia - Ep. 125",
"wasactive": false,
"writer": "",
"year": 0
},
"broadcastnow": {
"broadcastid": 50087,
"cast": "",
"director": "",
"endtime": "2015-11-03 18:35:00",
"episodename": "",
"episodenum": 0,
"episodepart": 0,
"filenameandpath": "pvr://guide/0001/2015-11-03 16:00:00.epg",
"firstaired": "1970-01-01",
"genre": ["Other", "Unknown"],
"hasrecording": false,
"hastimer": false,
"imdbnumber": "",
"isactive": true,
"originaltitle": "",
"parentalrating": 0,
"plot": "João Baião e Andreia Rodrigues vão mudar as nossas tardes. Com eles tudo pode acontecer! Surpresas, reencontros, abraços... todos os dias um programa especial.",
"plotoutline": "",
"progress": 7658,
"progresspercentage": 82.5806427001953125,
"rating": 0,
"recording": "",
"runtime": "155",
"starttime": "2015-11-03 16:00:00",
"title": "Grande Tarde T2 - Ep. 212",
"wasactive": false,
"writer": "",
"year": 0
},
"channel": "SIC",
"channelid": 1,
"channeltype": "tv",
"hidden": false,
"label": "SIC",
"lastplayed": "1970-01-01",
"locked": false,
"thumbnail": ""
}, {
"broadcastnext": {
"broadcastid": 46764,
"cast": "",
"director": "",
"endtime": "2015-11-03 20:00:00",
"episodename": "",
"episodenum": 0,
"episodepart": 0,
"filenameandpath": "pvr://guide/0003/2015-11-03 19:13:00.epg",
"firstaired": "1970-01-01",
"genre": ["Other", "Unknown"],
"hasrecording": false,
"hastimer": false,
"imdbnumber": "",
"isactive": false,
"originaltitle": "",
"parentalrating": 0,
"plot": "Acompanhe os resumos do que se passa na Quinta, no Rurality Show que reúne famosos e anónimos num ambiente onde todos são postos à prova.",
"plotoutline": "",
"progress": 0,
"progresspercentage": 0.0,
"rating": 0,
"recording": "",
"runtime": "47",
"starttime": "2015-11-03 19:13:00",
"title": "A Quinta: Diário da Tarde",
"wasactive": false,
"writer": "",
"year": 0
},
"broadcastnow": {
"broadcastid": 46763,
"cast": "",
"director": "",
"endtime": "2015-11-03 19:13:00",
"episodename": "",
"episodenum": 0,
"episodepart": 0,
"filenameandpath": "pvr://guide/0003/2015-11-03 16:00:00.epg",
"firstaired": "1970-01-01",
"genre": ["Other", "Unknown"],
"hasrecording": false,
"hastimer": false,
"imdbnumber": "",
"isactive": true,
"originaltitle": "",
"parentalrating": 0,
"plot": "Fátima Lopes faz-lhe companhia todas as tardes, com um programa muito especial onde a boa disposição da apresentadora nunca irá faltar. Os temas centram-se em todas as áreas da sociedade: a saúde, a família, as finanças, os afetos, os famosos, a moda e as grandes polémicas da atualidade.",
"plotoutline": "Fátima Lopes faz-lhe companhia todas as tardes, com um programa muito especial onde a boa disposição da apresentadora nunca irá faltar. Os temas centram-se em todas as áreas da sociedade: a...",
"progress": 7658,
"progresspercentage": 66.3212432861328125,
"rating": 0,
"recording": "",
"runtime": "193",
"starttime": "2015-11-03 16:00:00",
"title": "A Tarde é Sua",
"wasactive": false,
"writer": "",
"year": 0
},
"channel": "TVI",
"channelid": 3,
"channeltype": "tv",
"hidden": false,
"label": "TVI",
"lastplayed": "1970-01-01",
"locked": false,
"thumbnail": ""
}, {
"channel": "ARTV",
"channelid": 2,
"channeltype": "tv",
"hidden": false,
"label": "ARTV",
"lastplayed": "1970-01-01",
"locked": false,
"thumbnail": ""
}, {
"channel": "HD",
"channelid": 5,
"channeltype": "tv",
"hidden": false,
"label": "HD",
"lastplayed": "1970-01-01",
"locked": false,
"thumbnail": ""
}],
"limits": {
"end": 6,
"start": 0,
"total": 6
}
}
}

View File

@ -0,0 +1,24 @@
{
"id": 32,
"jsonrpc": "2.0",
"result": {
"channelgroups": [{
"channelgroupid": 40,
"channeltype": "tv",
"label": "All channels"
}, {
"channelgroupid": -1,
"channeltype": "tv",
"label": "Main"
}, {
"channelgroupid": -1,
"channeltype": "tv",
"label": "Other"
}],
"limits": {
"end": 3,
"start": 0,
"total": 3
}
}
}