2017-07-17 15:45:58 +02:00
|
|
|
<?php
|
|
|
|
class SteamBridge extends BridgeAbstract {
|
|
|
|
|
|
|
|
const NAME = 'Steam Bridge';
|
2018-03-07 11:24:33 +01:00
|
|
|
const URI = 'https://store.steampowered.com/';
|
2017-07-17 15:45:58 +02:00
|
|
|
const CACHE_TIMEOUT = 3600; // 1h
|
2018-03-12 10:22:34 +01:00
|
|
|
const DESCRIPTION = 'Returns apps list';
|
2017-07-17 15:45:58 +02:00
|
|
|
const MAINTAINER = 'jacknumber';
|
|
|
|
const PARAMETERS = array(
|
|
|
|
'Wishlist' => array(
|
2019-06-06 19:59:30 +02:00
|
|
|
'userid' => array(
|
|
|
|
'name' => 'Steamid64 (find it on steamid.io)',
|
|
|
|
'title' => 'User ID (17 digits). Find your user ID with steamid.io or steamidfinder.com',
|
2017-07-17 15:45:58 +02:00
|
|
|
'required' => true,
|
2019-06-06 19:59:30 +02:00
|
|
|
'exampleValue' => '76561198821231205',
|
|
|
|
'pattern' => '[0-9]{17}',
|
2017-07-17 15:45:58 +02:00
|
|
|
),
|
|
|
|
'only_discount' => array(
|
|
|
|
'name' => 'Only discount',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
public function collectData(){
|
|
|
|
|
2019-06-06 19:59:30 +02:00
|
|
|
$userid = $this->getInput('userid');
|
2017-07-17 15:45:58 +02:00
|
|
|
|
2019-06-06 19:59:30 +02:00
|
|
|
$sourceUrl = self::URI . 'wishlist/profiles/' . $userid . '/wishlistdata?p=0';
|
2018-03-12 10:22:34 +01:00
|
|
|
$sort = array();
|
2017-07-17 15:45:58 +02:00
|
|
|
|
2019-06-06 19:59:30 +02:00
|
|
|
$json = getContents($sourceUrl)
|
|
|
|
or returnServerError('Could not get content from wishlistdata (' . $sourceUrl . ')');
|
2017-07-17 15:45:58 +02:00
|
|
|
|
2019-06-06 19:59:30 +02:00
|
|
|
$appsData = json_decode($json);
|
2017-07-17 15:45:58 +02:00
|
|
|
|
2018-03-12 10:22:34 +01:00
|
|
|
foreach($appsData as $id => $element) {
|
2017-07-17 15:45:58 +02:00
|
|
|
|
2018-03-12 10:22:34 +01:00
|
|
|
$appType = $element->type;
|
|
|
|
$appIsBuyable = 0;
|
|
|
|
$appHasDiscount = 0;
|
|
|
|
$appIsFree = 0;
|
2017-07-17 15:45:58 +02:00
|
|
|
|
2018-03-12 10:22:34 +01:00
|
|
|
if($element->subs) {
|
|
|
|
$appIsBuyable = 1;
|
2019-06-06 19:59:30 +02:00
|
|
|
$priceBlock = str_get_html($element->subs[0]->discount_block);
|
|
|
|
$appPrice = str_replace('--', '00', $priceBlock->find('.discount_final_price', 0)->plaintext);
|
2017-07-17 15:45:58 +02:00
|
|
|
|
2018-03-12 10:22:34 +01:00
|
|
|
if($element->subs[0]->discount_pct) {
|
2017-07-17 15:45:58 +02:00
|
|
|
|
2018-03-12 10:22:34 +01:00
|
|
|
$appHasDiscount = 1;
|
|
|
|
$discountBlock = str_get_html($element->subs[0]->discount_block);
|
|
|
|
$appDiscountValue = $discountBlock->find('.discount_pct', 0)->plaintext;
|
|
|
|
$appOldPrice = $discountBlock->find('.discount_original_price', 0)->plaintext;
|
2017-07-17 15:45:58 +02:00
|
|
|
|
2018-03-07 11:24:33 +01:00
|
|
|
} else {
|
2017-07-17 15:45:58 +02:00
|
|
|
|
2018-03-07 11:24:33 +01:00
|
|
|
if($this->getInput('only_discount')) {
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-17 15:45:58 +02:00
|
|
|
|
2018-03-12 10:22:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if($this->getInput('only_discount')) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isset($element->free) && $element->free = 1) {
|
|
|
|
$appIsFree = 1;
|
2018-03-07 11:24:33 +01:00
|
|
|
}
|
2018-03-12 10:22:34 +01:00
|
|
|
}
|
2017-07-17 15:45:58 +02:00
|
|
|
|
2019-06-06 19:59:30 +02:00
|
|
|
$coverUrl = str_replace('_292x136', '', strtok($element->capsule, '?'));
|
|
|
|
$picturesPath = pathinfo($coverUrl)['dirname'] . '/';
|
|
|
|
|
2018-03-12 10:22:34 +01:00
|
|
|
$item = array();
|
|
|
|
$item['uri'] = "http://store.steampowered.com/app/$id/";
|
|
|
|
$item['title'] = $element->name;
|
|
|
|
$item['type'] = $appType;
|
2019-06-06 19:59:30 +02:00
|
|
|
$item['cover'] = $coverUrl;
|
2018-03-12 10:22:34 +01:00
|
|
|
$item['timestamp'] = $element->added;
|
|
|
|
$item['isBuyable'] = $appIsBuyable;
|
|
|
|
$item['hasDiscount'] = $appHasDiscount;
|
|
|
|
$item['isFree'] = $appIsFree;
|
|
|
|
$item['priority'] = $element->priority;
|
|
|
|
|
|
|
|
if($appIsBuyable) {
|
2019-06-06 19:59:30 +02:00
|
|
|
|
2018-03-12 10:22:34 +01:00
|
|
|
$item['price'] = floatval(str_replace(',', '.', $appPrice));
|
2019-06-06 19:59:30 +02:00
|
|
|
$item['content'] = $appPrice;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if($appIsFree) {
|
|
|
|
$item['content'] = 'Free';
|
2017-07-17 15:45:58 +02:00
|
|
|
}
|
|
|
|
|
2018-03-12 10:22:34 +01:00
|
|
|
if($appHasDiscount) {
|
|
|
|
|
|
|
|
$item['discount']['value'] = $appDiscountValue;
|
2019-06-06 19:59:30 +02:00
|
|
|
$item['discount']['oldPrice'] = $appOldPrice;
|
|
|
|
$item['content'] = '<s>' . $appOldPrice . '</s> <b>' . $appPrice . '</b> (' . $appDiscountValue . ')';
|
2018-03-12 10:22:34 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$item['enclosures'] = array();
|
2019-06-06 19:59:30 +02:00
|
|
|
$item['enclosures'][] = $coverUrl;
|
2018-03-12 10:22:34 +01:00
|
|
|
|
2019-06-06 19:59:30 +02:00
|
|
|
foreach($element->screenshots as $screenshotFileName) {
|
|
|
|
$item['enclosures'][] = $picturesPath . $screenshotFileName;
|
2018-03-12 10:22:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$sort[$id] = $element->priority;
|
2018-03-07 11:24:33 +01:00
|
|
|
|
2018-03-12 10:22:34 +01:00
|
|
|
$this->items[] = $item;
|
2017-07-17 15:45:58 +02:00
|
|
|
}
|
2018-03-07 11:24:33 +01:00
|
|
|
|
2018-03-12 10:22:34 +01:00
|
|
|
array_multisort($sort, SORT_ASC, $this->items);
|
2017-07-17 15:45:58 +02:00
|
|
|
}
|
|
|
|
}
|