Skip to content

Commit 31e4583

Browse files
committed
QOL improvements! QR codes, MF proxy integration, and more! 🎉
1 parent 168f650 commit 31e4583

27 files changed

+541
-162
lines changed

app/Facades/PlaylistUrlFacade.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
use Illuminate\Support\Facades\Facade;
66

7+
/**
8+
* @method static array getUrls($playlist)
9+
* @method static boolean mediaFlowProxyEnabled()
10+
* @method static array getMediaFlowSettings()
11+
* @method static array getMediaFlowProxyServerUrl()
12+
* @method static string getMediaFlowProxyUrls()
13+
*/
714
class PlaylistUrlFacade extends Facade
815
{
916
protected static function getFacadeAccessor()

app/Facades/ProxyFacade.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
use Illuminate\Support\Facades\Facade;
66

7+
/**
8+
* @method static string getProxyUrlForChannel(string $id)
9+
*/
710
class ProxyFacade extends Facade
811
{
912
protected static function getFacadeAccessor()

app/Filament/Pages/Preferences.php

Lines changed: 89 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class Preferences extends SettingsPage
1717

1818
protected static string $settings = GeneralSettings::class;
1919

20+
protected static ?string $navigationLabel = 'Settings';
21+
22+
protected static ?string $title = 'Settings';
23+
2024
public function form(Form $form): Form
2125
{
2226
return $form
@@ -45,6 +49,91 @@ public function form(Form $form): Form
4549
MaxWidth::Full->value => 'Full',
4650
]),
4751
]),
52+
Forms\Components\Section::make()
53+
->heading('Proxy')
54+
->description('Proxy settings and configuration.')
55+
->schema([
56+
Forms\Components\Section::make('Internal Proxy')
57+
->description('FFmpeg proxy settings')
58+
->columnSpan('full')
59+
->columns(3)
60+
->schema([
61+
Forms\Components\Toggle::make('ffmpeg_debug')
62+
->label('Debug')
63+
->columnSpan(1)
64+
->inline(false)
65+
->helperText('When enabled FFmpeg will output verbose logging to the log file (/var/www/logs/ffmpeg.log). When disabled, FFmpeg will only log errors.'),
66+
Forms\Components\TextInput::make('ffmpeg_max_tries')
67+
->label('Max tries')
68+
->columnSpan(1)
69+
->required()
70+
->type('number')
71+
->default(3)
72+
->minValue(0)
73+
->helperText('If the FFMpeg process crashes or fails for any reason, how many times should it try to reconnect before aborting?'),
74+
Forms\Components\TextInput::make('ffmpeg_user_agent')
75+
->label('User agent')
76+
->required()
77+
->columnSpan(1)
78+
->default('VLC/3.0.21 LibVLC/3.0.21')
79+
->placeholder('VLC/3.0.21 LibVLC/3.0.21')
80+
->helperText(''),
81+
]),
82+
Forms\Components\Section::make('MediaFlow Proxy')
83+
->description('If you have MediaFlow Proxy installed, you can use it to proxy your m3u editor playlist streams. When enabled, the app will auto-generate URLs for you to use via MediaFlow Proxy.')
84+
->columnSpan('full')
85+
->columns(3)
86+
->headerActions([
87+
Forms\Components\Actions\Action::make('mfproxy_git')
88+
->label('GitHub')
89+
->icon('heroicon-o-arrow-top-right-on-square')
90+
->iconPosition('after')
91+
->color('gray')
92+
->size('sm')
93+
->url('https://github.com/mhdzumair/mediaflow-proxy')
94+
->openUrlInNewTab(true)
95+
])
96+
->schema([
97+
Forms\Components\TextInput::make('mediaflow_proxy_url')
98+
->label('URL')
99+
->columnSpan(1)
100+
->placeholder('http://localhost'),
101+
Forms\Components\TextInput::make('mediaflow_proxy_port')
102+
->label('Port')
103+
->type('number')
104+
->columnSpan(1)
105+
->placeholder(8888),
106+
Forms\Components\TextInput::make('mediaflow_proxy_password')
107+
->label('API Password')
108+
->columnSpan(1)
109+
->password()
110+
->revealable(),
111+
])
112+
]),
113+
Forms\Components\Section::make()
114+
->heading('API')
115+
->description('Use the API to make calls directly to the app.')
116+
->headerActions([
117+
Forms\Components\Actions\Action::make('manage_api_keys')
118+
->label('Manage API Tokens')
119+
->color('gray')
120+
->icon('heroicon-s-key')
121+
->iconPosition('before')
122+
->size('sm')
123+
->url('/profile'),
124+
Forms\Components\Actions\Action::make('view_api_docs')
125+
->label('API Docs')
126+
->icon('heroicon-o-arrow-top-right-on-square')
127+
->iconPosition('after')
128+
->size('sm')
129+
->url('/docs/api')
130+
->openUrlInNewTab(true),
131+
])
132+
->schema([
133+
Forms\Components\Toggle::make('show_api_docs')
134+
->label('Allow access to API docs')
135+
->helperText('When enabled you can access the API documentation using the "API Docs" button. When disabled, the docs endpoint will return a 403 (Unauthorized). NOTE: The API will respond regardless of this setting. You do not need to enable it to use the API.'),
136+
]),
48137
Forms\Components\Section::make()
49138
->heading('Debugging')
50139
->description('Debug and development settings.')
@@ -93,31 +182,6 @@ public function form(Form $form): Form
93182
->label('Allow queue manager access')
94183
->helperText('When enabled you can access the queue manager using the "Queue Manager" button. When disabled, the queue manager endpoint will return a 403 (Unauthorized).'),
95184
]),
96-
97-
Forms\Components\Section::make()
98-
->heading('API')
99-
->description('Use the API to make calls directly to the app.')
100-
->headerActions([
101-
Forms\Components\Actions\Action::make('manage_api_keys')
102-
->label('Manage API Tokens')
103-
->color('gray')
104-
->icon('heroicon-s-key')
105-
->iconPosition('before')
106-
->size('sm')
107-
->url('/profile'),
108-
Forms\Components\Actions\Action::make('view_api_docs')
109-
->label('API Docs')
110-
->icon('heroicon-o-arrow-top-right-on-square')
111-
->iconPosition('after')
112-
->size('sm')
113-
->url('/docs/api')
114-
->openUrlInNewTab(true),
115-
])
116-
->schema([
117-
Forms\Components\Toggle::make('show_api_docs')
118-
->label('Allow access to API docs')
119-
->helperText('When enabled you can access the API documentation using the "API Docs" button. When disabled, the docs endpoint will return a 403 (Unauthorized). NOTE: The API will respond regardless of this setting. You do not need to enable it to use the API.'),
120-
])
121185
]);
122186
}
123187
}

