use of me.michaeldick.sonosonedrive.model.Item in project SonosOneDriveServer by bertique.
the class SonosService method parseMediaListResponse.
private static MediaList parseMediaListResponse(String userId, String json) {
JsonElement element = JsonParser.parseString(json);
JsonArray mainResultList = element.getAsJsonObject().getAsJsonArray("value");
if (mainResultList != null) {
MediaList ml = new MediaList();
List<AbstractMedia> mcList = ml.getMediaCollectionOrMediaMetadata();
for (int i = 0; i < mainResultList.size(); i++) {
Item m = new Item(mainResultList.get(i).getAsJsonObject());
if (m.getType() == null) {
logger.debug("Ignoring item with null type (e.g. .url files): " + m.getName());
} else if (m.getType() == Item.FileType.audio || (m.getType() == Item.FileType.file && m.getName().endsWith(".flac")) || (m.getType().equals(Item.FileType.file) && m.getMimeType().contains("audio"))) {
mcList.add(buildMMD(m));
} else if (m.getType() == Item.FileType.folder || m.getType() == Item.FileType.file) {
mcList.add(buildMC(m));
}
}
ml.setCount(mcList.size());
if (element.getAsJsonObject().has("@odata.count")) {
ml.setTotal(element.getAsJsonObject().get("@odata.count").getAsInt());
if (ml.getTotal() < 100 && ml.getTotal() > mcList.size()) {
ml.setTotal(ml.getTotal() - 1);
}
} else {
ml.setTotal(mcList.size());
}
logger.debug("Got program list: " + mcList.size());
return ml;
} else {
return new MediaList();
}
}
use of me.michaeldick.sonosonedrive.model.Item in project SonosOneDriveServer by bertique.
the class SonosService method getMediaURI.
@Override
public void getMediaURI(String id, MediaUriAction action, Integer secondsSinceExplicit, Holder<String> deviceSessionToken, Holder<String> getMediaURIResult, Holder<EncryptionContext> deviceSessionKey, Holder<EncryptionContext> contentKey, Holder<HttpHeaders> httpHeaders, Holder<Integer> uriTimeout, Holder<PositionInformation> positionInformation, Holder<String> privateDataFieldName) throws CustomFault {
logger.debug("getMediaURI id:" + id);
GraphAuth auth = getGraphAuth();
String json = graphApiGetRequest("me/drive/items/" + id.replaceAll(SonosService.AUDIO + ":", "") + "", 1, null, auth);
JsonElement element = JsonParser.parseString(json);
Item m = new Item(element.getAsJsonObject());
getMediaURIResult.value = m.getFileUri();
}
use of me.michaeldick.sonosonedrive.model.Item in project SonosOneDriveServer by bertique.
the class SonosService method getMediaMetadata.
@Override
public GetMediaMetadataResponse getMediaMetadata(GetMediaMetadata parameters) throws CustomFault {
logger.debug("getMediaMetadata id:" + parameters.getId());
GraphAuth auth = getGraphAuth();
String json = graphApiGetRequest("me/drive/items/" + parameters.getId(), 1, null, auth);
JsonElement element = JsonParser.parseString(json);
Item m = new Item(element.getAsJsonObject());
GetMediaMetadataResponse response = new GetMediaMetadataResponse();
response.setGetMediaMetadataResult(buildMMD(m));
return response;
}
Aggregations