App-MHFS
view release on metacpan or search on metacpan
lib/MHFS/HTTP/Server/Client/Request.pm view on Meta::CPAN
# expects unicode string (not bytes)
sub SendText {
my ($self, $mime, $buf, $options) = @_;
@_ = ($self, $mime, encode('UTF-8', $buf), $options);
goto &SendBytes;
}
# expects unicode string (not bytes)
sub SendHTML {
my ($self, $buf, $options) = @_;;
@_ = ($self, 'text/html; charset=utf-8', encode('UTF-8', $buf), $options);
goto &SendBytes;
}
# expects perl data structure
sub SendAsJSON {
my ($self, $obj, $options) = @_;
@_ = ($self, 'application/json', encode_json($obj), $options);
goto &SendBytes;
}
lib/MHFS/Plugin/Kodi.pm view on Meta::CPAN
my $b_metadir = $params->{meta} . '/' . encode_utf8($medianame) . (defined $season ? '/'.encode_utf8($season). (defined $episode ? '/'.encode_utf8($episode) : '') : '');
my $b_plotfile = $params->{meta} . '/' . encode_utf8($medianame) . '/'. (defined $season ? encode_utf8($season).'/season.json' : 'plot.txt');
# fast path, check disk
if (defined $season && $metadatatype eq 'plot') {
try {
my $bytes = read_file($b_plotfile);
my $json = decode_json($bytes);
if (defined $episode) {
$json = MHFS::Kodi::Season::_get_season_episode($json, $episode);
}
$request->SendText('text/plain; charset=utf-8', $json->{overview});
return;
} catch ($e){}
} elsif (-d $b_metadir) {
my %acceptable = ( 'thumb' => ['png', 'jpg'], 'fanart' => ['png', 'jpg'], 'plot' => ['txt']);
if(exists $acceptable{$metadatatype}) {
foreach my $totry (@{$acceptable{$metadatatype}}) {
my $path = $b_metadir.'/'.$metadatatype.".$totry";
if(-f $path) {
$request->SendLocalFile($path);
return;
lib/MHFS/Plugin/Kodi.pm view on Meta::CPAN
MHFS::Kodi::Season::_get_season_episode($_[0], $episode)
})
})->then(sub {
# get the metadata
if (! defined $season && ($metadatatype eq 'plot' || ! -f "$b_metadir/plot.txt")) {
make_path($b_metadir);
try { write_text_file_lossy("$b_metadir/plot.txt", $_[0]->{overview}) }
catch ($e) { say "wierd, creating file failed?"; }
}
if($metadatatype eq 'plot') {
$request->SendText('text/plain; charset=utf-8', $_[0]->{overview});
return;
}
# thumb or fanart
my $imagepartial = ($metadatatype eq 'thumb') ? (! defined $episode ? $_[0]->{poster_path} : $_[0]->{still_path}) : $_[0]->{backdrop_path};
if (!$imagepartial || $imagepartial !~ /(\.[^\.]+)$/) {
die 'path not matched '.$imagepartial;
}
my $ext = $1;
make_path($b_metadir);
return MHFS::Promise->new($request->{client}{server}{evp}, sub {
lib/MHFS/Plugin/MusicLibrary.pm view on Meta::CPAN
# route
my $qs = defined($request->{'qs'}{'ptrack'}) ? {'ptrack' => $request->{'qs'}{'ptrack'}} : undef;
if($fmt eq 'worklet') {
return $request->SendRedirect(307, 'static/music_worklet_inprogress/', $qs);
}
elsif($fmt eq 'musicdbjson') {
return $request->SendBytes('application/json', $self->{'musicdbjson'});
}
elsif($fmt eq 'musicdbhtml') {
return $request->SendBytes("text/html; charset=utf-8", $self->{'musicdbhtml'});
}
elsif($fmt eq 'gapless') {
$qs->{fmt} = 'musicinc';
return $request->SendRedirect(301, "music", $qs);
}
elsif($fmt eq 'musicinc') {
return $request->SendRedirect(307, 'static/music_inc/', $qs);
}
elsif($fmt eq 'legacy') {
say __PACKAGE__.": legacy";
return $request->SendBytes("text/html; charset=utf-8", $self->{'html'});
}
else {
return $request->Send404;
}
}
my $SEGMENT_DURATION = 5;
my %TRACKDURATION;
my %TRACKINFO;
sub SendTrack {
lib/MHFS/Util.pm view on Meta::CPAN
'mp4' => 'video/mp4',
'ts' => 'video/mp2t',
'mkv' => 'video/x-matroska',
'webm' => 'video/webm',
'flv' => 'video/x-flv',
# media
'mpd' => 'application/dash+xml',
'm3u8' => 'application/x-mpegURL',
'm3u8_v' => 'application/x-mpegURL',
# text
'html' => 'text/html; charset=utf-8',
'json' => 'application/json',
'js' => 'application/javascript',
'txt' => 'text/plain; charset=utf-8',
'css' => 'text/css',
# images
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'png' => 'image/png',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
# binary
'pdf' => 'application/pdf',
'tar' => 'application/x-tar',
share/public_html/static/browse_gazelle_music.html view on Meta::CPAN
<html>
<head>
<meta charset="utf-8"/>
<style>
body {
width: 60%;
}
.results {
/*width: 100%;*/
}
.result {
/*width: 100%;*/
share/public_html/static/music_worklet_inprogress/decoder/bin/_mhfscl.js view on Meta::CPAN
async function Module(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope!="undefined";var ENVIRONMENT_IS_NODE=typeof process=="object"&&process.versions?....
;return moduleRtn}export default Module;
( run in 3.983 seconds using v1.01-cache-2.11-cpan-697924b945d )