Skip to content

Commit

Permalink
Merge pull request #52 from flubshi/matrix_set_recordable
Browse files Browse the repository at this point in the history
Show record option only if available for program/channel
  • Loading branch information
flubshi committed Dec 24, 2019
2 parents a15228e + 60e1016 commit 3c6d533
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
29 changes: 28 additions & 1 deletion src/WaipuData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ WaipuData::WaipuData(const string& user, const string& pass, const WAIPU_PROVIDE
WaipuData::~WaipuData(void)
{
m_channels.clear();
m_epgEntries.clear();
m_channelGroups.clear();
m_apiToken = {};
}
Expand Down Expand Up @@ -489,7 +490,7 @@ bool WaipuData::LoadChannelData(void)
XBMC->Log(LOG_DEBUG, "[channel] selected channel logo: %s", waipu_channel.strIconPath.c_str());

bool isFav = channel["faved"].GetBool();
if(isFav)
if (isFav)
favgroup.channels.push_back(waipu_channel);

m_channels.push_back(waipu_channel);
Expand Down Expand Up @@ -676,6 +677,7 @@ PVR_ERROR WaipuData::GetEPGForChannel(ADDON_HANDLE handle,
for (const auto& epgData : epgDoc["result"].GetArray())
{
EPG_TAG tag;
WaipuEPGEntry epgEntry;
memset(&tag, 0, sizeof(EPG_TAG));

// generate a unique boadcast id
Expand All @@ -684,9 +686,17 @@ PVR_ERROR WaipuData::GetEPGForChannel(ADDON_HANDLE handle,
int dirtyID = Utils::GetIDDirty(epg_bid);
XBMC->Log(LOG_DEBUG, "[epg] epg_bid dirty: %i;", dirtyID);
tag.iUniqueBroadcastId = dirtyID;
epgEntry.iUniqueBroadcastId = dirtyID;

// channel ID
tag.iUniqueChannelId = myChannel.iUniqueId;
epgEntry.iUniqueChannelId = myChannel.iUniqueId;

// is recordable
bool isRecordable = !epgData["recordingForbidden"].GetBool();
XBMC->Log(LOG_DEBUG, "[epg] recordable: %i;", isRecordable);
epgEntry.isRecordable = isRecordable;
m_epgEntries.push_back(epgEntry);

// set title
tag.strTitle = epgData["title"].GetString();
Expand Down Expand Up @@ -1126,3 +1136,20 @@ std::string WaipuData::GetLicense(void)
ApiLogin();
return m_license;
}

PVR_ERROR WaipuData::IsEPGTagRecordable(const EPG_TAG* tag, bool* bIsRecordable)
{

for (const auto& epgEntry : m_epgEntries)
{
if (epgEntry.iUniqueBroadcastId != tag->iUniqueBroadcastId)
continue;
if (epgEntry.iUniqueChannelId != tag->iUniqueChannelId)
continue;
*bIsRecordable = epgEntry.isRecordable;
return PVR_ERROR_NO_ERROR;
}

*bIsRecordable = false;
return PVR_ERROR_NO_ERROR;
}
8 changes: 5 additions & 3 deletions src/WaipuData.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ struct WaipuChannelGroup
std::vector<WaipuChannel> channels;
};

struct WaipuEPGMappingEntry
struct WaipuEPGEntry
{
int iBroadcastId;
int iUniqueBroadcastId;
int iUniqueChannelId;
std::string waipuId;
bool isRecordable;
};

class WaipuData
Expand Down Expand Up @@ -101,6 +101,7 @@ class WaipuData

std::string GetLicense(void);
WAIPU_LOGIN_STATUS GetLoginStatus(void);
PVR_ERROR IsEPGTagRecordable(const EPG_TAG* tag, bool* bIsRecordable);

protected:
string HttpGet(const string& url);
Expand All @@ -117,6 +118,7 @@ class WaipuData
private:
bool ParseAccessToken(void);
std::vector<WaipuChannel> m_channels;
std::vector<WaipuEPGEntry> m_epgEntries;
std::vector<WaipuChannelGroup> m_channelGroups;
std::string username;
std::string password;
Expand Down
10 changes: 9 additions & 1 deletion src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,15 @@ extern "C"
PVR_ERROR SetRecordingLifetime(const PVR_RECORDING*) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR GetStreamProperties(PVR_STREAM_PROPERTIES*) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR GetStreamTimes(PVR_STREAM_TIMES*) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR IsEPGTagRecordable(const EPG_TAG*, bool*) { return PVR_ERROR_NOT_IMPLEMENTED; }
PVR_ERROR IsEPGTagRecordable(const EPG_TAG* tag, bool* bIsRecordable)
{
if (m_data)
{
return m_data->IsEPGTagRecordable(tag, bIsRecordable);
}

return PVR_ERROR_FAILED;
}
PVR_ERROR GetEPGTagEdl(const EPG_TAG* epgTag, PVR_EDL_ENTRY edl[], int* size)
{
return PVR_ERROR_NOT_IMPLEMENTED;
Expand Down

0 comments on commit 3c6d533

Please sign in to comment.