convert php to python online
?php
// Get Username and Password for mac-address
function getUserPassForMac($mac, $base_url) {
// URL Encode MAC for processing
$mac_address = urlencode($mac);
// URL's
$token_url = '/portal.php?action=handshake&type=stb&token=';
$profile_url = '/portal.php?type=stb&action=get_profile';
$list_url = '/portal.php?action=get_ordered_list&type=vod&p=1&JsHttpRequest=1-xml';
// Get token from server
$first_token = curl_http_get($base_url . $token_url)['js']['token'];
$res = explode('/', $result['js']['cmd']);
if (count($res) < 6) {
return false;
}
return [
'username' => $res[4],
'password' => $res[5]
];
}