@@ -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
517540PVR_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
542556string 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
753760PVR_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
917918PVR_ERROR TeleBoy::GetEPGTagEdl (const kodi::addon::PVREPGTag& tag, std::vector<kodi::addon::PVREDLEntry>& edl)
0 commit comments