Skip to content

Commit

Permalink
Merge pull request #6 from nirvana-7777/temp
Browse files Browse the repository at this point in the history
v20.7.6
  • Loading branch information
nirvana-7777 committed Nov 21, 2023
2 parents 491a65a + 6144b82 commit 0212764
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 111 deletions.
3 changes: 1 addition & 2 deletions pvr.eon/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.eon"
version="21.7.5"
version="21.7.6"
name="EON PVR Client"
provider-name="Nirvana">
<requires>
@ADDON_DEPENDS@
<import addon="inputstream.ffmpegdirect" minversion="21.0.0"/>
<import addon="inputstream.adaptive" minversion="21.0.0"/>
<import addon="script.module.inputstreamhelper" version="0.5.8"/>
</requires>
Expand Down
2 changes: 2 additions & 0 deletions pvr.eon/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ v21.7.4
- Exploit some more EPG data (live, age, seasons, episodes)
v21.7.5
- Fix startup with empty credentials and web
v20.7.6
- Try to fix armv7a
61 changes: 54 additions & 7 deletions src/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ static const std::string EON_USER_AGENT = std::string("Kodi/")
static const std::string GLOBAL_URL = "global.united.cloud/";
static const std::string BROKER_URL = "https://broker." + GLOBAL_URL;
static const std::string PLAYER = "m3u8";

static const std::string CLIENT_ID_WEB = "b8d9ade4-1093-46a7-a4f7-0e47be463c10";
static const std::string CLIENT_SECRET_WEB = "1w4dmww87x1e9l89essqvc81pidrqsa0li1rva23";

static const std::string CLIENT_ID_ATV = "5a3e24b8-70cd-4958-b716-af9ce053e594";
static const std::string CLIENT_SECRET_ATV = "aazy6orsi9elhhs17e47lfb4palgszw6igf4y26z";

static const std::string SS_DOMAIN = "TBA";
static const std::string SS_USER = "webscuser";
static const std::string SS_SECRET = "k4md93!k334f3";
Expand All @@ -38,3 +31,57 @@ static const std::string CONN_TYPE_WIFI = "WI_FI";
static const std::string CONN_TYPE_ETHERNET= "ETHERNET";
static const std::string CONN_TYPE_MOBILE = "MOBILE";
static const std::string CONN_TYPE_BROWSER = "BROWSER";

struct EonParameter
{
std::string api_prefix;
std::string api_selector;
std::string device_type;
std::string device_name;
std::string device_model;
std::string device_platform;
std::string device_mac;
std::string client_sw_version;
std::string client_sw_build;
std::string system_sw;
std::string system_version;
std::string user_agent;
std::string client_id;
std::string client_secret;
};