app/Filament/Resources/CustomPlaylistResource.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Filament\Tables\Table;
1616
use Illuminate\Database\Eloquent\Builder;
1717
use Illuminate\Database\Eloquent\SoftDeletingScope;
18+
use App\Facades\PlaylistUrlFacade;
1819

1920
class CustomPlaylistResource extends Resource
2021
{
@@ -27,6 +28,12 @@ public static function getGloballySearchableAttributes(): array
2728
return ['name'];
2829
}
2930

31+
public static function getGlobalSearchEloquentQuery(): Builder
32+
{
33+
return parent::getGlobalSearchEloquentQuery()
34+
->where('user_id', auth()->id());
35+
}
36+
3037
protected static ?string $navigationIcon = 'heroicon-o-list-bullet';
3138

3239
protected static ?string $navigationGroup = 'Custom';
@@ -94,17 +101,17 @@ public static function table(Table $table): Table
94101
Tables\Actions\Action::make('Download M3U')
95102
->label('Download M3U')
96103
->icon('heroicon-o-arrow-down-tray')
97-
->url(fn($record) => \App\Facades\PlaylistUrlFacade::getUrls($record)['m3u'])
104+
->url(fn($record) => PlaylistUrlFacade::getUrls($record)['m3u'])
98105
->openUrlInNewTab(),
99106
Tables\Actions\Action::make('Download M3U')
100107
->label('Download EPG')
101108
->icon('heroicon-o-arrow-down-tray')
102-
->url(fn($record) => \App\Facades\PlaylistUrlFacade::getUrls($record)['epg'])
109+
->url(fn($record) => PlaylistUrlFacade::getUrls($record)['epg'])
103110
->openUrlInNewTab(),
104111
Tables\Actions\Action::make('HDHomeRun URL')
105112
->label('HDHomeRun Url')
106113
->icon('heroicon-o-arrow-top-right-on-square')
107-
->url(fn($record) => \App\Facades\PlaylistUrlFacade::getUrls($record)['hdhr'])
114+
->url(fn($record) => PlaylistUrlFacade::getUrls($record)['hdhr'])
108115
->openUrlInNewTab(),
109116
Tables\Actions\DeleteAction::make(),
110117
])->button()->hiddenLabel()
@@ -154,6 +161,8 @@ public static function getForm(): array
154161
])->hiddenOn(['create']),
155162
Forms\Components\Section::make('Links')
156163
->description('These links are generated based on the current playlist configuration. Only enabled channels will be included.')
164+
->collapsible()
165+
->collapsed(false)
157166
->schema([
158167
Forms\Components\Toggle::make('short_urls_enabled')
159168
->label('Use Short URLs')
@@ -162,9 +171,11 @@ public static function getForm(): array
162171
->inline(false)
163172
->default(false),
164173
PlaylistM3uUrl::make('m3u_url')
174+
->label('M3U URL')
165175
->columnSpan(2)
166176
->dehydrated(false), // don't save the value in the database
167177
PlaylistEpgUrl::make('epg_url')
178+
->label('EPG URL')
168179
->columnSpan(2)
169180
->dehydrated(false) // don't save the value in the database
170181
])->hiddenOn(['create']),

