Skip to content

Commit c9a73ab

Browse files
committed
Add DRM support (widevine)
1 parent bcb2079 commit c9a73ab

3 files changed

Lines changed: 36 additions & 33 deletions

File tree

pvr.teleboy/addon.xml.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<addon id="pvr.teleboy"
3-
version="19.8.2"
3+
version="19.8.3"
44
name="Teleboy PVR Client"
55
provider-name="rbuehlma">
66
<requires>
@@ -32,6 +32,8 @@
3232
<fanart>fanart.jpg</fanart>
3333
</assets>
3434
<news>
35+
v19.8.3
36+
- Support drm
3537
v19.8.2
3638
- Fix session handling
3739
v19.8.1

src/TeleBoy.cpp

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -504,39 +504,53 @@ void TeleBoy::TransferChannel(kodi::addon::PVRChannelsResultSet& results, TeleBo
504504
results.Add(kodiChannel);
505505
}
506506

507-
void TeleBoy::SetStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties, const std::string& url, bool realtime)
507+
PVR_ERROR TeleBoy::SetStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties, const Value& stream, bool realtime)
508508
{
509+
PVR_ERROR ret = PVR_ERROR_FAILED;
510+
511+
string url = GetStringOrEmpty(stream, "url");
512+
kodi::Log(ADDON_LOG_INFO, "Play URL: %s.", url.c_str());
513+
url = FollowRedirect(url);
514+
515+
if (url.empty())
516+
{
517+
return PVR_ERROR_FAILED;
518+
}
519+
509520
properties.emplace_back(PVR_STREAM_PROPERTY_STREAMURL, url);
510521
properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.adaptive");
511522
properties.emplace_back("inputstream.adaptive.manifest_type", "mpd");
512523
properties.emplace_back("inputstream.adaptive.manifest_update_parameter", "full");
513524
properties.emplace_back(PVR_STREAM_PROPERTY_MIMETYPE, "application/xml+dash");
514525
properties.emplace_back(PVR_STREAM_PROPERTY_ISREALTIMESTREAM, realtime ? "true" : "false");
526+
527+
if (stream.HasMember("drm")) {
528+
string drmType = GetStringOrEmpty(stream["drm"], "type");
529+
if (drmType == "widevine") {
530+
string licenseUrl = GetStringOrEmpty(stream["drm"], "license_url");
531+
properties.emplace_back("inputstream.adaptive.license_key", licenseUrl + "||A{SSM}|");
532+
properties.emplace_back("inputstream.adaptive.license_type", "com.widevine.alpha");
533+
} else {
534+
kodi::Log(ADDON_LOG_ERROR, "Unsupported drm type: %s.", drmType.c_str());
535+
}
536+
}
537+
return PVR_ERROR_NO_ERROR;
515538
}
516539

517540
PVR_ERROR TeleBoy::GetChannelStreamProperties(const kodi::addon::PVRChannel& channel, std::vector<kodi::addon::PVRStreamProperty>& properties)
518541
{
519-
PVR_ERROR ret = PVR_ERROR_FAILED;
520-
521542
Document json;
522543
if (!ApiGet(
523544
"/users/" + userId + "/stream/live/" + to_string(channel.GetUniqueId())
524545
+ "?expand=primary_image,flags&https=1" + GetStreamParameters(), json, 0))
525546
{
526547
kodi::Log(ADDON_LOG_ERROR, "Error getting live stream url for channel %i.",
527548
channel.GetUniqueId());
528-
return ret;
549+
return PVR_ERROR_FAILED;
529550
}
530-
string url = GetStringOrEmpty(json["data"]["stream"], "url");
531-
kodi::Log(ADDON_LOG_INFO, "Play URL: %s.", url.c_str());
532-
url = FollowRedirect(url);
551+
const Value& stream = json["data"]["stream"];
552+
return SetStreamProperties(properties, stream, true);
533553

534-
if (!url.empty())
535-
{
536-
SetStreamProperties(properties, url, true);
537-
ret = PVR_ERROR_NO_ERROR;
538-
}
539-
return ret;
540554
}
541555

542556
string TeleBoy::FollowRedirect(string url)
@@ -739,15 +753,8 @@ PVR_ERROR TeleBoy::GetRecordingStreamProperties(const kodi::addon::PVRRecording&
739753
recording.GetRecordingId().c_str());
740754
return ret;
741755
}
742-
string url = GetStringOrEmpty(json["data"]["stream"], "url");
743-
url = FollowRedirect(url);
744-
745-
if (!url.empty())
746-
{
747-
SetStreamProperties(properties, url, false);
748-
ret = PVR_ERROR_NO_ERROR;
749-
}
750-
return ret;
756+
const Value& stream = json["data"]["stream"];
757+
return SetStreamProperties(properties, stream, false);
751758
}
752759

753760
PVR_ERROR TeleBoy::GetRecordingEdl(const kodi::addon::PVRRecording& recording, std::vector<kodi::addon::PVREDLEntry>& edl)
@@ -904,14 +911,8 @@ PVR_ERROR TeleBoy::GetEPGTagStreamProperties(const kodi::addon::PVREPGTag& tag,
904911
kodi::Log(ADDON_LOG_ERROR, "Could not get URL for epg tag.");
905912
return ret;
906913
}
907-
string url = GetStringOrEmpty(json["data"]["stream"], "url");
908-
url = FollowRedirect(url);
909-
if (!url.empty())
910-
{
911-
SetStreamProperties(properties, url, false);
912-
ret = PVR_ERROR_NO_ERROR;
913-
}
914-
return ret;
914+
const Value& stream = json["data"]["stream"];
915+
return SetStreamProperties(properties, stream, false);
915916
}
916917

917918
PVR_ERROR TeleBoy::GetEPGTagEdl(const kodi::addon::PVREPGTag& tag, std::vector<kodi::addon::PVREDLEntry>& edl)

src/TeleBoy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class ATTRIBUTE_HIDDEN TeleBoy : public kodi::addon::CAddonBase,
105105
std::string GetStreamParameters();
106106
void LoadGenres();
107107
bool LoadChannels();
108-
void SetStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties,
109-
const std::string& url, bool realtime);
108+
PVR_ERROR SetStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties,
109+
const Value& stream, bool realtime);
110110
void AddTimerType(std::vector<kodi::addon::PVRTimerType>& types, int idx, int attributes);
111111
};

0 commit comments

Comments
 (0)