static const EonParameter EonParameters[2] = {{
//Web Client
"web",
"be",
"web_linux_chrome",
"",
"Chrome 116",
"web",
"",
"",
"",
"Linux",
"x86_64",
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36",
"b8d9ade4-1093-46a7-a4f7-0e47be463c10",
"1w4dmww87x1e9l89essqvc81pidrqsa0li1rva23"
},
{
//Android TV
"android-tv",
"af31",
"Android 11",
"Android TV 30",
"SHIELD Android TV",
"android_tv",
"",
"8.1.3",
"8.1.35906",
"Android",
"11",
"Mozilla/5.0 (Linux; Android 11; SHIELD Android TV Build/RQ1A.210105.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/114.0.5735.196 Mobile Safari/537.36; XDKAndroidWebView/3.0.1/XDKWebView NVIDIA NVIDIA/mdarcy/mdarcy:11/RQ1A.210105.003/7825230_3167.5736:user/release-keys NVIDIA AndroidTV 1.00A_ATV SHIELD Android TV Android/11 ExoPlayer ((1.00A_ATV::1.14.1::androidtv::)",
"5a3e24b8-70cd-4958-b716-af9ce053e594",
"aazy6orsi9elhhs17e47lfb4palgszw6igf4y26z"
}
};
95 changes: 48 additions & 47 deletions src/PVREon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,9 @@ bool CPVREon::GetPostJson(const std::string& url, const std::string& body, rapid
doc.Parse(result.c_str());
if ((doc.GetParseError()) || (statusCode != 200 && statusCode != 206))
{
kodi::Log(ADDON_LOG_ERROR, "Failed to get JSON %s status code: %i", url.c_str(), statusCode);
if (!body.empty()) {
kodi::Log(ADDON_LOG_ERROR, "Body was %s", body.c_str());
}
if (result.empty()) {
kodi::Log(ADDON_LOG_ERROR, "Empty result returned");
} else {
kodi::Log(ADDON_LOG_ERROR, "Failed to get JSON for URL %s and body %s. Status code: %i", url.c_str(), body.c_str(), statusCode);
if (!doc.GetParseError())
{
kodi::Log(ADDON_LOG_ERROR, "Result is: %s", result.c_str());
if (doc.HasMember("error") && doc.HasMember("errorMessage"))
{
Expand Down Expand Up @@ -273,7 +269,7 @@ bool CPVREon::GetCDNInfo()

const rapidjson::Value& baseApi = cdnItem["domains"]["baseApi"];

cdn.baseApi = Utils::JsonStringOrEmpty(baseApi, EonParameters[m_params].api_selector.c_str());
cdn.baseApi = Utils::JsonStringOrEmpty(baseApi, EonParameters[m_platform].api_selector.c_str());
m_cdns.emplace_back(cdn);
}

Expand Down Expand Up @@ -315,25 +311,25 @@ bool CPVREon::GetDeviceFromSerial()
{
std::string postData;

if (m_settings->GetPlatform() == PLATFORM_ANDROIDTV) {
postData = "{\"deviceName\":\"" + EonParameters[m_params].device_name +
"\",\"deviceType\":\"" + EonParameters[m_params].device_type +
"\",\"modelName\":\"" + EonParameters[m_params].device_model +
"\",\"platform\":\"" + EonParameters[m_params].device_platform +
if (m_platform == PLATFORM_ANDROIDTV) {
postData = "{\"deviceName\":\"" + EonParameters[m_platform].device_name +
"\",\"deviceType\":\"" + EonParameters[m_platform].device_type +
"\",\"modelName\":\"" + EonParameters[m_platform].device_model +
"\",\"platform\":\"" + EonParameters[m_platform].device_platform +
"\",\"serial\":\"" + m_device_serial +
"\",\"clientSwVersion\":\"" + EonParameters[m_params].client_sw_version +
"\",\"clientSwBuild\":\"" + EonParameters[m_params].client_sw_build +
"\",\"systemSwVersion\":{\"name\":\"" + EonParameters[m_params].system_sw +
"\",\"version\":\"" + EonParameters[m_params].system_version +
"\",\"clientSwVersion\":\"" + EonParameters[m_platform].client_sw_version +
"\",\"clientSwBuild\":\"" + EonParameters[m_platform].client_sw_build +
"\",\"systemSwVersion\":{\"name\":\"" + EonParameters[m_platform].system_sw +
"\",\"version\":\"" + EonParameters[m_platform].system_version +
"\"},\"fcmToken\":\"\"}";
//TODO: implement parameter fcmToken...
} else {
postData = "{\"deviceName\":\"\",\"deviceType\":\"" + EonParameters[m_params].device_type +
"\",\"modelName\":\"" + EonParameters[m_params].device_model +
"\",\"platform\":\"" + EonParameters[m_params].device_platform +
postData = "{\"deviceName\":\"\",\"deviceType\":\"" + EonParameters[m_platform].device_type +
"\",\"modelName\":\"" + EonParameters[m_platform].device_model +
"\",\"platform\":\"" + EonParameters[m_platform].device_platform +
"\",\"serial\":\"" + m_device_serial +
"\",\"clientSwVersion\":\"\",\"systemSwVersion\":{\"name\":\"" + EonParameters[m_params].system_sw +
"\",\"version\":\"" + EonParameters[m_params].system_version + "\"}}";
"\",\"clientSwVersion\":\"\",\"systemSwVersion\":{\"name\":\"" + EonParameters[m_platform].system_sw +
"\",\"version\":\"" + EonParameters[m_platform].system_version + "\"}}";
}

std::string url = m_api + "v1/devices";
Expand Down Expand Up @@ -523,7 +519,7 @@ CPVREon::CPVREon() :
m_settings->Load();
m_httpClient = new HttpClient(m_settings);

m_params = m_settings->GetPlatform();
m_platform = m_settings->GetPlatform();
m_support_web = "API_NOT_SET_YET";
m_httpClient->SetSupportApi(m_support_web);

Expand All @@ -533,11 +529,11 @@ CPVREon::CPVREon() :
std::string cdn_identifier = GetBrandIdentifier();
kodi::Log(ADDON_LOG_DEBUG, "CDN Identifier: %s", cdn_identifier.c_str());
std::string baseApi = GetBaseApi(cdn_identifier);
m_api = "https://api-" + EonParameters[m_params].api_prefix + "." + baseApi + "/";
m_images_api = "https://images-" + EonParameters[m_params].api_prefix + "." + baseApi + "/";
m_api = "https://api-" + EonParameters[m_platform].api_prefix + "." + baseApi + "/";
m_images_api = "https://images-" + EonParameters[m_platform].api_prefix + "." + baseApi + "/";
} else {
m_api = "https://api-" + EonParameters[m_params].api_prefix + "." + GLOBAL_URL;
m_images_api = "https://images-" + EonParameters[m_params].api_prefix + "." + GLOBAL_URL;
m_api = "https://api-" + EonParameters[m_platform].api_prefix + "." + GLOBAL_URL;
m_images_api = "https://images-" + EonParameters[m_platform].api_prefix + "." + GLOBAL_URL;
}
m_httpClient->SetApi(m_api);
kodi::Log(ADDON_LOG_DEBUG, "API set to: %s", m_api.c_str());
Expand Down Expand Up @@ -768,14 +764,13 @@ bool CPVREon::HandleSession(bool start, int cid, int epg_id)

void CPVREon::SetStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& properties,
const std::string& url,
const bool& realtime, const bool& playTimeshiftBuffer, const bool& isLive,
const int& starttime, const int& endtime)
const bool& realtime, const bool& playTimeshiftBuffer, const bool& isLive/*,
time_t starttime, time_t endtime*/)
{
kodi::Log(ADDON_LOG_DEBUG, "[PLAY STREAM] url: %s", url.c_str());

properties.emplace_back(PVR_STREAM_PROPERTY_STREAMURL, url);
properties.emplace_back(PVR_STREAM_PROPERTY_ISREALTIMESTREAM, realtime ? "true" : "false");
properties.emplace_back(PVR_STREAM_PROPERTY_MIMETYPE, "application/x-mpegURL");

int inputstream = m_settings->GetInputstream();

Expand All @@ -791,8 +786,11 @@ void CPVREon::SetStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& p
properties.emplace_back("inputstream.adaptive.manifest_type", "hls");
// properties.emplace_back("inputstream.adaptive.original_audio_language", "bs");
// properties.emplace_back("inputstream.adaptive.stream_selection_type", "adaptive");
properties.emplace_back("inputstream.adaptive.stream_selection_type", "manual-osd");
properties.emplace_back("inputstream.adaptive.manifest_headers", "User-Agent=" + EonParameters[m_params].user_agent);
// properties.emplace_back("inputstream.adaptive.stream_selection_type", "manual-osd");
properties.emplace_back("inputstream.adaptive.stream_selection_type", "fixed-res");
properties.emplace_back("inputstream.adaptive.chooser_resolution_max", "4K");
//properties.emplace_back("inputstream.adaptive.stream_selection_type", "fixed-res");
properties.emplace_back("inputstream.adaptive.manifest_headers", "User-Agent=" + EonParameters[m_platform].user_agent);
// properties.emplace_back("inputstream.adaptive.manifest_update_parameter", "full");
} else if (inputstream == INPUTSTREAM_FFMPEGDIRECT)
{
Expand All @@ -817,9 +815,9 @@ void CPVREon::SetStreamProperties(std::vector<kodi::addon::PVRStreamProperty>& p
} else {
kodi::Log(ADDON_LOG_DEBUG, "Unknown inputstream detected");
}
properties.emplace_back(PVR_STREAM_PROPERTY_MIMETYPE, "application/x-mpegURL");
}


PVR_ERROR CPVREon::GetCapabilities(kodi::addon::PVRCapabilities& capabilities)
{
capabilities.SetSupportsEPG(true);
Expand Down Expand Up @@ -913,10 +911,10 @@ PVR_ERROR CPVREon::GetEPGForChannel(int channelUid,
tag.SetUniqueChannelId(channelUid);
tag.SetTitle(Utils::JsonStringOrEmpty(epgItem,"title"));
tag.SetOriginalTitle(Utils::JsonStringOrEmpty(epgItem,"originalTitle"));
int64_t starttime = Utils::JsonInt64OrZero(epgItem,"startTime") / 1000;
int64_t endtime = Utils::JsonInt64OrZero(epgItem,"endTime") / 1000;
tag.SetStartTime((int)starttime);
tag.SetEndTime((int)endtime);
time_t starttime = (time_t) (Utils::JsonInt64OrZero(epgItem,"startTime") / 1000);
time_t endtime = (time_t) (Utils::JsonInt64OrZero(epgItem,"endTime") / 1000);
tag.SetStartTime(starttime);
tag.SetEndTime(endtime);
tag.SetPlot(Utils::JsonStringOrEmpty(epgItem,"shortDescription"));
int seasonNumber = Utils::JsonIntOrZero(epgItem,"seasonNumber");
if (seasonNumber != 0)
Expand Down Expand Up @@ -993,7 +991,7 @@ PVR_ERROR CPVREon::GetEPGTagStreamProperties(
{
if (channel.iUniqueId == tag.GetUniqueChannelId())
{
return GetStreamProperties(channel, properties, tag.GetStartTime(), tag.GetEndTime(), false);
return GetStreamProperties(channel, properties, tag.GetStartTime(), /*tag.GetEndTime(),*/ false);
}
}
return PVR_ERROR_NO_ERROR;
Expand Down Expand Up @@ -1049,7 +1047,7 @@ PVR_ERROR CPVREon::GetChannels(bool bRadio, kodi::addon::PVRChannelsResultSet& r
}

PVR_ERROR CPVREon::GetStreamProperties(
const EonChannel& channel, std::vector<kodi::addon::PVRStreamProperty>& properties, const int& starttime, const int& endtime, const bool& isLive)
const EonChannel& channel, std::vector<kodi::addon::PVRStreamProperty>& properties, time_t starttime,/* time_t endtime,*/ const bool& isLive)
{
kodi::Log(ADDON_LOG_DEBUG, "function call: [%s]", __FUNCTION__);
std::string streaming_profile = "hp7000";
Expand Down Expand Up @@ -1080,7 +1078,7 @@ PVR_ERROR CPVREon::GetStreamProperties(

std::string plain_aes;

if (m_settings->GetPlatform() == PLATFORM_ANDROIDTV) {
if (m_platform == PLATFORM_ANDROIDTV) {
plain_aes = "channel=" + channel.publishingPoints[0].publishingPoint + ";" +
"stream=" + streaming_profile + ";" +
"sp=" + m_service_provider + ";" +
Expand All @@ -1098,7 +1096,7 @@ PVR_ERROR CPVREon::GetStreamProperties(
"session=" + m_session_id + ";" +
"maxvbr=" + std::to_string(rndbitrate);
if (!isLive) {
plain_aes = plain_aes + ";t=" + std::to_string(starttime) + "000;";
plain_aes = plain_aes + ";t=" + std::to_string((int) starttime) + "000;";
}
} else {
plain_aes = "channel=" + channel.publishingPoints[0].publishingPoint + ";" +
Expand All @@ -1113,7 +1111,7 @@ PVR_ERROR CPVREon::GetStreamProperties(
"ctime=" + GetTime() + ";" +
"conn=" + CONN_TYPE_BROWSER + ";";
if (!isLive) {
plain_aes = plain_aes + "t=" + std::to_string(starttime) + "000;";
plain_aes = plain_aes + "t=" + std::to_string((int) starttime) + "000;";
}
plain_aes = plain_aes + "aa=" + (channel.aaEnabled ? "true" : "false");
}
Expand All @@ -1138,20 +1136,23 @@ PVR_ERROR CPVREon::GetStreamProperties(
std::string enc_url = "https://" + currentServer.hostname +
"/stream?i=" + urlsafeencode(base64_encode(iv_str.c_str(), iv_str.length())) +
"&a=" + urlsafeencode(base64_encode(enc_str.c_str(), enc_str.length()));
if (m_settings->GetPlatform() == PLATFORM_ANDROIDTV) {
if (m_platform == PLATFORM_ANDROIDTV) {
enc_url = enc_url + "&lang=eng";
}
enc_url = enc_url + "&sp=" + m_service_provider +
"&u=" + m_settings->GetEonStreamUser() +
"&player=" + PLAYER +
"&session=" + m_session_id;
if (m_settings->GetPlatform() != PLATFORM_ANDROIDTV) {
if (m_platform != PLATFORM_ANDROIDTV) {
enc_url = enc_url + "&sig=" + channel.sig;
}

kodi::Log(ADDON_LOG_DEBUG, "Encrypted Stream URL -> %s", enc_url.c_str());

SetStreamProperties(properties, enc_url, true, false, isLive, starttime, endtime);
SetStreamProperties(properties, enc_url, true, false, isLive/*, starttime, endtime*/);

for (auto& prop : properties)
kodi::Log(ADDON_LOG_DEBUG, "Name: %s Value: %s", prop.GetName().c_str(), prop.GetValue().c_str());

return PVR_ERROR_NO_ERROR;
}
Expand All @@ -1163,7 +1164,7 @@ PVR_ERROR CPVREon::GetChannelStreamProperties(
EonChannel addonChannel;
if (GetChannel(channel, addonChannel)) {
if (addonChannel.subscribed) {
return GetStreamProperties(addonChannel, properties, 0, 0, true);
return GetStreamProperties(addonChannel, properties, 0,/* 0,*/ true);
}
kodi::Log(ADDON_LOG_DEBUG, "Channel not subscribed");
return PVR_ERROR_SERVER_ERROR;
Expand Down Expand Up @@ -1311,7 +1312,7 @@ bool CPVREon::GetServer(bool isLive, EonServer& myServer)
servers = m_timeshift_servers;
}
int target_server = 2;
if (m_settings->GetPlatform() == PLATFORM_ANDROIDTV) {
if (m_platform == PLATFORM_ANDROIDTV) {
target_server = 3;
}
int count = 0;
Expand Down

0 comments on commit 0212764

Please sign in to comment.