Skip to content

Commit

Permalink
Merge pull request #20796 from phunkyfish/pvr-json-playlist-add-recor…
Browse files Browse the repository at this point in the history
…ding-id

[pvr] Support PVR Recording ID in JSON Playlist.Add and Playlist.Insert API
  • Loading branch information
phunkyfish committed Jan 6, 2022
2 parents 4690032 + 0a77d2f commit 44b564a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
2 changes: 2 additions & 0 deletions xbmc/interfaces/json-rpc/FileItemHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ void CFileItemHandler::HandleFileItem(const char* ID,
{
if (item->HasPVRChannelInfoTag())
object["type"] = "channel";
else if (item->HasPVRRecordingInfoTag())
object["type"] = "recording";
else if (item->HasMusicInfoTag())
{
std::string type = item->GetMusicInfoTag()->GetType();
Expand Down
18 changes: 18 additions & 0 deletions xbmc/interfaces/json-rpc/PVROperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,3 +520,21 @@ JSONRPC_STATUS CPVROperations::GetRecordingDetails(const std::string &method, IT

return OK;
}

std::shared_ptr<CFileItem> CPVROperations::GetRecordingFileItem(int recordingId)
{
if (CServiceBroker::GetPVRManager().IsStarted())
{
const std::shared_ptr<PVR::CPVRRecordings> recordings =
CServiceBroker::GetPVRManager().Recordings();

if (recordings)
{
const std::shared_ptr<PVR::CPVRRecording> recording = recordings->GetById(recordingId);
if (recording)
return std::make_shared<CFileItem>(recording);
}
}

return {};
}
2 changes: 2 additions & 0 deletions xbmc/interfaces/json-rpc/PVROperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ namespace JSONRPC
static JSONRPC_STATUS Record(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS Scan(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);

static std::shared_ptr<CFileItem> GetRecordingFileItem(int recordingId);

private:
static JSONRPC_STATUS GetPropertyValue(const std::string &property, CVariant &result);
static void FillChannelGroupDetails(const std::shared_ptr<PVR::CPVRChannelGroup> &channelGroup, const CVariant &parameterObject, CVariant &result, bool append = false);
Expand Down
13 changes: 13 additions & 0 deletions xbmc/interfaces/json-rpc/VideoLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "VideoLibrary.h"

#include "PVROperations.h"
#include "TextureDatabase.h"
#include "Util.h"
#include "messaging/ApplicationMessenger.h"
Expand Down Expand Up @@ -1041,6 +1042,7 @@ bool CVideoLibrary::FillFileItemList(const CVariant &parameterObject, CFileItemL
int movieID = (int)parameterObject["movieid"].asInteger(-1);
int episodeID = (int)parameterObject["episodeid"].asInteger(-1);
int musicVideoID = (int)parameterObject["musicvideoid"].asInteger(-1);
int recordingID = static_cast<int>(parameterObject["recordingid"].asInteger());

bool success = false;
CFileItemPtr fileItem(new CFileItem());
Expand Down Expand Up @@ -1079,6 +1081,17 @@ bool CVideoLibrary::FillFileItemList(const CVariant &parameterObject, CFileItemL
success = true;
}
}
if (recordingID > 0)
{
std::shared_ptr<CFileItem> recordingFileItem =
CPVROperations::GetRecordingFileItem(recordingID);

if (recordingFileItem)
{
list.Add(recordingFileItem);
success = true;
}
}

return success;
}
Expand Down
5 changes: 3 additions & 2 deletions xbmc/interfaces/json-rpc/schema/types.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@
{ "type": "object", "properties": { "artistid": { "$ref": "Library.Id", "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "albumid": { "$ref": "Library.Id", "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "songid": { "$ref": "Library.Id", "required": true } }, "additionalProperties": false },
{ "type": "object", "properties": { "genreid": { "$ref": "Library.Id", "required": true, "description": "Identification of a genre from the AudioLibrary" } }, "additionalProperties": false }
{ "type": "object", "properties": { "genreid": { "$ref": "Library.Id", "required": true, "description": "Identification of a genre from the AudioLibrary" } }, "additionalProperties": false },
{ "type": "object", "properties": { "recordingid": { "$ref": "Library.Id", "required": true, "description": "Identification of a PVR recording" } }, "additionalProperties": false }
]
},
"Player.Id": {
Expand Down Expand Up @@ -1502,7 +1503,7 @@
"extends": [ "Video.Details.File", "Audio.Details.Media" ],
"properties": {
"id": { "$ref": "Library.Id" },
"type": { "type": "string", "enum": [ "unknown", "movie", "episode", "musicvideo", "song", "picture", "channel" ] },
"type": { "type": "string", "enum": [ "unknown", "movie", "episode", "musicvideo", "song", "picture", "channel", "recording" ] },
"albumartist": { "$ref": "Array.String" },
"album": { "type": "string" },
"track": { "type": "integer" },
Expand Down
2 changes: 1 addition & 1 deletion xbmc/interfaces/json-rpc/schema/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
JSONRPC_VERSION 12.6.0
JSONRPC_VERSION 12.7.0

0 comments on commit 44b564a

Please sign in to comment.