app/Filament/Resources/EpgChannelResource.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public static function getGloballySearchableAttributes(): array
2424
return ['name', 'display_name'];
2525
}
2626

27+
public static function getGlobalSearchEloquentQuery(): Builder
28+
{
29+
return parent::getGlobalSearchEloquentQuery()
30+
->where('user_id', auth()->id());
31+
}
32+
2733
protected static ?string $navigationIcon = 'heroicon-o-photo';
2834

2935
protected static ?string $label = 'Channels';

app/Filament/Resources/GroupResource.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public static function getGloballySearchableAttributes(): array
3232
return ['name', 'name_internal'];
3333
}
3434

35+
public static function getGlobalSearchEloquentQuery(): Builder
36+
{
37+
return parent::getGlobalSearchEloquentQuery()
38+
->where('user_id', auth()->id());
39+
}
40+
3541
protected static ?string $navigationIcon = 'heroicon-o-queue-list';
3642

3743
protected static ?string $navigationGroup = 'Playlist';

app/Filament/Resources/MergedPlaylistResource.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Filament\Tables\Table;
1616
use Illuminate\Database\Eloquent\Builder;
1717
use Illuminate\Database\Eloquent\SoftDeletingScope;
18+
use App\Facades\PlaylistUrlFacade;
1819

1920
class MergedPlaylistResource extends Resource
2021
{
@@ -27,6 +28,12 @@ public static function getGloballySearchableAttributes(): array
2728
return ['name'];
2829
}
2930

31+
public static function getGlobalSearchEloquentQuery(): Builder
32+
{
33+
return parent::getGlobalSearchEloquentQuery()
34+
->where('user_id', auth()->id());
35+
}
36+
3037
protected static ?string $navigationIcon = 'heroicon-o-forward';
3138

3239
protected static ?string $navigationGroup = 'Custom';
@@ -89,17 +96,17 @@ public static function table(Table $table): Table
8996
Tables\Actions\Action::make('Download M3U')
9097
->label('Download M3U')
9198
->icon('heroicon-o-arrow-down-tray')
92-
->url(fn($record) => \App\Facades\PlaylistUrlFacade::getUrls($record)['m3u'])
99+
->url(fn($record) => PlaylistUrlFacade::getUrls($record)['m3u'])
93100
->openUrlInNewTab(),
94101
Tables\Actions\Action::make('Download M3U')
95102
->label('Download EPG')
96103
->icon('heroicon-o-arrow-down-tray')
97-
->url(fn($record) => \App\Facades\PlaylistUrlFacade::getUrls($record)['epg'])
104+
->url(fn($record) => PlaylistUrlFacade::getUrls($record)['epg'])
98105
->openUrlInNewTab(),
99106
Tables\Actions\Action::make('HDHomeRun URL')
100107
->label('HDHomeRun Url')
101108
->icon('heroicon-o-arrow-top-right-on-square')
102-
->url(fn($record) => \App\Facades\PlaylistUrlFacade::getUrls($record)['hdhr'])
109+
->url(fn($record) => PlaylistUrlFacade::getUrls($record)['hdhr'])
103110
->openUrlInNewTab(),
104111
Tables\Actions\DeleteAction::make(),
105112
])->button()->hiddenLabel()
@@ -149,6 +156,8 @@ public static function getForm(): array
149156
])->hiddenOn(['create']),
150157
Forms\Components\Section::make('Links')
151158
->description('These links are generated based on the current playlist configuration. Only enabled channels will be included.')
159+
->collapsible()
160+
->collapsed(false)
152161
->schema([
153162
Forms\Components\Toggle::make('short_urls_enabled')
154163
->label('Use Short URLs')
@@ -157,9 +166,11 @@ public static function getForm(): array
157166
->inline(false)
158167
->default(false),
159168
PlaylistM3uUrl::make('m3u_url')
169+
->label('M3U URL')
160170
->columnSpan(2)
161171
->dehydrated(false), // don't save the value in the database
162172
PlaylistEpgUrl::make('epg_url')
173+
->label('EPG URL')
163174
->columnSpan(2)
164175
->dehydrated(false) // don't save the value in the database
165176
])->hiddenOn(['create']),

0 commit comments

Comments
 (0)