Skip to content

Commit

Permalink
Extract APi key from html
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuehlma committed Nov 20, 2018
1 parent bdbd6b2 commit 420a28d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pvr.teleboy/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="pvr.teleboy"
version="18.0.21"
version="18.0.22"
name="Teleboy PVR Client"
provider-name="rbuehlma">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
2 changes: 2 additions & 0 deletions pvr.teleboy/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
v18.0.22
- Extract API key from html
v18.0.21
- Reduce logging
- Sync code with pvr.zattoo
Expand Down
19 changes: 17 additions & 2 deletions src/TeleBoy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ using namespace std;
using namespace rapidjson;

static const string apiUrl = "http://tv.api.teleboy.ch";
static const string apiKey =
"69d4547562510efe1b5d354bc34656fb34366b6c1023739ce46958007bf17ee9";
static const string apiDeviceType = "desktop";
static const string apiVersion = "1.5";

Expand Down Expand Up @@ -189,6 +187,23 @@ bool TeleBoy::Login(string u, string p)
return false;
}
userId = result.substr(pos, endPos - pos);

pos = result.find("tvapiKey:");
size_t pos1 = result.find("'", pos) + 1;
if (pos == std::string::npos || pos1 > pos + 50)
{
XBMC->Log(LOG_ERROR, "No api key found.");
return false;
}
endPos = result.find("'", pos1);
if (endPos - pos1 > 65 || endPos <= pos)
{
XBMC->Log(LOG_DEBUG, "Got HTML body: %s", result.c_str());
XBMC->Log(LOG_ERROR, "Received api key is invalid.");
return false;
}
apiKey = result.substr(pos1, endPos - pos1);

isPlusMember = result.find("setIsPlusMember(1", endPos) != std::string::npos;
isComfortMember = result.find("setIsComfortMember(1", endPos)
!= std::string::npos;
Expand Down
1 change: 1 addition & 0 deletions src/TeleBoy.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class TeleBoy
string password;
bool favoritesOnly;
string userId;
string apiKey;
map<int, TeleBoyChannel> channelsById;
vector<int> sortedChannels;
int64_t maxRecallSeconds;
Expand Down

0 comments on commit 420a28d

Please sign in to comment.