Skip to content

Commit

Permalink
LANraragi Release 0.8.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Difegue authored Apr 25, 2022
2 parents 9c32ce6 + 411b4a4 commit 0edd1b2
Show file tree
Hide file tree
Showing 46 changed files with 947 additions and 408 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/push-continous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ jobs:
- name: Build MSI Installer
shell: powershell
run: |
Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll";
Enter-VsDevShell -VsInstallPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" -SkipAutomaticLocation
[array]$installPath = &"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property installationpath
# Get first line of installPath in case we have multiple VS installs
Import-Module (Join-Path $installPath[0] "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
# Import the VS shell module
Enter-VsDevShell -VsInstallPath $installPath[0] -SkipAutomaticLocation
$ErrorActionPreference = 'Continue'
git submodule init
git submodule update
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/release-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ jobs:
- name: Build MSI Installer
shell: powershell
run: |
Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll";
Enter-VsDevShell -VsInstallPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" -SkipAutomaticLocation
[array]$installPath = &"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property installationpath
# Get first line of installPath in case we have multiple VS installs
Import-Module (Join-Path $installPath[0] "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
# Import the VS shell module
Enter-VsDevShell -VsInstallPath $installPath[0] -SkipAutomaticLocation
$ErrorActionPreference = 'Continue'
git submodule init
git submodule update
Expand Down Expand Up @@ -63,7 +66,7 @@ jobs:
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
with:
args: 'Windows Installer built and available on the Release page! :logo:🪟'
args: 'Windows Installer built and available on the Release page! <:logo:821516019179978772>🪟'

buildLatestDocker:
name: Build Latest Docker image
Expand Down
69 changes: 69 additions & 0 deletions lib/LANraragi/Controller/Api/Minion.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package LANraragi::Controller::Api::Minion;
use Mojo::Base 'Mojolicious::Controller';

use Mojo::JSON qw(encode_json decode_json);
use Redis;

use LANraragi::Model::Stats;
use LANraragi::Utils::TempFolder qw(get_tempsize clean_temp_full);
use LANraragi::Utils::Generic qw(render_api_response);
use LANraragi::Utils::Plugins qw(get_plugin get_plugins get_plugin_parameters use_plugin);

# Returns basic info for the given Minion job id.
sub minion_job_status {
my $self = shift;
my $id = $self->stash('jobid');
my $job = $self->minion->job($id);

if ($job) {

my %info = %{ $job->info };

# Render a basic json containing only task, state and error
$self->render(
json => {
task => $info{task},
state => $info{state},
error => $info{error}
}
);

} else {
render_api_response( $self, "minion_job_status", "No job with this ID." );
}
}

# Returns the full info for the given Minion job id.
sub minion_job_detail {
my $self = shift;
my $id = $self->stash('jobid');
my $job = $self->minion->job($id);

if ($job) {
$self->render( json => $job->info );
} else {
render_api_response( $self, "minion_job_detail", "No job with this ID." );
}
}

# Queues a job into Minion.
sub queue_minion_job {

my ($self) = shift;
my $jobname = $self->stash('jobname');
my @jobargs = decode_json( $self->req->param('args') );
my $priority = $self->req->param('priority') || 0;

my $jobid = $self->minion->enqueue( $jobname => @jobargs => { priority => $priority } );

$self->render(
json => {
operation => "queue_minion_job",
success => 1,
job => $jobid
}
);
}

1;

38 changes: 1 addition & 37 deletions lib/LANraragi/Controller/Api/Other.pm
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,6 @@ sub list_plugins {
$self->render( json => \@plugins );
}

# Returns the info for the given Minion job id.
sub minion_job_status {
my $self = shift;
my $id = $self->stash('jobid');

my $job = $self->minion->job($id);

if ($job) {
$self->render( json => $job->info );
} else {
render_api_response( $self, "minion_job_status", "No job with this ID." );
}
}

# Queue the regen_all_thumbnails Minion job.
sub regen_thumbnails {
my $self = shift;
Expand All @@ -102,7 +88,6 @@ sub regen_thumbnails {
}

sub download_url {

my ($self) = shift;
my $url = $self->req->param('url');
my $catid = $self->req->param('catid');
Expand Down Expand Up @@ -130,8 +115,7 @@ sub download_url {

# Uses a plugin, with the standard global arguments and a provided oneshot argument.
sub use_plugin_sync {

my ($self) = shift;
my ($self) = shift;
my $id = $self->req->param('id') || 0;
my $plugname = $self->req->param('plugin');
my $input = $self->req->param('arg');
Expand All @@ -153,7 +137,6 @@ sub use_plugin_sync {

# Queues a plugin execution into Minion.
sub use_plugin_async {

my ($self) = shift;
my $id = $self->req->param('id') || 0;
my $priority = $self->req->param('priority') || 0;
Expand All @@ -171,24 +154,5 @@ sub use_plugin_async {
);
}

# Queues a job into Minion.
sub queue_minion_job {

my ($self) = shift;
my $jobname = $self->stash('jobname');
my @jobargs = decode_json( $self->req->param('args') );
my $priority = $self->req->param('priority') || 0;

my $jobid = $self->minion->enqueue( $jobname => @jobargs => { priority => $priority } );

$self->render(
json => {
operation => "queue_minion_job",
success => 1,
job => $jobid
}
);
}

1;

26 changes: 26 additions & 0 deletions lib/LANraragi/Controller/Api/Shinobu.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@ sub shinobu_status {
);
}

sub reset_filemap {
my $self = shift;

# This is a shinobu endpoint even though we're deleting stuff in redis
# since we'll have to restart shinobu anyway to proc filemap re-creation.

my $redis = $self->LRR_CONF->get_redis;
$redis->del("LRR_FILEMAP");

my $shinobu = ${ retrieve( get_temp . "/shinobu.pid" ) };

#commit sudoku
$shinobu->kill();

# Create a new Process, automatically stored in TEMP_FOLDER/shinobu.pid
my $proc = start_shinobu($self);

$self->render(
json => {
operation => "shinobu_rescan",
success => $proc->poll(),
new_pid => $proc->pid
}
);
}

sub stop_shinobu {
my $self = shift;
my $shinobu = ${ retrieve( get_temp . "/shinobu.pid" ) };
Expand Down
2 changes: 1 addition & 1 deletion lib/LANraragi/Controller/Upload.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package LANraragi::Controller::Upload;
use Mojo::Base 'Mojolicious::Controller';

use Redis;
use File::Temp qw/ tempfile tempdir /;
use File::Temp qw(tempdir);
use File::Copy;
use File::Find;
use File::Basename;
Expand Down
28 changes: 16 additions & 12 deletions lib/LANraragi/Model/Archive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use Cwd 'abs_path';
use Redis;
use Time::HiRes qw(usleep);
use File::Basename;
use File::Temp qw(tempfile);
use File::Copy "cp";
use File::Path qw(make_path);
use Mojo::Util qw(xml_escape);

use LANraragi::Utils::Generic qw(get_tag_with_namespace remove_spaces remove_newlines render_api_response);
Expand Down Expand Up @@ -54,11 +54,11 @@ sub generate_opds_catalog {
my $tags = $arcdata->{tags};

# Infer a few OPDS-related fields from the tags
$arcdata->{dateadded} = get_tag_with_namespace( "dateadded", $tags, "2010-01-10T10:01:11Z" );
$arcdata->{author} = get_tag_with_namespace( "artist", $tags, "" );
$arcdata->{language} = get_tag_with_namespace( "language", $tags, "" );
$arcdata->{circle} = get_tag_with_namespace( "group", $tags, "" );
$arcdata->{event} = get_tag_with_namespace( "event", $tags, "" );
$arcdata->{dateadded} = get_tag_with_namespace( "date_added", $tags, "2010-01-10T10:01:11Z" );
$arcdata->{author} = get_tag_with_namespace( "artist", $tags, "" );
$arcdata->{language} = get_tag_with_namespace( "language", $tags, "" );
$arcdata->{circle} = get_tag_with_namespace( "group", $tags, "" );
$arcdata->{event} = get_tag_with_namespace( "event", $tags, "" );

# Application/zip is universally hated by all readers so it's better to use x-cbz and x-cbr here.
if ( $file =~ /^(.*\/)*.+\.(pdf)$/ ) {
Expand Down Expand Up @@ -124,7 +124,7 @@ sub find_untagged_archives {
remove_newlines($t);

# The following are basic and therefore don't count as "tagged"
$nondefaulttags += 1 unless $t =~ /(artist|parody|series|language|event|group|date_added):.*/;
$nondefaulttags += 1 unless $t =~ /(artist|parody|series|language|event|group|date_added|timestamp):.*/;
}

#If the archive has no tags, or the tags namespaces are only from
Expand Down Expand Up @@ -287,17 +287,21 @@ sub serve_page {
# Apply resizing transformation if set in Settings
if ( LANraragi::Model::Config->enable_resize ) {

# Use File::Temp to copy the extracted file and resize it
my ( $fh, $filename ) = tempfile();
cp( $file, $fh );
# Store resized files in a subfolder of the ID's temp folder
my $resized_file = "$tempfldr/$id/resized/$path";
my ( $n, $resized_folder, $e ) = fileparse( $resized_file, qr/\.[^.]*/ );
make_path($resized_folder);

$logger->debug("Copying file to $resized_folder for resize transformation");
cp( $file, $resized_file );

my $threshold = LANraragi::Model::Config->get_threshold;
my $quality = LANraragi::Model::Config->get_readquality;
LANraragi::Model::Reader::resize_image( $filename, $quality, $threshold );
LANraragi::Model::Reader::resize_image( $resized_file, $quality, $threshold );

# resize_image always converts the image to jpg
$self->render_file(
filepath => $filename,
filepath => $resized_file,
content_disposition => "inline",
format => "jpg"
);
Expand Down
5 changes: 3 additions & 2 deletions lib/LANraragi/Model/Upload.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use warnings;
use Redis;
use URI::Escape;
use File::Basename;
use File::Temp qw/ tempfile tempdir /;
use File::Temp qw(tempdir);
use File::Find qw(find);
use File::Copy qw(move);

Expand Down Expand Up @@ -107,9 +107,10 @@ sub handle_incoming_file {
return ( 0, $id, $name, "The file couldn't be moved to your content folder!" );
}

# Now that the file has been copied, we can add the timestamp tag.
# Now that the file has been copied, we can add the timestamp tag and calculate pagecount.
# (The file being physically present is necessary in case last modified time is used)
LANraragi::Utils::Database::add_timestamp_tag( $redis, $id );
LANraragi::Utils::Database::add_pagecount( $redis, $id );
$redis->quit();

$logger->debug("Running autoplugin on newly uploaded file $id...");
Expand Down
4 changes: 2 additions & 2 deletions lib/LANraragi/Plugin/Metadata/EHentai.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sub plugin_info {
{ type => "bool", desc => "Fetch using thumbnail first (falls back to title)" },
{ type => "bool", desc => "Use ExHentai (enable to search for fjorded content without star cookie)" },
{ type => "bool",
desc => "Save the original Japanese title when available instead of the English or " . "romanised title"
desc => "Save the original title when available instead of the English or romanised title"
},
{ type => "bool", desc => "Fetch additional timestamp (time posted) and uploader metadata" },
{ type => "bool", desc => "Search expunged galleries as well" },
Expand Down Expand Up @@ -69,7 +69,7 @@ sub get_tags {
$gID = $1;
$gToken = $2;
$logger->debug("Skipping search and using gallery $gID / $gToken from oneshot args");
} elsif ( $lrr_info->{existing_tags} =~ /.*source:e(?:x|-)hentai\.org\/g\/([0-9]*)\/([0-z]*)\/*.*/gi ) {
} elsif ( $lrr_info->{existing_tags} =~ /.*source:\s*e(?:x|-)hentai\.org\/g\/([0-9]*)\/([0-z]*)\/*.*/gi ) {
$gID = $1;
$gToken = $2;
$hasSrc = 1;
Expand Down
Loading

0 comments on commit 0edd1b2

Please sign in to comment.