Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions PodFetch/PodFetch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace App\SupportedApps\PodFetch;

class PodFetch extends \App\SupportedApps implements \App\EnhancedApps
{
public $config;

public function test()
{
$test = parent::appTest($this->url("/api/v1/info"));
echo $test->status;
}

public function livestats()
{
$status = "inactive";

$res1 = parent::execute($this->url("/api/v1/podcasts"));
$podcasts = json_decode($res1->getBody());

$res2 = parent::execute($this->url("/api/v1/sys/info"));
$sysinfo = json_decode($res2->getBody());

$data = [];
if ($podcasts && is_array($podcasts)) {
$data["podcast_count"] = count($podcasts);
$status = "active";
}
if ($sysinfo && isset($sysinfo->podcast_directory)) {
$data["disk_used"] = self::fmt($sysinfo->podcast_directory);
$free = array_sum(array_column($sysinfo->disks ?? [], 'available_space'));
$data["disk_free"] = self::fmt($free);
$status = "active";
}

return parent::getLiveStats($status, $data);
}

private static function fmt($bytes)
{
if ($bytes >= 1099511627776) {
return round($bytes / 1099511627776, 1) . 'T';
}
if ($bytes >= 1073741824) {
return round($bytes / 1073741824, 1) . 'G';
}
return round($bytes / 1048576, 1) . 'M';
}

public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url);
$username = $this->config->username;
$password = $this->config->password;
$rebuild_url = str_replace(
"http://",
"http://" . $username . ":" . $password . "@",
$api_url
);
$rebuild_url = str_replace(
"https://",
"https://" . $username . ":" . $password . "@",
$rebuild_url
);
$rebuild_url = rtrim($rebuild_url, "/");
return $rebuild_url . $endpoint;
}
}
Binary file added PodFetch/PodFetch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions PodFetch/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"appid": "433dc2c56e482aa6d8bc5cfae5ac5e4ec3d0f752",
"name": "PodFetch",
"website": "https://github.com/SamTV12345/PodFetch",
"license": "GPL-3.0",
"description": "Self-hosted podcast manager with GPodder sync, Audiobookshelf API, transcripts, and Chromecast support.",
"enhanced": true,
"tile_background": "light",
"icon": "PodFetch.png"
}
18 changes: 18 additions & 0 deletions PodFetch/config.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
<div class="items">
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', isset($item) ? $item->getconfig()->override_url : null, ['placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control']) !!}
</div>
<div class="input">
<label>{{ __('app.apps.username') }}</label>
{!! Form::text('config[username]', isset($item) ? $item->getconfig()->username : null, ['placeholder' => __('app.apps.username'), 'data-config' => 'username', 'class' => 'form-control config-item']) !!}
</div>
<div class="input">
<label>{{ __('app.apps.password') }}</label>
{!! Form::input('password', 'config[password]', '', ['placeholder' => __('app.apps.password'), 'data-config' => 'password', 'class' => 'form-control config-item']) !!}
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>
14 changes: 14 additions & 0 deletions PodFetch/livestats.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<ul class="livestats">
<li>
<span class="title">Pods</span>
<strong>{!! $podcast_count ?? 0 !!}</strong>
</li>
<li style="border-left:1px solid rgb(255 255 255 / 15%);border-right:1px solid rgb(255 255 255 / 15%);padding:0 8px;">
<span class="title">Used</span>
<strong>{!! $disk_used ?? '0' !!}</strong>
</li>
<li>
<span class="title">Free</span>
<strong>{!! $disk_free ?? '0' !!}</strong>
</li>
</ul>
7 changes: 0 additions & 7 deletions Podfetch/Podfetch.php

This file was deleted.

10 changes: 0 additions & 10 deletions Podfetch/app.json

This file was deleted.

Binary file removed Podfetch/podfetch.png
Binary file not shown.