Skip to content
Open
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
66 changes: 64 additions & 2 deletions Podfetch/Podfetch.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,69 @@
<?php

namespace App\SupportedApps\Podfetch;
namespace App\SupportedApps\PodFetch;

class Podfetch extends \App\SupportedApps
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;
}
}
16 changes: 8 additions & 8 deletions Podfetch/app.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"appid": "433dc2c56e482aa6d8bc5cfae5ac5e4ec3d0f752",
"name": "Podfetch",
"website": "https://podfetch.com/",
"license": "Apache License 2.0",
"description": "Podfetch es un gestor de podcasts autohospedado. Es una aplicación web que permite descargar podcasts y escucharlos en línea. Está escrita en Rust y utiliza React para el frontend. Además, incluye integración con GPodder, por lo que puedes seguir usando tu aplicación de podcasts actual.",
"enhanced": false,
"tile_background": "light",
"icon": "podfetch.png"
"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>
Binary file modified 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.