mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-30 21:30:14 +02:00
Reformat codebase v4 (#2872)
Reformat code base to PSR12 Co-authored-by: rssbridge <noreply@github.com>
This commit is contained in:
@@ -1,121 +1,111 @@
|
||||
<?php
|
||||
class SteamBridge extends BridgeAbstract {
|
||||
|
||||
const NAME = 'Steam Bridge';
|
||||
const URI = 'https://store.steampowered.com/';
|
||||
const CACHE_TIMEOUT = 3600; // 1h
|
||||
const DESCRIPTION = 'Returns apps list';
|
||||
const MAINTAINER = 'jacknumber';
|
||||
const PARAMETERS = array(
|
||||
'Wishlist' => array(
|
||||
'userid' => array(
|
||||
'name' => 'Steamid64 (find it on steamid.io)',
|
||||
'title' => 'User ID (17 digits). Find your user ID with steamid.io or steamidfinder.com',
|
||||
'required' => true,
|
||||
'exampleValue' => '76561198821231205',
|
||||
'pattern' => '[0-9]{17}',
|
||||
),
|
||||
'only_discount' => array(
|
||||
'name' => 'Only discount',
|
||||
'type' => 'checkbox',
|
||||
)
|
||||
)
|
||||
);
|
||||
class SteamBridge extends BridgeAbstract
|
||||
{
|
||||
const NAME = 'Steam Bridge';
|
||||
const URI = 'https://store.steampowered.com/';
|
||||
const CACHE_TIMEOUT = 3600; // 1h
|
||||
const DESCRIPTION = 'Returns apps list';
|
||||
const MAINTAINER = 'jacknumber';
|
||||
const PARAMETERS = [
|
||||
'Wishlist' => [
|
||||
'userid' => [
|
||||
'name' => 'Steamid64 (find it on steamid.io)',
|
||||
'title' => 'User ID (17 digits). Find your user ID with steamid.io or steamidfinder.com',
|
||||
'required' => true,
|
||||
'exampleValue' => '76561198821231205',
|
||||
'pattern' => '[0-9]{17}',
|
||||
],
|
||||
'only_discount' => [
|
||||
'name' => 'Only discount',
|
||||
'type' => 'checkbox',
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
public function collectData(){
|
||||
public function collectData()
|
||||
{
|
||||
$userid = $this->getInput('userid');
|
||||
|
||||
$userid = $this->getInput('userid');
|
||||
$sourceUrl = self::URI . 'wishlist/profiles/' . $userid . '/wishlistdata?p=0';
|
||||
$sort = [];
|
||||
|
||||
$sourceUrl = self::URI . 'wishlist/profiles/' . $userid . '/wishlistdata?p=0';
|
||||
$sort = array();
|
||||
$json = getContents($sourceUrl);
|
||||
|
||||
$json = getContents($sourceUrl);
|
||||
$appsData = json_decode($json);
|
||||
|
||||
$appsData = json_decode($json);
|
||||
foreach ($appsData as $id => $element) {
|
||||
$appType = $element->type;
|
||||
$appIsBuyable = 0;
|
||||
$appHasDiscount = 0;
|
||||
$appIsFree = 0;
|
||||
|
||||
foreach($appsData as $id => $element) {
|
||||
if ($element->subs) {
|
||||
$appIsBuyable = 1;
|
||||
$priceBlock = str_get_html($element->subs[0]->discount_block);
|
||||
$appPrice = str_replace('--', '00', $priceBlock->find('.discount_final_price', 0)->plaintext);
|
||||
|
||||
$appType = $element->type;
|
||||
$appIsBuyable = 0;
|
||||
$appHasDiscount = 0;
|
||||
$appIsFree = 0;
|
||||
if ($element->subs[0]->discount_pct) {
|
||||
$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;
|
||||
} else {
|
||||
if ($this->getInput('only_discount')) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($this->getInput('only_discount')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($element->subs) {
|
||||
$appIsBuyable = 1;
|
||||
$priceBlock = str_get_html($element->subs[0]->discount_block);
|
||||
$appPrice = str_replace('--', '00', $priceBlock->find('.discount_final_price', 0)->plaintext);
|
||||
if (isset($element->free) && $element->free = 1) {
|
||||
$appIsFree = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if($element->subs[0]->discount_pct) {
|
||||
$coverUrl = str_replace('_292x136', '', strtok($element->capsule, '?'));
|
||||
$picturesPath = pathinfo($coverUrl)['dirname'] . '/';
|
||||
|
||||
$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;
|
||||
$item = [];
|
||||
$item['uri'] = "http://store.steampowered.com/app/$id/";
|
||||
$item['title'] = $element->name;
|
||||
$item['type'] = $appType;
|
||||
$item['cover'] = $coverUrl;
|
||||
$item['timestamp'] = $element->added;
|
||||
$item['isBuyable'] = $appIsBuyable;
|
||||
$item['hasDiscount'] = $appHasDiscount;
|
||||
$item['isFree'] = $appIsFree;
|
||||
$item['priority'] = $element->priority;
|
||||
|
||||
} else {
|
||||
if ($appIsBuyable) {
|
||||
$item['price'] = floatval(str_replace(',', '.', $appPrice));
|
||||
$item['content'] = $appPrice;
|
||||
}
|
||||
|
||||
if($this->getInput('only_discount')) {
|
||||
continue;
|
||||
}
|
||||
if ($appIsFree) {
|
||||
$item['content'] = 'Free';
|
||||
}
|
||||
|
||||
}
|
||||
if ($appHasDiscount) {
|
||||
$item['discount']['value'] = $appDiscountValue;
|
||||
$item['discount']['oldPrice'] = $appOldPrice;
|
||||
$item['content'] = '<s>' . $appOldPrice . '</s> <b>' . $appPrice . '</b> (' . $appDiscountValue . ')';
|
||||
}
|
||||
|
||||
} else {
|
||||
$item['enclosures'] = [];
|
||||
$item['enclosures'][] = $coverUrl;
|
||||
|
||||
if($this->getInput('only_discount')) {
|
||||
continue;
|
||||
}
|
||||
foreach ($element->screenshots as $screenshotFileName) {
|
||||
$item['enclosures'][] = $picturesPath . $screenshotFileName;
|
||||
}
|
||||
|
||||
if(isset($element->free) && $element->free = 1) {
|
||||
$appIsFree = 1;
|
||||
}
|
||||
}
|
||||
$sort[$id] = $element->priority;
|
||||
|
||||
$coverUrl = str_replace('_292x136', '', strtok($element->capsule, '?'));
|
||||
$picturesPath = pathinfo($coverUrl)['dirname'] . '/';
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = "http://store.steampowered.com/app/$id/";
|
||||
$item['title'] = $element->name;
|
||||
$item['type'] = $appType;
|
||||
$item['cover'] = $coverUrl;
|
||||
$item['timestamp'] = $element->added;
|
||||
$item['isBuyable'] = $appIsBuyable;
|
||||
$item['hasDiscount'] = $appHasDiscount;
|
||||
$item['isFree'] = $appIsFree;
|
||||
$item['priority'] = $element->priority;
|
||||
|
||||
if($appIsBuyable) {
|
||||
|
||||
$item['price'] = floatval(str_replace(',', '.', $appPrice));
|
||||
$item['content'] = $appPrice;
|
||||
|
||||
}
|
||||
|
||||
if($appIsFree) {
|
||||
$item['content'] = 'Free';
|
||||
}
|
||||
|
||||
if($appHasDiscount) {
|
||||
|
||||
$item['discount']['value'] = $appDiscountValue;
|
||||
$item['discount']['oldPrice'] = $appOldPrice;
|
||||
$item['content'] = '<s>' . $appOldPrice . '</s> <b>' . $appPrice . '</b> (' . $appDiscountValue . ')';
|
||||
|
||||
}
|
||||
|
||||
$item['enclosures'] = array();
|
||||
$item['enclosures'][] = $coverUrl;
|
||||
|
||||
foreach($element->screenshots as $screenshotFileName) {
|
||||
$item['enclosures'][] = $picturesPath . $screenshotFileName;
|
||||
}
|
||||
|
||||
$sort[$id] = $element->priority;
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
array_multisort($sort, SORT_ASC, $this->items);
|
||||
}
|
||||
array_multisort($sort, SORT_ASC, $this->items);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user